2026-07-27 16:18:17 -04:00
|
|
|
#include "akerror.h"
|
|
|
|
|
#include "err_capture.h"
|
|
|
|
|
|
2026-08-03 12:55:42 -04:00
|
|
|
/* IGNORE logs and releases an error, then lets execution continue. */
|
2026-07-27 16:18:17 -04:00
|
|
|
|
|
|
|
|
akerr_ErrorContext *boom(void)
|
|
|
|
|
{
|
|
|
|
|
PREPARE_ERROR(e);
|
|
|
|
|
FAIL_RETURN(e, AKERR_VALUE, "this error is ignored on purpose");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
|
{
|
|
|
|
|
akerr_capture_install();
|
|
|
|
|
|
|
|
|
|
int reached_after_ignore = 0;
|
|
|
|
|
PREPARE_ERROR(e);
|
|
|
|
|
(void)e;
|
|
|
|
|
|
2026-08-03 12:55:42 -04:00
|
|
|
/* More failures than the pool has slots must remain safe: a leaking
|
|
|
|
|
* IGNORE used to exhaust the pool and terminate the process here. */
|
|
|
|
|
for ( int i = 0; i < AKERR_MAX_ARRAY_ERROR + 1; i++ ) {
|
|
|
|
|
IGNORE(boom());
|
|
|
|
|
AKERR_CHECK(__akerr_last_ignored == NULL);
|
|
|
|
|
AKERR_CHECK(akerr_slots_in_use() == 0);
|
|
|
|
|
}
|
2026-07-27 16:18:17 -04:00
|
|
|
reached_after_ignore = 1;
|
|
|
|
|
|
|
|
|
|
AKERR_CHECK(reached_after_ignore == 1);
|
|
|
|
|
AKERR_CHECK_CONTAINS("IGNORED ERROR");
|
|
|
|
|
AKERR_CHECK_CONTAINS("this error is ignored on purpose");
|
|
|
|
|
fprintf(stderr, "err_ignore ok\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|