blob: afa8e26e8745c7f5340a1f91285ae0914649dc83 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include "kpl_test.h"
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);
}
|