]> granicus.if.org Git - strace/commitdiff
tests/prctl-seccomp-strict.c: cleanup
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 21 Apr 2016 21:13:20 +0000 (21:13 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 21 Apr 2016 22:05:55 +0000 (22:05 +0000)
* tests/prctl-seccomp-strict.c (main): Use errno2name,
stop using assert.

tests/prctl-seccomp-strict.c

index 8d1fdfc9f5da55f7b4ad6f063be8abce704574fd..1944745076a3f96a4b6c8312e3b5234e358a3361 100644 (file)
@@ -44,23 +44,24 @@ main(void)
        static const char text1[] =
                "prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT) = 0\n";
        static const char text2[] = "+++ exited with 0 +++\n";
-       int rc = 0;
 
-       assert(prctl(PR_SET_SECCOMP, -1L, 1, 2, 3) == -1);
+       int rc = prctl(PR_SET_SECCOMP, -1L, 1, 2, 3);
        printf("prctl(PR_SET_SECCOMP, %#x /* SECCOMP_MODE_??? */, 0x1, 0x2, 0x3)"
-              " = -1 %s (%m)\n", -1, ENOSYS == errno ? "ENOSYS" : "EINVAL");
+              " = %d %s (%m)\n", -1, rc, errno2name());
        fflush(stdout);
 
-       if (prctl(PR_SET_SECCOMP, 1)) {
-               printf("prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT) = -1 %s (%m)\n",
-                      ENOSYS == errno ? "ENOSYS" : "EINVAL");
+       rc = prctl(PR_SET_SECCOMP, 1);
+       if (rc) {
+               printf("prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT)"
+                      " = %d %s (%m)\n", rc, errno2name());
                fflush(stdout);
+               rc = 0;
        } else {
                /*
                 * If kernel implementaton of SECCOMP_MODE_STRICT is buggy,
                 * the following syscall will result to SIGKILL.
                 */
-               rc += write(1, text1, LENGTH_OF(text1)) != LENGTH_OF(text1);
+               rc = write(1, text1, LENGTH_OF(text1)) != LENGTH_OF(text1);
        }
 
        rc += write(1, text2, LENGTH_OF(text2)) != LENGTH_OF(text2);