|
| 1 | +From 4335cd9b58d1449abfba1bb5060970785940a399 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Florian Weimer < [email protected]> |
| 3 | +Date: Mon, 23 Dec 2024 13:57:55 +0100 |
| 4 | +Subject: [PATCH] support: Add support_record_failure_barrier |
| 5 | + |
| 6 | +This can be used to stop execution after a TEST_COMPARE_BLOB |
| 7 | +failure, for example. |
| 8 | + |
| 9 | +(cherry picked from commit d0b8aa6de4529231fadfe604ac2c434e559c2d9e) |
| 10 | +--- |
| 11 | + support/check.h | 3 +++ |
| 12 | + support/support_record_failure.c | 10 ++++++++++ |
| 13 | + 2 files changed, 13 insertions(+) |
| 14 | + |
| 15 | +diff --git a/support/check.h b/support/check.h |
| 16 | +index 0a9fff484f..632fe5298a 100644 |
| 17 | +--- a/support/check.h |
| 18 | ++++ b/support/check.h |
| 19 | +@@ -207,6 +207,9 @@ void support_record_failure_reset (void); |
| 20 | + failures or not. */ |
| 21 | + int support_record_failure_is_failed (void); |
| 22 | + |
| 23 | ++/* Terminate the process if any failures have been encountered so far. */ |
| 24 | ++void support_record_failure_barrier (void); |
| 25 | ++ |
| 26 | + __END_DECLS |
| 27 | + |
| 28 | + #endif /* SUPPORT_CHECK_H */ |
| 29 | +diff --git a/support/support_record_failure.c b/support/support_record_failure.c |
| 30 | +index 711f08801b..8466b895dc 100644 |
| 31 | +--- a/support/support_record_failure.c |
| 32 | ++++ b/support/support_record_failure.c |
| 33 | +@@ -112,3 +112,13 @@ support_record_failure_is_failed (void) |
| 34 | + synchronization for reliable test error reporting anyway. */ |
| 35 | + return __atomic_load_n (&state->failed, __ATOMIC_RELAXED); |
| 36 | + } |
| 37 | ++ |
| 38 | ++void |
| 39 | ++support_record_failure_barrier (void) |
| 40 | ++{ |
| 41 | ++ if (__atomic_load_n (&state->failed, __ATOMIC_RELAXED)) |
| 42 | ++ { |
| 43 | ++ puts ("error: exiting due to previous errors"); |
| 44 | ++ exit (1); |
| 45 | ++ } |
| 46 | ++} |
| 47 | +-- |
| 48 | +2.43.7 |
| 49 | + |
0 commit comments