Skip the tests if the rseq syscall is unavailable
[librseq.git] / tests / basic_percpu_ops_test.c
index 7000ff505893bf987d6ac47ddfbfc7d69cf15a7b..e514ce6a6cae36280242013a6a8cbba5d18e0afb 100644 (file)
@@ -15,7 +15,7 @@
 
 #include "tap.h"
 
-#define NR_TESTS 2
+#define NR_TESTS 4
 
 #define ARRAY_SIZE(arr)        (sizeof(arr) / sizeof((arr)[0]))
 
@@ -303,23 +303,30 @@ int main(void)
 {
        plan_tests(NR_TESTS);
 
+       if (!rseq_available()) {
+               skip(NR_TESTS, "The rseq syscall is unavailable");
+               goto end;
+       }
+
        if (rseq_register_current_thread()) {
-               fprintf(stderr, "Error: rseq_register_current_thread(...) failed(%d): %s\n",
+               fail("rseq_register_current_thread(...) failed(%d): %s\n",
                        errno, strerror(errno));
-               goto error;
+               goto end;
+       } else {
+               pass("Registered current thread with rseq");
        }
 
        test_percpu_spinlock();
        test_percpu_list();
 
        if (rseq_unregister_current_thread()) {
-               fprintf(stderr, "Error: rseq_unregister_current_thread(...) failed(%d): %s\n",
+               fail("rseq_unregister_current_thread(...) failed(%d): %s\n",
                        errno, strerror(errno));
-               goto error;
+               goto end;
+       } else {
+               pass("Unregistered current thread with rseq");
        }
 
-       exit(EXIT_SUCCESS);
-
-error:
-       exit(EXIT_FAILURE);
+end:
+       exit(exit_status());
 }
This page took 0.02416 seconds and 4 git commands to generate.