]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
support: Add support_record_failure_barrier
authorFlorian Weimer <fweimer@redhat.com>
Mon, 23 Dec 2024 12:57:55 +0000 (13:57 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 23 Dec 2024 12:57:55 +0000 (13:57 +0100)
This can be used to stop execution after a TEST_COMPARE_BLOB
failure, for example.

support/check.h
support/support_record_failure.c

index 7ea22c7a2cba5cfddc8dab5896ee306164b61e04..8f41e5b99fc17472a53d22eb134f81ad7b2dc70f 100644 (file)
@@ -207,6 +207,9 @@ void support_record_failure_reset (void);
    failures or not.  */
 int support_record_failure_is_failed (void);
 
+/* Terminate the process if any failures have been encountered so far.  */
+void support_record_failure_barrier (void);
+
 __END_DECLS
 
 #endif /* SUPPORT_CHECK_H */
index 978123701d128795a26b8fe5c930939d7e24fba4..72ee2b232fb2b08c7e71cf1de0ce5831fadf8d45 100644 (file)
@@ -112,3 +112,13 @@ support_record_failure_is_failed (void)
      synchronization for reliable test error reporting anyway.  */
   return __atomic_load_n (&state->failed, __ATOMIC_RELAXED);
 }
+
+void
+support_record_failure_barrier (void)
+{
+  if (__atomic_load_n (&state->failed, __ATOMIC_RELAXED))
+    {
+      puts ("error: exiting due to previous errors");
+      exit (1);
+    }
+}