Skip to content

Commit ebd2233

Browse files
committed
syscalls/ptrace02: Add a pedantic check for return value
Make sure that -1 is returned on failure. Signed-off-by: Cyril Hrubis <[email protected]>
1 parent 55dc57e commit ebd2233

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

testcases/kernel/syscalls/ptrace/ptrace02.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,18 @@ static void verify_ptrace(void)
3030
if (!child_pid[1]) {
3131
SAFE_SETUID(uid);
3232
TEST(ptrace(PTRACE_ATTACH, child_pid[0], NULL, NULL));
33+
3334
if (TST_RET == 0) {
3435
tst_res(TFAIL, "ptrace() succeeded unexpectedly");
3536
exit(0);
3637
}
38+
39+
if (TST_RET != -1) {
40+
tst_res(TFAIL,
41+
"Invalid ptrace() return value %ld", TST_RET);
42+
exit(0);
43+
}
44+
3745
if (TST_ERR == EPERM)
3846
tst_res(TPASS | TTERRNO, "ptrace() failed as expected");
3947
else

0 commit comments

Comments
 (0)