-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgeneral_process.hh
144 lines (112 loc) · 4.17 KB
/
general_process.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#ifndef GENERAL_PROCESS_HH
#define GENERAL_PROCESS_HH
#include <string> // for string
#include <map> // for map
#include <memory> //for shared_ptr
#include <schema.hh> // for schema
#include <dut.hh> // for dut_base
#include <sys/stat.h> // for mkdir
#include <algorithm> // for sort
#include "config.h" // for PACKAGE_NAME
// for supported dbms ---
#ifdef HAVE_TIDB
#include "tidb.hh"
#endif
#ifdef HAVE_MYSQL
#include "mysql.hh"
#endif
#ifdef HAVE_MARIADB
#include "mariadb.hh"
#endif
// ---
#include "grammar.hh" // for statement gen
#include "dbms_info.hh" // for dbms_info
#include "transaction_test.hh" // for transaction
#include "instrumentor.hh" // for stmt_usage
extern "C" { //for sigusr1
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
}
using namespace std;
#define NORMAL_BUG_FILE "bug_trigger_stmt.sql"
#define GEN_STMT_FILE "gen_stmts.sql"
#define KILL_PROC_TIME_MS 10000
#define WAIT_FOR_PROC_TIME_MS 20000
#define RESET "\033[0m"
#define BLACK "\033[30m" /* Black */
#define RED "\033[31m" /* Red */
#define GREEN "\033[32m" /* Green */
#define YELLOW "\033[33m" /* Yellow */
#define BLUE "\033[34m" /* Blue */
#define MAGENTA "\033[35m" /* Magenta */
#define CYAN "\033[36m" /* Cyan */
#define WHITE "\033[37m" /* White */
#define BOLDBLACK "\033[1m\033[30m" /* Bold Black */
struct thread_data {
dbms_info* d_info;
vector<string>* trans_stmts;
vector<string>* exec_trans_stmts;
vector<vector<string>>* stmt_output;
int commit_or_not;
};
struct test_thread_arg {
dbms_info* d_info;
string* stmt;
vector<string>* stmt_output;
int* affected_row_num;
exception e;
bool has_exception;
};
void gen_stmts_for_one_txn(shared_ptr<schema> &db_schema,
int trans_stmt_num,
vector<shared_ptr<prod>>& trans_rec,
dbms_info& d_info);
bool compare_output(vector<vector<vector<string>>>& a_output,
vector<vector<vector<string>>>& b_output);
bool compare_content(map<string, vector<vector<string>>>&a_content,
map<string, vector<vector<string>>>&b_content);
pid_t fork_db_server(dbms_info& d_info);
shared_ptr<schema> get_schema(dbms_info& d_info);
shared_ptr<dut_base> dut_setup(dbms_info& d_info);
int save_backup_file(string path, dbms_info& d_info);
int use_backup_file(string backup_file, dbms_info& d_info);
void user_signal(int signal);
void dut_reset(dbms_info& d_info);
void dut_backup(dbms_info& d_info);
void dut_reset_to_backup(dbms_info& d_info);
void dut_get_content(dbms_info& d_info,
map<string, vector<vector<string>>>& content);
int generate_database(dbms_info& d_info);
void kill_process_with_SIGTERM(pid_t process_id);
bool reproduce_routine(dbms_info& d_info,
vector<shared_ptr<prod>>& stmt_queue,
vector<int>& tid_queue,
vector<stmt_usage> usage_queue,
string& err_info);
bool check_txn_cycle(dbms_info& d_info,
vector<shared_ptr<prod>>& stmt_queue,
vector<int>& tid_queue,
vector<stmt_usage>& usage_queue);
void txn_decycle_test(dbms_info& d_info,
vector<shared_ptr<prod>>& stmt_queue,
vector<int>& tid_queue,
vector<stmt_usage>& usage_queue,
int& succeed_time,
int& all_time,
vector<int> delete_nodes);
void check_topo_sort(dbms_info& d_info,
vector<shared_ptr<prod>>& stmt_queue,
vector<int>& tid_queue,
vector<stmt_usage>& usage_queue,
int& succeed_time,
int& all_time);
bool minimize_testcase(dbms_info& d_info,
vector<shared_ptr<prod>>& stmt_queue,
vector<int>& tid_queue,
vector<stmt_usage> usage_queue);
string print_stmt_to_string(shared_ptr<prod> stmt);
int make_dir_error_exit(string& folder);
extern pthread_mutex_t mutex_timeout;
extern pthread_cond_t cond_timeout;
#endif