Rename newtestsuite to testsuite
[dyninst.git] / testsuite / src / dyninst / ParseThat.h
1 #ifndef __PARSE_THAT_H__
2 #define __PARSE_THAT_H__
3
4 #include <string>
5 #include <vector>
6 #include "test_lib.h"
7 //#include "dyninst_comp.h"
8 #include "util.h"
9 //  A (hopefully simple) c++ class interface for issuing parseThat commands
10 //  inside the testsuite
11
12 class ParseThat {
13         public:
14
15         typedef enum {
16                 T_None,
17                 T_Func,
18                 T_Mod,
19                 T_Proc
20         } InstTransaction;
21
22         typedef enum {
23                 PL_Module = 0,
24                 PL_Func = 1,
25                 PL_CFG = 2
26         } ParseLevel;
27
28         typedef enum {
29                 IL_None = 0,
30                 IL_FuncEntry = 1,
31                 IL_FuncExit = 2,
32                 IL_BasicBlock = 3,
33                 IL_MemRead = 4,
34                 IL_MemWrite = 5 
35         } InstLevel;
36
37         TESTLIB_DLL_EXPORT ParseThat();
38         TESTLIB_DLL_EXPORT ~ParseThat();
39
40         TESTLIB_DLL_EXPORT void pt_output_redirect(std::string fname) {pt_out_name = fname;}
41         TESTLIB_DLL_EXPORT void cmd_stdout_redirect(std::string fname) {cmd_stdout_name = fname;}
42         TESTLIB_DLL_EXPORT void cmd_stderr_redirect(std::string fname) {cmd_stderr_name = fname;}
43         TESTLIB_DLL_EXPORT void func_only(std::string fname) {limit_func = fname;}
44         TESTLIB_DLL_EXPORT void module_only(std::string mname) {limit_mod = mname;}
45         TESTLIB_DLL_EXPORT void set_transactions(InstTransaction t) {trans = t;}
46         TESTLIB_DLL_EXPORT void skip_functions_matching(std::string regex) {skip_funcs = regex;}
47         TESTLIB_DLL_EXPORT void skip_modules_matching(std::string regex) {skip_mods = regex;}
48         TESTLIB_DLL_EXPORT void suppress_ipc_messages() {suppress_ipc  = true;}
49         TESTLIB_DLL_EXPORT void set_verbosity(int v) {verbosity = v;}
50         TESTLIB_DLL_EXPORT void dont_fork() {nofork = true;}
51         TESTLIB_DLL_EXPORT void set_timeout(unsigned secs) {timeout_secs  = secs;}
52         TESTLIB_DLL_EXPORT void set_tracing() {do_trace = true;}
53         TESTLIB_DLL_EXPORT void set_tracesize(unsigned ntraces) {tracelength  = ntraces;}
54         TESTLIB_DLL_EXPORT void print_summary() {print_summary_ = true;}
55         TESTLIB_DLL_EXPORT void recursive() {do_recursive = true;}
56         TESTLIB_DLL_EXPORT void setParseLevel(ParseLevel pl) {parse_level = pl;}
57         TESTLIB_DLL_EXPORT void use_rewriter(std::string dest) {rewrite_filename = dest;}
58         TESTLIB_DLL_EXPORT void use_merge() {merge_tramps = true;}
59         TESTLIB_DLL_EXPORT void inst_level(InstLevel il) {inst_level_ = il;}
60         TESTLIB_DLL_EXPORT void include_libs() {include_libs_ = true;}
61
62         TESTLIB_DLL_EXPORT test_results_t operator()(std::string exec_path, 
63                         std::vector<std::string> &args);
64         TESTLIB_DLL_EXPORT test_results_t operator()(int pid);
65
66         private:
67         std::string pt_path;
68         std::string cmd_stdout_name;
69         std::string cmd_stderr_name;
70         std::string pt_out_name;
71         std::string rewrite_filename;
72         InstTransaction trans;
73         std::string skip_mods; // regex string
74         std::string skip_funcs; // regex string
75         std::string limit_mod;  // only use this module
76         std::string limit_func; // only use this func
77
78         bool suppress_ipc; //
79         bool nofork;
80         unsigned verbosity; // presently can be 0-7
81         unsigned int timeout_secs;
82         bool do_trace;
83         unsigned tracelength;
84         bool print_summary_;
85         ParseLevel parse_level;
86         bool do_recursive;
87         bool merge_tramps;
88         InstLevel inst_level_;
89         bool include_libs_;
90
91         bool setup_args(std::vector<std::string> &);
92         test_results_t pt_execute(std::vector<std::string> &);
93
94 };
95 #endif