Created
April 1, 2011 00:46
-
-
Save piscisaureus/897555 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int simple(); | |
int ping_pong_server(); | |
int ping_pong_client(); | |
TEST_LIST_START | |
TEST_ENTRY (simple) | |
TEST_ENTRY2 (pingpong, ping_pong_server) | |
TEST_ENTRY2 (pingpong, ping_pong_client) | |
TEST_LIST_END | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <stdio.h> | |
#ifdef _WIN32 | |
# include <windows.h> | |
#endif | |
typedef struct { | |
char *group_name; | |
char *process_name; | |
int (*main)(); | |
int ran; | |
} test_entry_t; | |
#define TEST_LIST_START \ | |
test_entry_t TESTS[] = { | |
#define TEST_LIST_END \ | |
{ 0, 0, 0, 0 } \ | |
}; | |
#define TEST_ENTRY(main) \ | |
{ "" # main, "" # main, &main, 0 }, | |
#define TEST_ENTRY2(name, main) \ | |
{ "" # name, "" # main, &main, 0 }, | |
#include "test-list.h" | |
int main(int argc, char **argv) { | |
int i; | |
test_entry_t *test, *testproc; | |
if (argc > 1) { | |
/* A specific test process was requested */ | |
for (test = (test_entry_t*)&TESTS; test->main; test++) { | |
if (strcmp(argv[1], test->process_name) == 0) | |
return test->main(); | |
} | |
fprintf(stderr, "Test process %s not found!\n", argv[1]); | |
return 255; | |
} else { | |
/* Run all tests */ | |
test = (test_entry_t*)&TESTS; | |
for (test = (test_entry_t*)&TESTS; test->main; test++) { | |
if (!test->ran) { | |
for (testproc = test; testproc->main; testproc++) { | |
start_process(testproc->process_name); | |
testproc->ran = 1; | |
} | |
process_waitall(); | |
} | |
} | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment