tests/var-mount: tweak test setup
authorLuca BRUNO <luca.bruno@coreos.com>
Tue, 19 Oct 2021 08:03:09 +0000 (08:03 +0000)
committerLuca BRUNO <luca.bruno@coreos.com>
Tue, 19 Oct 2021 08:03:09 +0000 (08:03 +0000)
This reworks the var-mount destructive test in order to properly use
the datadir for the current stateroot instead of a duplicated one.
In turn, it ensures that the resulting `var.mount` after reboot is
correctly pointing to the same location which hosted `/var` on the
previous boot.

tests/kolainst/destructive/var-mount.sh

index 86c69fd19a33a28ec2d44252d35a33cf7881c89d..ff615f880cc02252818178de0d130a3fd6997332 100755 (executable)
@@ -6,12 +6,9 @@ set -xeuo pipefail
 
 case "${AUTOPKGTEST_REBOOT_MARK:-}" in
   "") 
-    require_writable_sysroot
-    # Hack this off for now
-    chattr -i /sysroot
-    cp -a /var /sysroot/myvar
-    touch /sysroot/myvar/somenewfile
-    echo '/sysroot/myvar /var none bind 0 0' >> /etc/fstab
+    touch "/var/somenewfile"
+    stateroot=$(ostree admin status 2> /dev/null | grep '^\*' | cut -d ' ' -f2 || true)
+    echo "/sysroot/ostree/deploy/${stateroot}/var /var none bind 0 0" >> /etc/fstab
     /tmp/autopkgtest-reboot "2"
     ;;
   "2")