diff options
author | aszlig <aszlig@nix.build> | 2021-06-16 03:30:26 +0200 |
---|---|---|
committer | aszlig <aszlig@nix.build> | 2021-06-16 04:12:04 +0200 |
commit | 9ecde9d16578580e3464ace89a30b44b9de123bb (patch) | |
tree | 46946fae83bf4e8e6f551a22e0592fc7f47fc35c /nixos/tests | |
parent | 32b767b57eb02d0dcd3bf34e7dc5d6cb6f8a7c54 (diff) | |
download | nixlib-9ecde9d16578580e3464ace89a30b44b9de123bb.tar nixlib-9ecde9d16578580e3464ace89a30b44b9de123bb.tar.gz nixlib-9ecde9d16578580e3464ace89a30b44b9de123bb.tar.bz2 nixlib-9ecde9d16578580e3464ace89a30b44b9de123bb.tar.lz nixlib-9ecde9d16578580e3464ace89a30b44b9de123bb.tar.xz nixlib-9ecde9d16578580e3464ace89a30b44b9de123bb.tar.zst nixlib-9ecde9d16578580e3464ace89a30b44b9de123bb.zip |
nixos/tests/overlayfs: Fix erroneous backslashes
Since commit b7749c76715ba96727f7a12bc2514ddfa6847813, commands run as part of VM tests are exiting immediately if an error happens. When converting the overlayfs test to Python in commit 5ae92144ba04caefaf56b4204abe85b71dbb527b, the individual test commands were crammed into one big string instead of using a series of test commands like done in the Perl version. Additionally, the backslash-escaped dollar signs were necessary in Perl's double-quoted strings to avoid variable interpolation, for Python however, this results in an actual backslash being inserted into the command. While this obviously results in an exit code of 1 (without an error message, since it's using bash's expression evaluation command), the test didn't fail because putting all these commands in one string will result in only the last error code being relevant. With the change to "set -e" for commands sent to test machines, this has changed and with the exit code of all commands now relevant, the test now fails because the errors from individual command substitutions that were prevented by escaping the dollar sign are now actually visible. This in turn also means that until now, we wouldn't have noticed if the overlayfs test would have failed for real. Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'nixos/tests')
-rw-r--r-- | nixos/tests/overlayfs.nix | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/nixos/tests/overlayfs.nix b/nixos/tests/overlayfs.nix index 142e7d378b2f..6d6f8c5e2c2c 100644 --- a/nixos/tests/overlayfs.nix +++ b/nixos/tests/overlayfs.nix @@ -26,21 +26,21 @@ import ./make-test-python.nix ({ pkgs, ... }: { mount -t overlay overlay -o lowerdir=/tmp/mnt/lower,upperdir=/tmp/mnt/upper,workdir=/tmp/mnt/work /tmp/mnt/merged # Test new echo 'New' > /tmp/mnt/merged/new.txt - [[ "\$(cat /tmp/mnt/merged/new.txt)" == "New" ]] + [[ "$(cat /tmp/mnt/merged/new.txt)" == "New" ]] # Test replace - [[ "\$(cat /tmp/mnt/merged/replace.txt)" == "Replace" ]] + [[ "$(cat /tmp/mnt/merged/replace.txt)" == "Replace" ]] echo 'Replaced' > /tmp/mnt/merged/replace-tmp.txt mv /tmp/mnt/merged/replace-tmp.txt /tmp/mnt/merged/replace.txt - [[ "\$(cat /tmp/mnt/merged/replace.txt)" == "Replaced" ]] + [[ "$(cat /tmp/mnt/merged/replace.txt)" == "Replaced" ]] # Overwrite - [[ "\$(cat /tmp/mnt/merged/overwrite.txt)" == "Overwrite" ]] + [[ "$(cat /tmp/mnt/merged/overwrite.txt)" == "Overwrite" ]] echo 'Overwritten' > /tmp/mnt/merged/overwrite.txt - [[ "\$(cat /tmp/mnt/merged/overwrite.txt)" == "Overwritten" ]] + [[ "$(cat /tmp/mnt/merged/overwrite.txt)" == "Overwritten" ]] # Test append - [[ "\$(cat /tmp/mnt/merged/append.txt)" == "Append" ]] + [[ "$(cat /tmp/mnt/merged/append.txt)" == "Append" ]] echo 'ed' >> /tmp/mnt/merged/append.txt #"cat /tmp/mnt/merged/append.txt && exit 1 - [[ "\$(cat /tmp/mnt/merged/append.txt)" == "Append\ned" ]] + [[ "$(cat /tmp/mnt/merged/append.txt)" == "Append\ned" ]] umount /tmp/mnt/merged umount /tmp/mnt udevadm settle |