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