52d30b80eb2b8688c2bfcde2577ab692c16402c3
[git/git.git] / t / helper / test-tool.c
1 #include "git-compat-util.h"
2 #include "test-tool.h"
3
4 struct test_cmd {
5 const char *name;
6 int (*fn)(int argc, const char **argv);
7 };
8
9 static struct test_cmd cmds[] = {
10 { "chmtime", cmd__chmtime },
11 { "config", cmd__config },
12 { "ctype", cmd__ctype },
13 { "date", cmd__date },
14 { "delta", cmd__delta },
15 { "lazy-init-name-hash", cmd__lazy_init_name_hash },
16 { "sha1", cmd__sha1 },
17 };
18
19 int cmd_main(int argc, const char **argv)
20 {
21 int i;
22
23 if (argc < 2)
24 die("I need a test name!");
25
26 for (i = 0; i < ARRAY_SIZE(cmds); i++) {
27 if (!strcmp(cmds[i].name, argv[1])) {
28 argv++;
29 argc--;
30 return cmds[i].fn(argc, argv);
31 }
32 }
33 die("There is no test named '%s'", argv[1]);
34 }