c23550291d714690e1f85e20727d456788ef3547
   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        { "lazy-init-name-hash", cmd__lazy_init_name_hash },
  13        { "sha1", cmd__sha1 },
  14};
  15
  16int cmd_main(int argc, const char **argv)
  17{
  18        int i;
  19
  20        if (argc < 2)
  21                die("I need a test name!");
  22
  23        for (i = 0; i < ARRAY_SIZE(cmds); i++) {
  24                if (!strcmp(cmds[i].name, argv[1])) {
  25                        argv++;
  26                        argc--;
  27                        return cmds[i].fn(argc, argv);
  28                }
  29        }
  30        die("There is no test named '%s'", argv[1]);
  31}