Fix: Tests: utils.sh: merge `validate_{directory,folder_is}_empty` functions
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 6 Mar 2020 23:18:14 +0000 (18:18 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 17 Mar 2020 17:24:16 +0000 (13:24 -0400)
commit94360c17201a28466af49058735166c73f9ae130
tree5030ec8146a11ef60ad16226e7db8d13d5b31e39
parent5bbf6fde94060f0dd7952e8595dcf6f05c61ad2a
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 <francis.deslauriers@efficios.com>
Change-Id: Id75baf16f42866e3b978389f9aada4a2f6b6f2ae
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/regression/tools/clear/test_ust
tests/utils/utils.sh
This page took 0.025971 seconds and 4 git commands to generate.