Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test skipping #1118

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/AwsTestHarness.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function(generate_test_driver driver_exe_name)

foreach(name IN LISTS TEST_CASES)
add_test(${name} ${driver_exe_name} "${name}")
set_tests_properties("${name}" PROPERTIES SKIP_RETURN_CODE ${SKIP_RETURN_CODE_VALUE})
endforeach()

# Clear test cases in case another driver needs to be generated
Expand Down
28 changes: 8 additions & 20 deletions include/aws/testing/aws_test_harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,6 @@ static int s_cunit_failure_message0(
* that may be returned from various tools (e.g. sanitizer). */
#define SKIP (103)

#define POSTSKIP_INTERNAL() \
do { \
return SKIP; \
} while (0)

#define RETURN_SKIP(format, ...) \
do { \
printf(format, ##__VA_ARGS__); \
printf("\n"); \
POSTSKIP_INTERNAL(); \
} while (0)

#define RETURN_SUCCESS(format, ...) \
do { \
printf(format, ##__VA_ARGS__); \
Expand Down Expand Up @@ -468,7 +456,7 @@ static inline int s_aws_run_test_case(struct aws_test_harness *harness) {
test_res |= harness->on_after(allocator, setup_res, harness->ctx);
}

if (test_res != AWS_OP_SUCCESS && test_res != AWS_OP_SKIP) {
if (test_res != AWS_OP_SUCCESS) {
goto fail;
}

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

if (test_res == AWS_OP_SUCCESS) {
RETURN_SUCCESS("%s [ \033[32mOK\033[0m ]", harness->test_name);
} else if (test_res == AWS_OP_SKIP) {
RETURN_SKIP("%s [ \033[32mSKIP\033[0m ]", harness->test_name);
}
RETURN_SUCCESS("%s [ \033[32mOK\033[0m ]", harness->test_name);

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

/* Enables terminal escape sequences for text coloring on Windows. */
Expand Down
2 changes: 1 addition & 1 deletion tests/thread_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static int s_test_managed_thread_join_timeout(struct aws_allocator *allocator, v
/*
* Increase the timeout and shut down
*/
aws_thread_set_managed_join_timeout_ns(aws_timestamp_convert(5, AWS_TIMESTAMP_SECS, AWS_TIMESTAMP_NANOS, NULL));
aws_thread_set_managed_join_timeout_ns(aws_timestamp_convert(10, AWS_TIMESTAMP_SECS, AWS_TIMESTAMP_NANOS, NULL));

aws_common_library_clean_up();

Expand Down
Loading