]> 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>
Tue, 20 May 2025 18:26:07 +0000 (20:26 +0200)
This can be used to stop execution after a TEST_COMPARE_BLOB
failure, for example.

(cherry picked from commit d0b8aa6de4529231fadfe604ac2c434e559c2d9e)

support/check.h
support/support_record_failure.c

index 0a9fff484f3c8299797639dfda0ed1687464e0e2..632fe5298a69aef7254cc03ff6ad9da63328d1d7 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 711f08801b0a8c575f917786f8d0ee878cc51d87..8466b895dcdb2e3bef01c2cebb402a1ad369a158 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);
+    }
+}