t / helper / test-tool.con commit t/helper: merge test-drop-caches into test-tool (1c85474)
   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        { "date", cmd__date },
  14        { "delta", cmd__delta },
  15        { "drop-caches", cmd__drop_caches },
  16        { "lazy-init-name-hash", cmd__lazy_init_name_hash },
  17        { "sha1", cmd__sha1 },
  18};
  19
  20int cmd_main(int argc, const char **argv)
  21{
  22        int i;
  23
  24        if (argc < 2)
  25                die("I need a test name!");
  26
  27        for (i = 0; i < ARRAY_SIZE(cmds); i++) {
  28                if (!strcmp(cmds[i].name, argv[1])) {
  29                        argv++;
  30                        argc--;
  31                        return cmds[i].fn(argc, argv);
  32                }
  33        }
  34        die("There is no test named '%s'", argv[1]);
  35}