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>
Wed, 25 Mar 2020 19:19:12 +0000 (15:19 -0400)
commitf2489409aa5ac1d21a40790399f1218c93227491
tree5030ec8146a11ef60ad16226e7db8d13d5b31e39
parenteb7aa6e0a9c5f87b1c8280b430a25b896912eecb
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.030906 seconds and 4 git commands to generate.