]> 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 19:43:13 +0000 (21:43 +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 af5b513cadb6cd8992a1c848fe7b03b3b3a71000..2026118fc0eea82443d73844b60386298d7c8bab 100644 (file)
@@ -192,6 +192,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 903da401555fc83a4028c3b20df85664f0b90d5a..c0bd489637990b705ef7fa25e4b13d2a2ace926c 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);
+    }
+}