Skip to content

Commit dae0e52

Browse files
authored
Fix test skipping (#1118)
**Issue:** The SKIP code worked in `aws-crt-cpp`'s tests, but not in any `aws-c-*` tests **Description of changes:** - Set SKIP_RETURN_CODE in CMake script that generates C test runner (the CPP script had it, but not the C script) - Skip leak checks when a test is skipped - this keeps the tests simple, you can bail out in the middle without cleaning up
1 parent ce899b9 commit dae0e52

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

cmake/AwsTestHarness.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ function(generate_test_driver driver_exe_name)
5959

6060
foreach(name IN LISTS TEST_CASES)
6161
add_test(${name} ${driver_exe_name} "${name}")
62+
set_tests_properties("${name}" PROPERTIES SKIP_RETURN_CODE ${SKIP_RETURN_CODE_VALUE})
6263
endforeach()
6364

6465
# Clear test cases in case another driver needs to be generated

include/aws/testing/aws_test_harness.h

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,6 @@ static int s_cunit_failure_message0(
8383
* that may be returned from various tools (e.g. sanitizer). */
8484
#define SKIP (103)
8585

86-
#define POSTSKIP_INTERNAL() \
87-
do { \
88-
return SKIP; \
89-
} while (0)
90-
91-
#define RETURN_SKIP(format, ...) \
92-
do { \
93-
printf(format, ##__VA_ARGS__); \
94-
printf("\n"); \
95-
POSTSKIP_INTERNAL(); \
96-
} while (0)
97-
9886
#define RETURN_SUCCESS(format, ...) \
9987
do { \
10088
printf(format, ##__VA_ARGS__); \
@@ -468,7 +456,7 @@ static inline int s_aws_run_test_case(struct aws_test_harness *harness) {
468456
test_res |= harness->on_after(allocator, setup_res, harness->ctx);
469457
}
470458

471-
if (test_res != AWS_OP_SUCCESS && test_res != AWS_OP_SKIP) {
459+
if (test_res != AWS_OP_SUCCESS) {
472460
goto fail;
473461
}
474462

@@ -492,21 +480,21 @@ static inline int s_aws_run_test_case(struct aws_test_harness *harness) {
492480
aws_logger_set(NULL);
493481
aws_logger_clean_up(&err_logger);
494482

495-
if (test_res == AWS_OP_SUCCESS) {
496-
RETURN_SUCCESS("%s [ \033[32mOK\033[0m ]", harness->test_name);
497-
} else if (test_res == AWS_OP_SKIP) {
498-
RETURN_SKIP("%s [ \033[32mSKIP\033[0m ]", harness->test_name);
499-
}
483+
RETURN_SUCCESS("%s [ \033[32mOK\033[0m ]", harness->test_name);
500484

501485
fail:
502-
PRINT_FAIL_WITHOUT_LOCATION("%s [ \033[31mFAILED\033[0m ]", harness->test_name);
486+
if (test_res == AWS_OP_SKIP) {
487+
fprintf(AWS_TESTING_REPORT_FD, "%s [ \033[32mSKIP\033[0m ]\n", harness->test_name);
488+
} else {
489+
PRINT_FAIL_WITHOUT_LOCATION("%s [ \033[31mFAILED\033[0m ]", harness->test_name);
490+
}
503491
/* Use _Exit() to terminate without cleaning up resources.
504492
* This prevents LeakSanitizer spam (yes, we know failing tests don't bother cleaning up).
505493
* It also prevents errors where threads that haven't cleaned are still using the logger declared in this fn. */
506494
fflush(AWS_TESTING_REPORT_FD);
507495
fflush(stdout);
508496
fflush(stderr);
509-
_Exit(FAILURE);
497+
_Exit(test_res == AWS_OP_SKIP ? SKIP : FAILURE);
510498
}
511499

512500
/* Enables terminal escape sequences for text coloring on Windows. */

tests/thread_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static int s_test_managed_thread_join_timeout(struct aws_allocator *allocator, v
243243
/*
244244
* Increase the timeout and shut down
245245
*/
246-
aws_thread_set_managed_join_timeout_ns(aws_timestamp_convert(5, AWS_TIMESTAMP_SECS, AWS_TIMESTAMP_NANOS, NULL));
246+
aws_thread_set_managed_join_timeout_ns(aws_timestamp_convert(10, AWS_TIMESTAMP_SECS, AWS_TIMESTAMP_NANOS, NULL));
247247

248248
aws_common_library_clean_up();
249249

0 commit comments

Comments
 (0)