/** * \brief Run a test suite * * Run all tests in \a suite, in the order in which they are found in * the array. * * \return The number of tests that didn't pass. */ int test_suite_run(const struct test_suite *suite) { unsigned int nr_failures = 0; unsigned int nr_errors = 0; unsigned int i; int ret; dbg_info("Running test suite '%s'...\r\n", suite->name); for (i = 0; i < suite->nr_tests; i++) { const struct test_case *test; test = suite->tests[i]; ret = test_case_run(test); if (ret < TEST_PASS) { nr_errors++; } else if (ret > TEST_PASS) { nr_failures++; } } dbg_info("Test suite '%s' complete: %u tests, %u failures, %u errors\r\n\r\n", suite->name, suite->nr_tests, nr_failures, nr_errors); return nr_errors + nr_failures; }
int main(int ac, char **av) { int rc, i; /* simple "do we have ssl" check for run_tests.sh */ if (ac == 2 && !strncmp(av[1], "--ssl", 5)) { #ifdef HAVE_SSL return 0; #else return 1; #endif } #ifdef WIN32 win_init(); #endif for (i = 0; TestCases[i] != NULL; i++) { const struct test_case *current = TestCases[i]; const char *name = get_test_name(current); printf("%-48s", name); fflush(stdout); rc = test_case_run(current); if (rc) { printf(TEST_FAILED " (%s)\n", socket_strerror(-rc)); break; } printf(TEST_OK "\n"); } return rc; }
void workqueue_test(void) { if (test_case_register((test_case_t *)workqueue_case_runner) == 0) { test_case_run(); test_case_unregister(); } }
int main(int argc, char* argv[]) { int passed = -1; char* case_name; TestCase* hello = hello_test_case_create(0); passed = test_case_get_status(hello); test_case_get_name(hello, (const char**)&case_name); printf("name: %s, passed: %d\n", case_name, passed); test_case_run(hello); passed = test_case_get_status(hello); printf("name: %s, passed: %d\n", case_name, passed); test_case_destroy(hello); return 0; }
int main(int ac, char **av) { int rc, i; #ifdef WIN32 win_init(); #endif for (i = 0; TestCases[i] != NULL; i++) { const struct test_case *current = TestCases[i]; const char *name = get_test_name(current); printf("%-48s", name); fflush(stdout); rc = test_case_run(current); if (rc) { printf(TEST_FAILED " (%s)\n", socket_strerror(-rc)); break; } printf(TEST_OK "\n"); } return rc; }