Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
run_testmanager.cpp
Go to the documentation of this file.
1 /*
2  @file run_testmanager.cpp
3 
4  @brief
5 
6  @author Tatsumi Aoyama (aoym)
7  $LastChangedBy: aoyama $
8 
9  @date $LastChangedDate: 2013-04-12 13:28:01 #$
10 
11  @version $LastChangedRevision: 1929 $
12 */
13 
14 #include "testlist.h"
15 #include "testManager.h"
16 
17 //====================================================================
18 void testmanager_usage(const char *prog)
19 {
20  vout.general("\n");
21  vout.general("usage: %s\n", prog);
22  vout.general(" (without args) -- run tests interactively.\n");
23  vout.general(" test_names -- run specified tests.\n");
24  vout.general(" -a | --all -- run all tests.\n");
25  vout.general(" -l | --list -- list registered tests.\n");
26  vout.general(" -h | --help -- show this message.\n");
27  vout.general("\n");
28 }
29 
30 
31 //====================================================================
32 int run_testmanager(int argc, char **argv)
33 {
34  TestManager& testmanager = TestManager::Instance(); // find singleton
35 
36 #ifdef USE_TESTMANAGER_AUTOREGISTER
37  //- tests are registered automatically at start up.
38 #else
39  //- register tests manually:
40  //
41  // testmanager.registerTest(
42  // "Gauge.Plaquette",
43  // Test_Gauge::plaquette
44  // );
45 #endif
46 
47  if (argc > 1) {
48  const std::string arg1 = argv[1];
49 
50  if ((arg1 == "-a") || (arg1 == "--all")) { // run all tests
51  testmanager.batch_recursive();
52  } else if ((arg1 == "-l") || (arg1 == "--list")) { // list registered tests
53  testmanager.list();
54  } else if ((arg1 == "-h") || (arg1 == "--help")) { // show usage and exit
55  testmanager_usage(argv[0]);
56  return EXIT_SUCCESS;
57  } else {
58  // argv[] = { "./bridge.elf", test1, (test2, ...) }
59  testmanager.batch_recursive(argc - 1, argv + 1);
60  }
61  } else {
62  testmanager.interactive();
63  }
64 
65  return EXIT_SUCCESS;
66 }
67 
68 
69 //====================================================================
70 //====================================================================
void testmanager_usage(const char *prog)
TestManager class for managing and performing tests.
Definition: testManager.h:52
BridgeIO vout
Definition: bridgeIO.cpp:503
void general(const char *format,...)
Definition: bridgeIO.cpp:197
void batch_recursive(const std::string &arg="")
int run_testmanager(int argc, char **argv)
static TestManager & Instance()
Definition: testManager.cpp:41
void interactive()
Definition: testManager.cpp:85