Preserve ignored error snapshots
Some checks failed
libakerror CI Build / coverage (push) Successful in 3m39s
libakerror CI Build / cmake_build (push) Successful in 6m3s
libakerror CI Build / mutation_test (push) Has been cancelled

This commit is contained in:
2026-08-04 10:44:46 -04:00
parent 4fe7571329
commit 55090d2419
5 changed files with 51 additions and 23 deletions

View File

@@ -1,7 +1,8 @@
#include "akerror.h"
#include "err_capture.h"
#include <string.h>
/* IGNORE logs and releases an error, then lets execution continue. */
/* IGNORE snapshots and logs an error, releases its pool slot, then continues. */
akerr_ErrorContext *boom(void)
{
@@ -18,10 +19,14 @@ int main(void)
(void)e;
/* More failures than the pool has slots must remain safe: a leaking
* IGNORE used to exhaust the pool and terminate the process here. */
* IGNORE used to exhaust the pool and terminate the process here. The
* copied snapshot must also survive the slot being reused on the next
* iteration. */
for ( int i = 0; i < AKERR_MAX_ARRAY_ERROR + 1; i++ ) {
IGNORE(boom());
AKERR_CHECK(__akerr_last_ignored == NULL);
AKERR_CHECK(__akerr_last_ignored.status == AKERR_VALUE);
AKERR_CHECK(strcmp(__akerr_last_ignored.message,
"this error is ignored on purpose") == 0);
AKERR_CHECK(akerr_slots_in_use() == 0);
}
reached_after_ignore = 1;