]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-13-*: remove containers created in test before running the test
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 31 Mar 2020 09:23:21 +0000 (11:23 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 31 Mar 2020 12:37:20 +0000 (14:37 +0200)
The test would fail when run again from the same image. So let's
rename the stuff we create to be more unique, and remove it before
running the test. (Removing it after would be more elegant, but it's
hard to make sure that everything is removed when things fail halfway.
Cleanup *before* tests is much more rebust.)

test/TEST-13-NSPAWN-SMOKE/test.sh
test/units/testsuite-13.sh

index c777c166f76fb0fd2d1e7bc01b7818f59dfbb024..4a08cfd4ec0a5e74883877dd4d43227bece1be72 100755 (executable)
@@ -15,8 +15,8 @@ test_create_image() {
         setup_basic_environment
         mask_supporting_services
 
-        ../create-busybox-container $initdir/nc-container
-        initdir="$initdir/nc-container" dracut_install nc ip
+        ../create-busybox-container $initdir/testsuite-13.nc-container
+        initdir="$initdir/testsuite-13.nc-container" dracut_install nc ip
     )
 }
 
index 0ab684732c6a024b2e274542f41250d5f32e331b..e37420610246c023d959be53bc7821bdf22b2e37 100755 (executable)
@@ -33,7 +33,8 @@ fi
 
 function check_bind_tmp_path {
     # https://github.com/systemd/systemd/issues/4789
-    local _root="/var/lib/machines/bind-tmp-path"
+    local _root="/var/lib/machines/testsuite-13.bind-tmp-path"
+    rm -rf "$_root"
     /usr/lib/systemd/tests/testdata/create-busybox-container "$_root"
     >/tmp/bind
     systemd-nspawn --register=no -D "$_root" --bind=/tmp/bind /bin/sh -c 'test -e /tmp/bind'
@@ -41,7 +42,8 @@ function check_bind_tmp_path {
 
 function check_norbind {
     # https://github.com/systemd/systemd/issues/13170
-    local _root="/var/lib/machines/norbind-path"
+    local _root="/var/lib/machines/testsuite-13.norbind-path"
+    rm -rf "$_root"
     mkdir -p /tmp/binddir/subdir
     echo -n "outer" > /tmp/binddir/subdir/file
     mount -t tmpfs tmpfs /tmp/binddir/subdir
@@ -53,8 +55,9 @@ function check_norbind {
 function check_notification_socket {
     # https://github.com/systemd/systemd/issues/4944
     local _cmd='echo a | $(busybox which nc) -U -u -w 1 /run/systemd/nspawn/notify'
-    systemd-nspawn --register=no -D /nc-container /bin/sh -x -c "$_cmd"
-    systemd-nspawn --register=no -D /nc-container -U /bin/sh -x -c "$_cmd"
+    # /testsuite-13.nc-container is prepared by test.sh
+    systemd-nspawn --register=no -D /testsuite-13.nc-container /bin/sh -x -c "$_cmd"
+    systemd-nspawn --register=no -D /testsuite-13.nc-container -U /bin/sh -x -c "$_cmd"
 }
 
 function run {
@@ -67,7 +70,8 @@ function run {
         return 0
     fi
 
-    local _root="/var/lib/machines/unified-$1-cgns-$2-api-vfs-writable-$3"
+    local _root="/var/lib/machines/testsuite-13.unified-$1-cgns-$2-api-vfs-writable-$3"
+    rm -rf "$_root"
     /usr/lib/systemd/tests/testdata/create-busybox-container "$_root"
     SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" -b
     SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" --private-network -b