mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-05 17:01:00 +01:00
syscall_sysctl test: correctly skip if CONFIG_SYSCTL_SYSCALL=n
From: Simon McVittie <simon.mcvittie@collabora.co.uk> Date: Wed, 11 May 2016 13:52:56 +0100 Subject: syscall_sysctl test: correctly skip if CONFIG_SYSCTL_SYSCALL=n This test attempts to auto-skip the sysctl() part if that syscall was not compiled into the current kernel, via CONFIG_SYSCTL_SYSCALL=n. Unfortunately, this didn't actually work, for two reasons: * Because "${test} ro" wasn't in "&&", "||", a pipeline or an "if", and it had nonzero exit status, the trap on ERR was triggered, causing execution of the error_handler() shell function, which aborts the test with a failed status. The rules for ERR are the same as for "set -e", so we can circumvent it in the same ways. * Because sysctl_syscall.c prints its diagnostic message to stderr, but the $() operator only captures stdout, it never matched in the string comparison. This is easily solved by redirecting its stderr to stdout. Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
This commit is contained in:
parent
90e5294578
commit
0f7ccc49bb
1 changed files with 1 additions and 2 deletions
|
@ -149,8 +149,7 @@ test_sysctl_proc()
|
|||
# generally we want to encourage kernels to disable it, but if it's
|
||||
# enabled we want to test against it
|
||||
settest syscall_sysctl
|
||||
res=$(${test} ro)
|
||||
if [ $? -ne 0 -a $res == "FAIL: sysctl read failed - Function not implemented" ] ; then
|
||||
if ! res="$(${test} ro 2>&1)" && [ "$res" = "FAIL: sysctl read failed - Function not implemented" ] ; then
|
||||
echo " WARNING: syscall sysctl not implemented, skipping tests ..."
|
||||
else
|
||||
test_syscall_sysctl
|
||||
|
|
Loading…
Add table
Reference in a new issue