Bridge++  Version 1.4.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 $Id: run_testmanager.cpp #$
3 
4  @brief
5 
6  @author Tatsumi Aoyama (aoym)
7  $LastChangedBy: aoym $
8 
9  @date $LastChangedDate: 2013-04-12 13:28:01 #$
10 
11  @version $LastChangedRevision: 1561 $
12 */
13 
14 #include "Tests/test.h"
15 #include "Tests/testlist.h"
16 #include "Tests/testManager.h"
17 
18 //====================================================================
19 void testmanager_usage(const char *prog)
20 {
21  vout.general("\n");
22  vout.general("usage: %s\n", prog);
23  vout.general(" (without args) -- run tests interactively.\n");
24  vout.general(" test_names -- run specified tests.\n");
25  vout.general(" -a | --all -- run all tests.\n");
26  vout.general(" -l | --list -- list registered tests.\n");
27  vout.general(" -h | --help -- show this message.\n");
28  vout.general("\n");
29 }
30 
31 
32 //====================================================================
33 int run_testmanager(int argc, char **argv)
34 {
35  TestManager& testmanager = TestManager::Instance(); // find singleton
36 
37 #ifdef USE_TESTMANAGER_AUTOREGISTER
38  //- tests are registered automatically at start up.
39 #else
40  //- register tests manually:
41  //
42  // testmanager.registerTest(
43  // "Gauge.Plaquette",
44  // Test_Gauge::plaquette
45  // );
46 #endif
47 
48  if (argc > 1) {
49  string arg1 = argv[1];
50 
51  if ((arg1 == "-a") || (arg1 == "--all")) { // run all tests
52  testmanager.batch_recursive();
53  } else if ((arg1 == "-l") || (arg1 == "--list")) { // list registered tests
54  testmanager.list();
55  } else if ((arg1 == "-h") || (arg1 == "--help")) { // show usage and exit
56  testmanager_usage(argv[0]);
57  return EXIT_SUCCESS;
58  } else {
59  // argv[] = { "./bridge.elf", test1, (test2, ...) }
60  testmanager.batch_recursive(argc - 1, argv + 1);
61  }
62  } else {
63  testmanager.interactive();
64  }
65 
66  return EXIT_SUCCESS;
67 }
68 
69 
70 //====================================================================
71 int preprocess_testmanager(int argc, char **argv)
72 {
73  if (argc > 1) {
74  std::string arg1 = argv[1];
75 
76  if ((arg1 == "-l") || (arg1 == "--list")) {
77  //- show list of registered tests and exit.
79  exit(EXIT_SUCCESS);
80  } else if ((arg1 == "-h") || (arg1 == "--help")) {
81  //- show usage and exit.
82  testmanager_usage(argv[0]);
83  exit(EXIT_SUCCESS);
84  }
85  }
86 
87  return EXIT_SUCCESS;
88 }
89 
90 
91 //====================================================================
92 //====================================================================
void testmanager_usage(const char *prog)
TestManager class for managing and performing tests.
Definition: testManager.h:52
BridgeIO vout
Definition: bridgeIO.cpp:495
void general(const char *format,...)
Definition: bridgeIO.cpp:195
void batch_recursive(const std::string &arg="")
int run_testmanager(int argc, char **argv)
int preprocess_testmanager(int argc, char **argv)
static TestManager & Instance()
Definition: testManager.cpp:41
void interactive()
Definition: testManager.cpp:85