40 lines
1.1 KiB
C
40 lines
1.1 KiB
C
#include "akerror.h"
|
|
#include "err_capture.h"
|
|
#include <string.h>
|
|
|
|
/* IGNORE snapshots and logs an error, releases its pool slot, then continues. */
|
|
|
|
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. 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.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;
|
|
|
|
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;
|
|
}
|