Bridge++  Ver. 2.0.2
testManager.h
Go to the documentation of this file.
1 
14 #ifndef TESTMANAGER_INCLUDED
15 #define TESTMANAGER_INCLUDED
16 
17 #include <map>
18 
21 #include "test.h"
22 
23 #include "IO/bridgeIO.h"
24 using Bridge::vout;
25 
26 // typedef Functor<int> Test_function;
27 typedef int (*Test_function)(void);
28 
29 // null function
30 int DoNothing();
31 
32 
34 
53 {
54  public:
55  static const std::string class_name;
56 
57  public:
58  void interactive();
59  void batch(const std::string& arg);
60  void batch_recursive(const std::string& arg = "");
61  void batch_recursive(const int argc, char **argv);
62 
63  bool registerTest(const std::string& key, const Test_function func);
64 
65  void list();
66 
67  static TestManager& Instance();
68 
69  static bool RegisterTest(const std::string& key, const Test_function func)
70  { return Instance().registerTest(key, func); }
71 
72  // for test result verification
73  int getCheckPrecision() const
74  { return m_precision; }
75 
76  private:
77  // singleton
78  TestManager();
79 
80  TestManager(const TestManager&); // not implemented
81  TestManager& operator=(const TestManager&); // not implemented
82 
83  ~TestManager();
84 
85  static void CreateInstance();
86 
88 
89  // bi-directional tree representation of key
90  struct Node
91  {
93  std::vector<Node *> m_next;
94  std::string m_name; // key
96 
97  Node(const std::string& name, Node *const prev = 0)
98  : m_prev(prev), m_next(), m_name(name), m_function(DoNothing) {}
100  {
101  for (size_t i = 0; i < m_next.size(); ++i) { delete m_next[i]; }
102  }
103  };
104 
105  Node *find_node(Node *p, const std::vector<std::string>& v);
106  Node *append_key(Node *p, const std::vector<std::string>& v);
107  Node *append_key(Node *p, int argc, char **argv);
108 
109  // statistics
110  struct Stat
111  {
116  std::vector<std::string> m_list_failure;
117  std::vector<std::string> m_list_skip;
118 
119  void reset();
120  void success(const std::string& test_name);
121  void failure(const std::string& test_name);
122  void skip(const std::string& test_name);
123  };
124 
125  void stat_report() const;
126 
127  std::string find_fullpath(const Node *p, const std::string& path = "");
128 
129  void interactive_master();
130  void interactive_slave();
131 
132  void run(const Node *p);
133  void run_traversal(const Node *p);
134 
135  bool menu(const Node *p, const bool is_top = false);
136  void banner();
137 
138  void set_precision();
139 
140  void list_traverse(const Node *p, const std::string& prefix);
141 
142  // for debug
143  void traverse(const Node *p, const std::string& indent = "");
144 
145 
147 
149 
150  // for test result verification
152 
153  // for statistics report
155 };
156 #endif // TEST_MANAGER_H
TestManager::s_instance
static TestManager * s_instance
Definition: testManager.h:87
TestManager::stat_report
void stat_report() const
Definition: testManager.cpp:517
TestManager::Node::m_function
Test_function m_function
Definition: testManager.h:95
bridgeIO.h
Test_Eigensolver::test_name
const std::string test_name
Definition: test_Eigensolver.cpp:40
TestManager::m_root_node
Node m_root_node
Definition: testManager.h:148
TestManager::interactive
void interactive()
Definition: testManager.cpp:84
TestManager::Stat::reset
void reset()
Definition: testManager.cpp:479
TestManager::m_precision
int m_precision
Definition: testManager.h:151
TestManager::Instance
static TestManager & Instance()
Definition: testManager.cpp:40
TestManager::getCheckPrecision
int getCheckPrecision() const
Definition: testManager.h:73
TestManager::Node::m_prev
Node * m_prev
Definition: testManager.h:92
TestManager::Stat::m_num_success
int m_num_success
Definition: testManager.h:113
TestManager::~TestManager
~TestManager()
Definition: testManager.cpp:77
TestManager::m_stat
Stat m_stat
Definition: testManager.h:154
TestManager::registerTest
bool registerTest(const std::string &key, const Test_function func)
Definition: testManager.cpp:205
DoNothing
int DoNothing()
Definition: testManager.cpp:22
TestManager::Node
Definition: testManager.h:90
TestManager::menu
bool menu(const Node *p, const bool is_top=false)
Definition: testManager.cpp:259
TestManager::Node::m_next
std::vector< Node * > m_next
Definition: testManager.h:93
TestManager::Node::Node
Node(const std::string &name, Node *const prev=0)
Definition: testManager.h:97
TestManager::Stat::m_list_failure
std::vector< std::string > m_list_failure
Definition: testManager.h:116
TestManager::traverse
void traverse(const Node *p, const std::string &indent="")
Definition: testManager.cpp:588
TestManager::list
void list()
Definition: testManager.cpp:581
TestManager::run
void run(const Node *p)
Definition: testManager.cpp:213
TestManager::Stat::m_num_failure
int m_num_failure
Definition: testManager.h:114
TestManager::Stat::m_num_tests
int m_num_tests
Definition: testManager.h:112
TestManager::find_node
Node * find_node(Node *p, const std::vector< std::string > &v)
Definition: testManager.cpp:370
TestManager::batch
void batch(const std::string &arg)
Definition: testManager.cpp:126
test.h
TestManager::class_name
static const std::string class_name
Definition: testManager.h:55
Test_function
int(* Test_function)(void)
Definition: testManager.h:27
TestManager::CreateInstance
static void CreateInstance()
Definition: testManager.cpp:59
TestManager::run_traversal
void run_traversal(const Node *p)
Definition: testManager.cpp:244
TestManager::Node::m_name
std::string m_name
Definition: testManager.h:94
TestManager::find_fullpath
std::string find_fullpath(const Node *p, const std::string &path="")
Definition: testManager.cpp:464
TestManager::TestManager
TestManager()
Definition: testManager.cpp:68
TestManager::Stat::skip
void skip(const std::string &test_name)
Definition: testManager.cpp:508
TestManager::banner
void banner()
Definition: testManager.cpp:29
TestManager::Stat::m_list_skip
std::vector< std::string > m_list_skip
Definition: testManager.h:117
TestManager::m_vl
Bridge::VerboseLevel m_vl
Definition: testManager.h:146
TestManager::set_precision
void set_precision()
Definition: testManager.cpp:346
TestManager::Stat
Definition: testManager.h:110
TestManager::operator=
TestManager & operator=(const TestManager &)
TestManager::Stat::success
void success(const std::string &test_name)
Definition: testManager.cpp:491
TestManager::batch_recursive
void batch_recursive(const std::string &arg="")
Definition: testManager.cpp:139
TestManager::Stat::failure
void failure(const std::string &test_name)
Definition: testManager.cpp:499
TestManager::interactive_master
void interactive_master()
Definition: testManager.cpp:95
TestManager::append_key
Node * append_key(Node *p, const std::vector< std::string > &v)
Definition: testManager.cpp:396
TestManager::Node::~Node
~Node()
Definition: testManager.h:99
TestManager::interactive_slave
void interactive_slave()
Definition: testManager.cpp:108
commonParameters.h
TestManager::list_traverse
void list_traverse(const Node *p, const std::string &prefix)
Definition: testManager.cpp:552
communicator.h
TestManager
TestManager class for managing and performing tests.
Definition: testManager.h:52
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
TestManager::Stat::m_num_skip
int m_num_skip
Definition: testManager.h:115
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
TestManager::RegisterTest
static bool RegisterTest(const std::string &key, const Test_function func)
Definition: testManager.h:69