Files
libakerror/tests/err_ignore.c
Logikoma (Codex GPT-5) 4fe7571329
All checks were successful
libakerror CI Build / cmake_build (push) Successful in 2m52s
libakerror CI Build / coverage (push) Successful in 2m53s
libakerror CI Build / mutation_test (push) Successful in 44m12s
Release ignored error contexts
2026-08-03 13:46:00 -04:00

35 lines
914 B
C

#include "akerror.h"
#include "err_capture.h"
/* IGNORE logs and releases an error, then lets execution continue. */
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;
/* 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);
}
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;
}