summaryrefslogtreecommitdiff
path: root/t/helper/test-tool.c
blob: 81bafced8b0ddaf87d4f6f727561d9840aff91d5 (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
#include "git-compat-util.h"
#include "test-tool.h"
 
struct test_cmd {
	const char *name;
	int (*fn)(int argc, const char **argv);
};
 
static struct test_cmd cmds[] = {
	{ "chmtime", cmd__chmtime },
	{ "config", cmd__config },
	{ "ctype", cmd__ctype },
	{ "date", cmd__date },
	{ "delta", cmd__delta },
	{ "drop-caches", cmd__drop_caches },
	{ "dump-cache-tree", cmd__dump_cache_tree },
	{ "dump-split-index", cmd__dump_split_index },
	{ "example-decorate", cmd__example_decorate },
	{ "genrandom", cmd__genrandom },
	{ "hashmap", cmd__hashmap },
	{ "lazy-init-name-hash", cmd__lazy_init_name_hash },
	{ "sha1", cmd__sha1 },
};
 
int cmd_main(int argc, const char **argv)
{
	int i;
 
	if (argc < 2)
		die("I need a test name!");
 
	for (i = 0; i < ARRAY_SIZE(cmds); i++) {
		if (!strcmp(cmds[i].name, argv[1])) {
			argv++;
			argc--;
			return cmds[i].fn(argc, argv);
		}
	}
	die("There is no test named '%s'", argv[1]);
}