@@ -311,9 +311,9 @@ static int total_failures;
311
311
} \
312
312
} while (0)
313
313
314
- typedef void (aws_test_before_fn )(struct aws_allocator * allocator , void * ctx );
314
+ typedef int (aws_test_before_fn )(struct aws_allocator * allocator , void * ctx );
315
315
typedef int (aws_test_run_fn )(struct aws_allocator * allocator , void * ctx );
316
- typedef void (aws_test_after_fn )(struct aws_allocator * allocator , void * ctx );
316
+ typedef int (aws_test_after_fn )(struct aws_allocator * allocator , int setup_result , void * ctx );
317
317
318
318
struct aws_test_harness {
319
319
aws_test_before_fn * on_before ;
@@ -378,17 +378,21 @@ static inline int s_aws_run_test_case(struct aws_test_harness *harness) {
378
378
aws_logger_init_standard (& err_logger , aws_default_allocator (), & options );
379
379
aws_logger_set (& err_logger );
380
380
381
+ int test_res = AWS_OP_ERR ;
382
+ int setup_res = AWS_OP_SUCCESS ;
381
383
if (harness -> on_before ) {
382
- harness -> on_before (allocator , harness -> ctx );
384
+ setup_res = harness -> on_before (allocator , harness -> ctx );
383
385
}
384
386
385
- int ret_val = harness -> run (allocator , harness -> ctx );
387
+ if (!setup_res ) {
388
+ test_res = harness -> run (allocator , harness -> ctx );
389
+ }
386
390
387
391
if (harness -> on_after ) {
388
- harness -> on_after (allocator , harness -> ctx );
392
+ test_res |= harness -> on_after (allocator , setup_res , harness -> ctx );
389
393
}
390
394
391
- if (!ret_val ) {
395
+ if (!test_res ) {
392
396
if (!harness -> suppress_memcheck ) {
393
397
const size_t leaked_bytes = aws_mem_tracer_count (allocator );
394
398
if (leaked_bytes ) {
@@ -405,7 +409,7 @@ static inline int s_aws_run_test_case(struct aws_test_harness *harness) {
405
409
aws_logger_set (NULL );
406
410
aws_logger_clean_up (& err_logger );
407
411
408
- if (!ret_val ) {
412
+ if (!test_res ) {
409
413
RETURN_SUCCESS ("%s [ \033[32mOK\033[0m ]" , harness -> test_name );
410
414
} else {
411
415
FAIL ("%s [ \033[31mFAILED\033[0m ]" , harness -> test_name );
@@ -464,9 +468,9 @@ static inline int enable_vt_mode(void) {
464
468
}
465
469
466
470
#define AWS_TEST_CASE_FIXTURE_SUPPRESSION (name , b , fn , af , c , s ) \
467
- static void b(struct aws_allocator *allocator, void *ctx); \
471
+ static int b(struct aws_allocator *allocator, void *ctx); \
468
472
static int fn(struct aws_allocator *allocator, void *ctx); \
469
- static void af(struct aws_allocator *allocator, void *ctx); \
473
+ static int af(struct aws_allocator *allocator, int setup_result, void *ctx); \
470
474
static struct aws_test_harness name##_test = { \
471
475
b, \
472
476
fn, \
0 commit comments