Bridge++  Ver. 1.3.x
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 #endif
43 
45 
64 {
65  public:
66  static const std::string class_name;
67 
68  public:
69  void interactive();
70  void batch(const std::string& arg);
71  void batch_recursive(const std::string& arg = "");
72  void batch_recursive(const int argc, char **argv);
73 
74  bool registerTest(const std::string& key, const Test_function func);
75 
76  void list();
77 
78  static TestManager& Instance();
79 
80  static bool RegisterTest(const std::string& key, const Test_function func)
81  { return Instance().registerTest(key, func); }
82 
83  // for test result verification
84  int getCheckPrecision() const
85  { return m_precision; }
86 
87  private:
88  // singleton
89  TestManager();
90 
91  TestManager(const TestManager&); // not implemented
92  TestManager& operator=(const TestManager&); // not implemented
93 
94  ~TestManager();
95 
96  static void CreateInstance();
97 
99 
100  // bi-directional tree representation of key
101  struct Node
102  {
104  std::vector<Node *> m_next;
105  std::string m_name; // key
107 
108  Node(const std::string& name, Node *const prev = 0)
109  : m_prev(prev), m_next(), m_name(name), m_function(DoNothing) {}
111  {
112  for (size_t i = 0; i < m_next.size(); ++i) { delete m_next[i]; }
113  }
114  };
115 
116  Node *find_node(Node *p, const std::vector<std::string>& v);
117  Node *append_key(Node *p, const std::vector<std::string>& v);
118  Node *append_key(Node *p, int argc, char **argv);
119 
120  // statistics
121  struct Stat
122  {
127  std::vector<std::string> m_list_failure;
128  std::vector<std::string> m_list_skip;
129 
130  void reset();
131  void success(const std::string& test_name);
132  void failure(const std::string& test_name);
133  void skip(const std::string& test_name);
134  };
135 
136  void stat_report() const;
137 
138  std::string find_fullpath(const Node *p, const std::string& path = "");
139 
140  void interactive_master();
141  void interactive_slave();
142 
143  void run(const Node *p);
144  void run_traversal(const Node *p);
145 
146  bool menu(const Node *p, const bool is_top = false);
147  void banner();
148 
149  void set_precision();
150 
151  void list_traverse(const Node *p, const std::string& prefix);
152 
153  // for debug
154  void traverse(const Node *p, const std::string& indent = "");
155 
156 
158 
160 
161  // for test result verification
163 
164  // for statistics report
166 };
167 #endif // TEST_MANAGER_H
TestManager class for managing and performing tests.
Definition: testManager.h:63
BridgeIO vout
Definition: bridgeIO.cpp:278
Node(const std::string &name, Node *const prev=0)
Definition: testManager.h:108
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 list_traverse(const Node *p, const std::string &prefix)
void stat_report() const
void skip(const std::string &test_name)
void interactive_master()
Definition: testManager.cpp:96
void traverse(const Node *p, const std::string &indent="")
std::string m_name
Definition: testManager.h:105
void run(const Node *p)
std::vector< std::string > m_list_skip
Definition: testManager.h:128
TestManager & operator=(const TestManager &)
Test_function m_function
Definition: testManager.h:106
Bridge::VerboseLevel m_vl
Definition: testManager.h:157
static bool RegisterTest(const std::string &key, const Test_function func)
Definition: testManager.h:80
int getCheckPrecision() const
Definition: testManager.h:84
std::vector< std::string > m_list_failure
Definition: testManager.h:127
Node m_root_node
Definition: testManager.h:159
static TestManager & Instance()
Definition: testManager.cpp:41
void interactive()
Definition: testManager.cpp:85
VerboseLevel
Definition: bridgeIO.h:39
static TestManager * s_instance
Definition: testManager.h:98
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:104
void banner()
Definition: testManager.cpp:30
static const std::string class_name
Definition: testManager.h:66
void set_precision()
int DoNothing()
Definition: testManager.cpp:23
int(* Test_function)(void)
Definition: testManager.h:33
Node * append_key(Node *p, const std::vector< std::string > &v)
void batch(const std::string &arg)