Ejemplo n.º 1
0
int main(int argc, char **argv)
{
  unsigned i;
  char test_dir_buf[256];
  DskError *error = NULL;

  dsk_cmdline_init ("test table internals (the 'file' abstraction)",
                    "Test Table Internals",
                    NULL, 0);
  dsk_cmdline_add_boolean ("verbose", "extra logging", NULL, 0,
                           &cmdline_verbose);
  dsk_cmdline_add_boolean ("slow", "run tests that are fairly slow", NULL, 0,
                           &cmdline_slow);
  dsk_cmdline_add_boolean ("keep-testdir", "do not delete working directory", NULL, 0,
                           &cmdline_keep_testdir);
  dsk_cmdline_process_args (&argc, &argv);

  snprintf (test_dir_buf, sizeof (test_dir_buf),
            "test-table-file-%u-%u", (unsigned)time(NULL), (unsigned)getpid());
  location = dsk_dir_new (NULL, test_dir_buf, DSK_DIR_NEW_MAYBE_CREATE, &error);
  if (location == NULL)
    dsk_die ("error making directory: %s", error->message);

  for (i = 0; i < DSK_N_ELEMENTS (tests); i++)
    {
      fprintf (stderr, "Test: %s... ", tests[i].name);
      tests[i].test ();
      fprintf (stderr, " done.\n");
    }

  if (cmdline_keep_testdir)
    {
      fprintf (stderr,
               "test-table-file: keep-testdir: preserving test directory %s\n",
               dsk_dir_get_str (location));
    }
  else
    {
      DskError *error = NULL;
      if (!dsk_remove_dir_recursive (dsk_dir_get_str (location), &error))
        dsk_die ("error removing directory %s: %s",
                 dsk_dir_get_str (location), error->message);
    }
  dsk_cleanup ();
  return 0;
}
Ejemplo n.º 2
0
int main(int argc, char **argv)
{
  unsigned i;

  dsk_cmdline_init ("test HTTP-Header parsing",
                    "Test the HTTP-Header Parsing Code",
                    NULL, 0);
  dsk_cmdline_add_boolean ("verbose", "extra logging", NULL, 0,
                           &cmdline_verbose);
  dsk_cmdline_process_args (&argc, &argv);

  for (i = 0; i < DSK_N_ELEMENTS (tests); i++)
    {
      fprintf (stderr, "Test: %s... ", tests[i].name);
      tests[i].test ();
      fprintf (stderr, " done.\n");
    }
  dsk_cleanup ();
  return 0;
}