From c8e000ef6be08c492f79b51b9752e5d8b9b26d59 Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Tue, 17 Mar 2020 17:48:40 -0400 Subject: [PATCH] Fix: Tests: trace path wildcards not expanded MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Issue ===== Some testcases related to `--live` sessions in `tools/clear/{test_ust,test_kernel}` fail with the following error: ls: cannot access '/tmp/tmp.gi1eVM3fZ9/tmp.dNL0WHRTQ3/ci-node-bionic-amd64-02-04/LUP49x7iV7xexehS*': No such file or directory not ok 61 - Failed to list content of directory "/tmp/tmp.gi1eVM3fZ9/tmp.dNL0WHRTQ3/ci-node-bionic-amd64-02-04/LUP49x7iV7xexehS*" FAIL: tools/clear/test_ust 61 - Failed to list content of directory "/tmp/tmp.gi1eVM3fZ9/tmp.dNL0WHRTQ3/ci-node-bionic-amd64-02-04/LUP49x7iV7xexehS*" # Failed test 'Failed to list content of directory "/tmp/tmp.gi1eVM3fZ9/tmp.dNL0WHRTQ3/ci-node-bionic-amd64-02-04/LUP49x7iV7xexehS*"' # in ./tools/clear//../../../utils/tap/tap.sh:fail() at line 159. They fail because the wildcard character `*` is used in a path and is not expanded when comes the time to list the content of the expanded path. In `--live` related tests, we use a wildcard in those paths because we can't know the full name of the output directory as it's named by the sessiond. This bug was introduced (or rather not fixed) by the following commit: commit 94360c17201a28466af49058735166c73f9ae130 Author: Francis Deslauriers Date: Fri Mar 6 18:18:14 2020 -0500 Fix: Tests: utils.sh: merge `validate_{directory,folder_is}_empty` functions Solution ======== Remove the double quotes around the path variable so that wildcards can be expanded as expected. Signed-off-by: Francis Deslauriers Change-Id: If4a72fab0d487cf6e6b021dfad9eca6d0d60d5f4 Signed-off-by: Jérémie Galarneau --- tests/utils/utils.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index b326c5bcf..88a4ddd20 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -1860,7 +1860,9 @@ function validate_directory_empty () { local trace_path="$1" - files="$(ls -A "$trace_path")" + # Do not double quote `$trace_path` below as we want wildcards to be + # expanded. + files="$(ls -A $trace_path)" ret=$? if [ $ret -ne 0 ]; then fail "Failed to list content of directory \"$trace_path\"" -- 2.34.1