Bridge++  Ver. 1.2.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
testManager.h
Go to the documentation of this file.
1 
14 #ifndef TESTMANAGER_INCLUDED
15 #define TESTMANAGER_INCLUDED
16 
17 #include <iostream>
18 #include <fstream>
19 #include <cmath>
20 #include <string>
21 #include <vector>
22 #include <map>
23 
24 #include "defs.h"
25 #include "communicator.h"
26 #include "commonParameters.h"
27 #include "test.h"
28 
29 #include "bridgeIO.h"
30 using Bridge::vout;
31 
32 // typedef Functor<int> Test_function;
33 typedef int (*Test_function)(void);
34 
35 // null function
36 int DoNothing();
37 
38 #if 0
39 // debug
40 void hook_preexec();
41 void hook_postexec();
42 
43 #endif
44 
46 
65 {
66  public:
67  static const std::string class_name;
68 
69  public:
70  void interactive();
71  void batch(const std::string& arg);
72  void batch_recursive(const std::string& arg = "");
73  void batch_recursive(const int argc, char **argv);
74 
75  bool registerTest(const std::string& key, const Test_function func);
76 
77  static TestManager& Instance();
78 
79  static bool RegisterTest(const std::string& key, const Test_function func)
80  { return Instance().registerTest(key, func); }
81 
82  // for test result verification
83  int getCheckPrecision() const
84  { return m_precision; }
85 
86  private:
87  // singleton
88  TestManager();
89 
90  TestManager(const TestManager&); // not implemented
91  TestManager& operator=(const TestManager&); // not implemented
92 
93  ~TestManager();
94 
95  static void CreateInstance();
96 
98 
99  // bi-directional tree representation of key
100  struct Node
101  {
103  std::vector<Node *> m_next;
104  std::string m_name; // key
106 
107  Node(const std::string& name, Node *const prev = 0)
108  : m_prev(prev), m_next(), m_name(name), m_function(DoNothing) {}
110  {
111  for (size_t i = 0; i < m_next.size(); ++i) { delete m_next[i]; }
112  }
113  };
114 
115  Node *find_node(Node *p, const std::vector<std::string>& v);
116  Node *append_key(Node *p, const std::vector<std::string>& v);
117  Node *append_key(Node *p, int argc, char **argv);
118 
119  // statistics
120  struct Stat
121  {
126  std::vector<std::string> m_list_failure;
127  std::vector<std::string> m_list_skip;
128 
129  void reset();
130  void success(const std::string& test_name);
131  void failure(const std::string& test_name);
132  void skip(const std::string& test_name);
133  };
134 
135  void stat_report() const;
136 
137  std::string find_fullpath(const Node *p, const std::string& path = "");
138 
139  void interactive_master();
140  void interactive_slave();
141 
142  void run(const Node *p);
143  void run_traversal(const Node *p);
144 
145  bool menu(const Node *p, const bool is_top = false);
146  void banner();
147 
148  void set_precision();
149 
150  // for debug
151  void traverse(const Node *p, const std::string& indent = "");
152 
153 
155 
157 
158  // for test result verification
160 
161  // for statistics report
163 };
164 #endif // TEST_MANAGER_H
TestManager class for managing and performing tests.
Definition: testManager.h:64
BridgeIO vout
Definition: bridgeIO.cpp:207
int DoNothing()
Definition: testManager.cpp:23
Node(const std::string &name, Node *const prev=0)
Definition: testManager.h:107
bool menu(const Node *p, const bool is_top=false)
void success(const std::string &test_name)
const std::string test_name
static void CreateInstance()
Definition: testManager.cpp:60
void run_traversal(const Node *p)
void failure(const std::string &test_name)
void batch_recursive(const std::string &arg="")
void interactive_slave()
std::string find_fullpath(const Node *p, const std::string &path="")
void stat_report() const
void skip(const std::string &test_name)
int(* Test_function)(void)
Definition: testManager.h:33
void interactive_master()
Definition: testManager.cpp:96
void traverse(const Node *p, const std::string &indent="")
std::string m_name
Definition: testManager.h:104
void run(const Node *p)
std::vector< std::string > m_list_skip
Definition: testManager.h:127
TestManager & operator=(const TestManager &)
Test_function m_function
Definition: testManager.h:105
Bridge::VerboseLevel m_vl
Definition: testManager.h:154
static bool RegisterTest(const std::string &key, const Test_function func)
Definition: testManager.h:79
int getCheckPrecision() const
Definition: testManager.h:83
std::vector< std::string > m_list_failure
Definition: testManager.h:126
Node m_root_node
Definition: testManager.h:156
static TestManager & Instance()
Definition: testManager.cpp:41
void interactive()
Definition: testManager.cpp:85
VerboseLevel
Definition: bridgeIO.h:25
static TestManager * s_instance
Definition: testManager.h:97
Node * find_node(Node *p, const std::vector< std::string > &v)
bool registerTest(const std::string &key, const Test_function func)
std::vector< Node * > m_next
Definition: testManager.h:103
void banner()
Definition: testManager.cpp:30
static const std::string class_name
Definition: testManager.h:67
void set_precision()
Node * append_key(Node *p, const std::vector< std::string > &v)
void batch(const std::string &arg)