Plan 9 from Bell Labs’s /usr/web/sources/contrib/de0u/root/sys/src/cmd/divergefs/tests/testmain.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <u.h>
#include <libc.h>
#include "common.h"
#include "debug.h"
#include "unittest.h"
#include "testmain.h"

#define DEBUG_TESTMAIN false

typedef AbstractTest *(*testsuitefactory)(void);

static testsuitefactory testsuite_factories[] =
{
  testarray_testsuite,
  testconfig_testsuite,
  testfilepath_testsuite,
  testfile_testsuite,
  testset_testsuite,
  testdictionary_testsuite
};

static TestSuite *load_testsuites(void)
{
  int i;
  TestSuite *result = testsuite_new("testmain");

  NOISE(DEBUG_TESTMAIN, "about to populate testsuites");
  for(i = 0; i < static_array_length(testsuite_factories); ++i)
  {
    testsuite_add(result, testsuite_factories[i]());
  }
  return result;
}

static void usage(void)
{
  debug_print("Usage", "tests [-d debuglevel]");
  exits("usage");
}

static void parse_options(int argc, char **argv)
{
  ARGBEGIN
  {
    case 'd':
      debug_set_level(atoi(EARGF(usage())));
      break;
    default:
      usage();
  }
  ARGEND
}

void main(int argc, char **argv)
{
  TestResult result;
  TestSuite *suite;

  debug_init();
  debug_set_level(4);
  parse_options(argc, argv);

  testresult_init(&result);
  suite = load_testsuites();

  NOISE(DEBUG_TESTMAIN, "about to run testsuite");
  abstracttest_run(suite, &result);
  
  NOISE(DEBUG_TESTMAIN, "about to free testsuite");
  abstracttest_free(suite);

  testresult_report(&result);
  exits(nil);
}



Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.