Merge branch 'nd/config-split'
[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 { "drop-caches", cmd__drop_caches },
16 { "dump-cache-tree", cmd__dump_cache_tree },
17 { "dump-split-index", cmd__dump_split_index },
18 { "example-decorate", cmd__example_decorate },
19 { "genrandom", cmd__genrandom },
20 { "hashmap", cmd__hashmap },
21 { "index-version", cmd__index_version },
22 { "json-writer", cmd__json_writer },
23 { "lazy-init-name-hash", cmd__lazy_init_name_hash },
24 { "match-trees", cmd__match_trees },
25 { "mergesort", cmd__mergesort },
26 { "mktemp", cmd__mktemp },
27 { "online-cpus", cmd__online_cpus },
28 { "path-utils", cmd__path_utils },
29 { "prio-queue", cmd__prio_queue },
30 { "reach", cmd__reach },
31 { "read-cache", cmd__read_cache },
32 { "read-midx", cmd__read_midx },
33 { "ref-store", cmd__ref_store },
34 { "regex", cmd__regex },
35 { "repository", cmd__repository },
36 { "revision-walking", cmd__revision_walking },
37 { "run-command", cmd__run_command },
38 { "scrap-cache-tree", cmd__scrap_cache_tree },
39 { "sha1-array", cmd__sha1_array },
40 { "sha1", cmd__sha1 },
41 { "sigchain", cmd__sigchain },
42 { "strcmp-offset", cmd__strcmp_offset },
43 { "string-list", cmd__string_list },
44 { "submodule-config", cmd__submodule_config },
45 { "subprocess", cmd__subprocess },
46 { "urlmatch-normalization", cmd__urlmatch_normalization },
47 { "wildmatch", cmd__wildmatch },
48 #ifdef GIT_WINDOWS_NATIVE
49 { "windows-named-pipe", cmd__windows_named_pipe },
50 #endif
51 { "write-cache", cmd__write_cache },
52 };
53
54 int cmd_main(int argc, const char **argv)
55 {
56 int i;
57
58 BUG_exit_code = 99;
59 if (argc < 2)
60 die("I need a test name!");
61
62 for (i = 0; i < ARRAY_SIZE(cmds); i++) {
63 if (!strcmp(cmds[i].name, argv[1])) {
64 argv++;
65 argc--;
66 return cmds[i].fn(argc, argv);
67 }
68 }
69 die("There is no test named '%s'", argv[1]);
70 }