From: Francis Deslauriers Date: Fri, 6 Mar 2020 23:18:14 +0000 (-0500) Subject: Fix: Tests: utils.sh: merge `validate_{directory,folder_is}_empty` functions X-Git-Tag: v2.13.0-rc1~726 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=94360c17201a28466af49058735166c73f9ae130;hp=94360c17201a28466af49058735166c73f9ae130 Fix: Tests: utils.sh: merge `validate_{directory,folder_is}_empty` functions Issues ====== 1. Both functions aim to do the same thing. 2. The current `validate_folder_is_empty` function uses an erroneous way of checking if a folder is empty. `ls -A` returns zero on success; it doesn't return the number of files and sub-folders. A correct way to get the number of elements in a directory is to pipe the output of `ls -A` to `wc -l`. 3. The `local_path` variable is used undefined in the current `validate_directory_empty` function. It just happens that the `local_path` variable is defined in all but one of the callsites of this function so those calls work as expected. The other call to this function was bogus (tests/regression/tools/clear/test_ust:323) because it uses the `$TRACE_PATH` variable name. Fixes ===== - Merge both functions into one, keeping the name `validate_directory_empty`, - Fix the emptiness check, - Fix usages of `validate_directory_empty` in tests. Signed-off-by: Francis Deslauriers Change-Id: Id75baf16f42866e3b978389f9aada4a2f6b6f2ae Signed-off-by: Jérémie Galarneau ---