Skip to content

Commit

Permalink
Add function to report overall number of passed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pokechu22 committed Apr 17, 2022
1 parent 3e6b1b1 commit af5a13c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions common/hwtests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ struct TestStatus

static TestStatus status(NULL, 0);
static int number_of_tests = 0;
static long long number_of_subtests;
static int number_of_tests_passed = 0;
static long long number_of_subtests_passed;

int client_socket;
int server_socket;
Expand Down Expand Up @@ -69,12 +72,23 @@ void privEndTest()
if (0 == status.num_failures)
{
network_printf("Test %d passed (%lld subtests)\n", number_of_tests, status.num_subtests);
number_of_tests_passed++;
}
else
{
network_printf("Test %d failed (%lld subtests, %lld failures)\n", number_of_tests,
status.num_subtests, status.num_failures);
}
number_of_subtests += status.num_subtests;
number_of_subtests_passed += status.num_passes;
}

void report_test_results()
{
network_printf("%d tests passed out of %d; %lld subtests passed out of %lld\n",
number_of_tests_passed, number_of_tests, number_of_subtests_passed, number_of_subtests);
if (number_of_tests_passed == number_of_tests)
network_printf("All tests passed\n");
}

#define SERVER_PORT 16784
Expand Down
2 changes: 2 additions & 0 deletions common/hwtests.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ void privDoTest(bool condition, const char* file, int line, fmt::format_string<A
}
void privEndTest();

void report_test_results();

void network_init();
void network_shutdown();
void network_vprintf(const char* str, va_list args);
Expand Down

0 comments on commit af5a13c

Please sign in to comment.