From 0d915a46babe5e5224f976620ab7692fdb01ad02 Mon Sep 17 00:00:00 2001 From: Zygmunt Krynicki Date: Wed, 29 May 2019 12:08:13 +0200 Subject: tests: correct application of ! / not A single test started failing after introduction of the "not" program. The specific code was (broken down for readability): su -l -c 'test-snapd-sh.with-home-plug -c \ "ln /home/test/snap/test-snapd-sh/common/evil-2 /home/test/bin/evil-2"' test \ 2>&1 | not MATCH '.* Permission denied' Originally there was a `!` in front of the entire expression. At runtime we observe the actual denial, that is symlinking from `$SNAP_USER_COMMON` to `$HOME/bin` is correctly denied, but with, now correctly working negation, it started to fail the test. I'm unsure as to why this happened but a working theory is that the prior approach was designed for `set -o pipefail`, where the `su` command would return the result of failing `ln` command which would cause the whole pipe expression to fail. The fix is to simply remove the negation, since the test works as expected exactly as-is. Signed-off-by: Zygmunt Krynicki --- tests/regression/lp-1797556/task.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/regression/lp-1797556/task.yaml b/tests/regression/lp-1797556/task.yaml index e76b442aca..c0951c33cf 100644 --- a/tests/regression/lp-1797556/task.yaml +++ b/tests/regression/lp-1797556/task.yaml @@ -19,9 +19,9 @@ execute: | test ! -e /home/test/bin/evil-1 test ! -e /home/test/bin/evil-2 if [ "$(snap debug confinement)" = "strict" ]; then - su -l -c 'test-snapd-sh.with-home-plug -c "touch /home/test/bin/evil-1"' test 2>&1 | not MATCH '.* Permission denied' + su -l -c 'test-snapd-sh.with-home-plug -c "touch /home/test/bin/evil-1"' test 2>&1 | MATCH '.* Permission denied' dmesg | grep 'apparmor="DENIED" operation="mknod".* name="/home/test/bin/evil-1"' - su -l -c 'test-snapd-sh.with-home-plug -c "ln /home/test/snap/test-snapd-sh/common/evil-2 /home/test/bin/evil-2"' test 2>&1 | not MATCH '.* Permission denied' + su -l -c 'test-snapd-sh.with-home-plug -c "ln /home/test/snap/test-snapd-sh/common/evil-2 /home/test/bin/evil-2"' test 2>&1 | MATCH '.* Permission denied' dmesg | grep 'apparmor="DENIED" operation="link".* name="/home/test/bin/evil-2"' fi test ! -e /home/test/bin/evil-1 -- cgit v1.2.3