From c497c96179bee07e3c0912d16ed366d4ba7b269e Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Tue, 5 Jan 2016 23:17:29 +0000 Subject: [PATCH] tests/seccomp.c: use libtests * tests/seccomp.c: Use SKIP_MAIN_UNDEFINED. (main): Use perror_msg_and_fail and perror_msg_and_skip. --- tests/seccomp.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/seccomp.c b/tests/seccomp.c index 54a5d057..f8d1370e 100644 --- a/tests/seccomp.c +++ b/tests/seccomp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Dmitry V. Levin + * Copyright (c) 2015-2016 Dmitry V. Levin * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -121,10 +121,13 @@ main(void) close(0); close(1); - if (pipe(fds) || - prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) || - prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog) || - close(0) || close(1)) + if (pipe(fds)) + perror_msg_and_fail("pipe"); + if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) + perror_msg_and_skip("PR_SET_NO_NEW_PRIVS"); + if (prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog)) + perror_msg_and_skip("PR_SET_SECCOMP"); + if (close(0) || close(1)) _exit(77); _exit(0); @@ -132,6 +135,8 @@ main(void) #else -int main(void) { return 77; } +SKIP_MAIN_UNDEFINED("HAVE_PRCTL && PR_SET_NO_NEW_PRIVS && PR_SET_SECCOMP" + " && SECCOMP_MODE_FILTER && SECCOMP_RET_ERRNO" + " && BPF_JUMP && BPF_STMT") #endif