diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/README | 12 | ||||
| -rw-r--r-- | test/test.c | 47 |
2 files changed, 53 insertions, 6 deletions
diff --git a/test/README b/test/README index 186c570..43d6110 100644 --- a/test/README +++ b/test/README @@ -50,9 +50,13 @@ All objects need to be built with the same sanitizer and do not run valgrind whe Running: -./kpl_test [OPTIONS] # Run all tests -./kpl_test [OPTIONS] NAME # Run test named NAME -./kpl_test [OPTIONS] NAME1 NAME2 ... # Run selected tests named NAM1 NAME2 ... -./kpl_test -h # Show OPTIONS +./kpl_test # Run all tests +./kpl_test NAME # Run test named NAME +./kpl_test NAME1 NAME2 ... # Run selected tests named NAM1 NAME2 ... +./kpl_test -h # Show help + +--- + +Compiler Flags: --- diff --git a/test/test.c b/test/test.c index f12ee6e..afa8e26 100644 --- a/test/test.c +++ b/test/test.c @@ -1,6 +1,49 @@ #include "kpl_test.h" -int main(void) { - return 2; +static kpl_test *_kpl_test_head = NULL, *_kpl_test_tail = NULL, *_kpl_error_head = NULL, *_kpl_error_tail = NULL; + +void kpl_test_add(kpl_test *_test) { + if (_kpl_test_head) + _kpl_test_tail = _kpl_test_tail->next_test = _test; + else + _kpl_test_head = _kpl_test_tail = _test; +} + +static int32_t kpl_test_help(const char *argv0) { + printf("\nUsage: " KPL_COLOR(BOLD) "%s " KPL_COLOR(RESET) + KPL_COLOR(WHITE) "[OPTIONS] [TEST NAMES]\n\n" KPL_COLOR(RESET), argv0); + printf("Where " KPL_COLOR(WHITE) "[OPTIONS]" KPL_COLOR(RESET) " are:\n"); + printf(KPL_COLOR(LIGHT_YELLOW) "\t-h " KPL_COLOR(RESET) "Show Help\n"); + printf(KPL_COLOR(LIGHT_YELLOW) "\t-l " KPL_COLOR(RESET) "List Test Names\n"); + putchar('\n'); + return KPL_EXIT_CODE_HELP; +} + +static int32_t kpl_test_list(void) { + // TODO + return KPL_EXIT_CODE_HELP; +} + +static int32_t kpl_test_run(int32_t argc, char *argv[], const int32_t named_arg_position) { + // TODO RUN + return _kpl_error_tail ? KPL_EXIT_CODE_ERROR : KPL_EXIT_CODE_SUCCESS; +} + +int32_t main(int32_t argc, char *argv[]) { + int32_t arg_position = 1; + while (arg_position < argc) { + if (argv[arg_position][0] != '-' || !argv[arg_position][1] || argv[arg_position][2]) + break; + switch (argv[arg_position][1]) { + case 'h': + return kpl_test_help(argv[0]); + case 'l': + return kpl_test_list(); + default: + return kpl_test_run(argc, argv, arg_position); + } + arg_position++; + } + return kpl_test_run(argc, argv, arg_position); } |
