Skip to content

Commit 4223876

Browse files
lplewalukaszstolarczuk
authored andcommitted
[Tests] skip IPC test and example if improper ptrace value
We should definitely not change a sys file's value, within the test. We also shouldn't count and/or use sudoless password - just skip.
1 parent 3a6358b commit 4223876

File tree

4 files changed

+9
-27
lines changed

4 files changed

+9
-27
lines changed

examples/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ if(LINUX AND UMF_BUILD_LIBUMF_POOL_SCALABLE)
137137
COMMAND ${BASE_NAME}.sh
138138
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
139139

140-
set_tests_properties(${EXAMPLE_NAME} PROPERTIES LABELS "example")
140+
set_tests_properties(
141+
${EXAMPLE_NAME} PROPERTIES
142+
SKIP_RETURN_CODE 125
143+
LABELS "example")
141144
else()
142145
message(
143146
STATUS

examples/basic/ipc_shm_ipcapi.sh

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,8 @@ VAL=0
2020
if [ -f $PTRACE_SCOPE_FILE ]; then
2121
PTRACE_SCOPE_VAL=$(cat $PTRACE_SCOPE_FILE)
2222
if [ $PTRACE_SCOPE_VAL -ne $VAL ]; then
23-
# check if sudo requires password
24-
if ! timeout --kill-after=5s 3s sudo date; then
25-
echo "ERROR: sudo requires password - cannot set ptrace_scope to 0"
26-
exit 1
27-
fi
28-
echo "Setting ptrace_scope to 0 (classic ptrace permissions) ..."
29-
echo "$ sudo bash -c \"echo $VAL > $PTRACE_SCOPE_FILE\""
30-
sudo bash -c "echo $VAL > $PTRACE_SCOPE_FILE"
31-
fi
32-
PTRACE_SCOPE_VAL=$(cat $PTRACE_SCOPE_FILE)
33-
if [ $PTRACE_SCOPE_VAL -ne $VAL ]; then
34-
echo "SKIP: setting ptrace_scope to 0 (classic ptrace permissions) FAILED - skipping the test"
35-
exit 0
23+
echo "SKIP: ptrace_scope is not set to 0 (classic ptrace permissions) - skipping the test"
24+
exit 125 # skip code defined in CMakeLists.txt
3625
fi
3726
fi
3827

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ if(LINUX)
257257
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
258258

259259
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "umf")
260+
set_tests_properties(${TEST_NAME} PROPERTIES SKIP_RETURN_CODE 125)
260261
else()
261262
message(
262263
STATUS "IPC shared memory test is supported on Linux only - skipping")

test/ipc_os_prov.sh

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,8 @@ VAL=0
2020
if [ -f $PTRACE_SCOPE_FILE ]; then
2121
PTRACE_SCOPE_VAL=$(cat $PTRACE_SCOPE_FILE)
2222
if [ $PTRACE_SCOPE_VAL -ne $VAL ]; then
23-
# check if sudo requires password
24-
if ! timeout --kill-after=5s 3s sudo date; then
25-
echo "ERROR: sudo requires password - cannot set ptrace_scope to 0"
26-
exit 1
27-
fi
28-
echo "Setting ptrace_scope to 0 (classic ptrace permissions) ..."
29-
echo "$ sudo bash -c \"echo $VAL > $PTRACE_SCOPE_FILE\""
30-
sudo bash -c "echo $VAL > $PTRACE_SCOPE_FILE"
31-
fi
32-
PTRACE_SCOPE_VAL=$(cat $PTRACE_SCOPE_FILE)
33-
if [ $PTRACE_SCOPE_VAL -ne $VAL ]; then
34-
echo "SKIP: setting ptrace_scope to 0 (classic ptrace permissions) FAILED - skipping the test"
35-
exit 0
23+
echo "SKIP: ptrace_scope is not set to 0 (classic ptrace permissions) - skipping the test"
24+
exit 125 # skip code defined in CMakeLists.txt
3625
fi
3726
fi
3827

0 commit comments

Comments
 (0)