tests: traverse directories before removing them during cleanup

Without `-depth` find will first `rm -rf foo` and then try to recurse into
`foo` resulting in `No such file or directory`.

With this the various `|| true` suffixes should no longer be required.

Lastly, in test/cases/040_packages/013_mkimage/test.sh cleanup any
`disk.qcow2*` detritus as well as the image itself.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
This commit is contained in:
Ian Campbell 2017-06-13 17:13:15 +01:00
parent 13a94c7a3c
commit 58d61d0846
10 changed files with 13 additions and 12 deletions

View File

@ -12,7 +12,7 @@ NAME=check
clean_up() { clean_up() {
# remove any images # remove any images
find . -iname "${NAME}*" -exec rm {} \; find . -depth -iname "${NAME}*" -exec rm -rf {} \;
} }
trap clean_up EXIT trap clean_up EXIT

View File

@ -10,7 +10,7 @@ set -e
. "${RT_PROJECT_ROOT}/_lib/lib.sh" . "${RT_PROJECT_ROOT}/_lib/lib.sh"
clean_up() { clean_up() {
find . -iname "test-kernel-config*" -not -iname "*.yml" -exec rm -rf {} \; || true find . -depth -iname "test-kernel-config*" -not -iname "*.yml" -exec rm -rf {} \;
} }
trap clean_up EXIT trap clean_up EXIT

View File

@ -10,7 +10,7 @@ set -e
. "${RT_PROJECT_ROOT}/_lib/lib.sh" . "${RT_PROJECT_ROOT}/_lib/lib.sh"
clean_up() { clean_up() {
find . -iname "test-kernel-config*" -not -iname "*.yml" -exec rm -rf {} \; || true find . -depth -iname "test-kernel-config*" -not -iname "*.yml" -exec rm -rf {} \;
} }
trap clean_up EXIT trap clean_up EXIT

View File

@ -10,7 +10,7 @@ set -e
. "${RT_PROJECT_ROOT}/_lib/lib.sh" . "${RT_PROJECT_ROOT}/_lib/lib.sh"
clean_up() { clean_up() {
find . -iname "test-kernel-config*" -not -iname "*.yml" -exec rm -rf {} \; || true find . -depth -iname "test-kernel-config*" -not -iname "*.yml" -exec rm -rf {} \;
} }
trap clean_up EXIT trap clean_up EXIT

View File

@ -13,7 +13,7 @@ IMAGE_NAME="kmod-test"
clean_up() { clean_up() {
docker rmi ${IMAGE_NAME} || true docker rmi ${IMAGE_NAME} || true
find . -iname "kmod*" -not -iname "*.yml" -exec rm -rf {} \; || true find . -depth -iname "kmod*" -not -iname "*.yml" -exec rm -rf {} \;
} }
trap clean_up EXIT trap clean_up EXIT

View File

@ -10,7 +10,7 @@ set -e
. "${RT_PROJECT_ROOT}/_lib/lib.sh" . "${RT_PROJECT_ROOT}/_lib/lib.sh"
clean_up() { clean_up() {
find . -iname "test-binfmt*" -not -iname "*.yml" -exec rm -rf {} \; || true find . -depth -iname "test-binfmt*" -not -iname "*.yml" -exec rm -rf {} \;
} }
trap clean_up EXIT trap clean_up EXIT

View File

@ -10,7 +10,7 @@ set -e
. "${RT_PROJECT_ROOT}/_lib/lib.sh" . "${RT_PROJECT_ROOT}/_lib/lib.sh"
clean_up() { clean_up() {
find . -iname "test-ca-certificates*" -not -iname "*.yml" -exec rm -rf {} \; || true find . -depth -iname "test-ca-certificates*" -not -iname "*.yml" -exec rm -rf {} \;
} }
trap clean_up EXIT trap clean_up EXIT

View File

@ -10,7 +10,7 @@ set -e
. "${RT_PROJECT_ROOT}/_lib/lib.sh" . "${RT_PROJECT_ROOT}/_lib/lib.sh"
clean_up() { clean_up() {
find . -iname "test-dhcpcd*" -not -iname "*.yml" -exec rm -rf {} \; || true find . -depth -iname "test-dhcpcd*" -not -iname "*.yml" -exec rm -rf {} \;
} }
trap clean_up EXIT trap clean_up EXIT

View File

@ -10,9 +10,10 @@ set -e
. "${RT_PROJECT_ROOT}/_lib/lib.sh" . "${RT_PROJECT_ROOT}/_lib/lib.sh"
clean_up() { clean_up() {
find . -iname "run*" -not -iname "*.yml" -exec rm -rf {} \; find . -depth -iname "run*" -not -iname "*.yml" -exec rm -rf {} \;
find . -iname "mkimage*" -not -iname "*.yml" -exec rm -rf {} \; find . -depth -iname "mkimage*" -not -iname "*.yml" -exec rm -rf {} \;
rm -f disk.qcow2 tarball.img find . -depth -iname "disk.qcow2*" -not -iname "*.yml" -exec rm -rf {} \;
rm -f tarball.img
} }
trap clean_up EXIT trap clean_up EXIT

View File

@ -10,7 +10,7 @@ set -e
. "${RT_PROJECT_ROOT}/_lib/lib.sh" . "${RT_PROJECT_ROOT}/_lib/lib.sh"
clean_up() { clean_up() {
find . -iname "test-sysctl*" -not -iname "*.yml" -exec rm -rf {} \; || true find . -depth -iname "test-sysctl*" -not -iname "*.yml" -exec rm -rf {} \;
} }
trap clean_up EXIT trap clean_up EXIT