/
AssertTorture.h
113 lines (108 loc) · 4.32 KB
/
AssertTorture.h
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
// See LICENSE for license details.
#include "bridges/synthesized_assertions.h"
#include "simif_peek_poke.h"
#include <vector>
class AssertTorture_t : public simif_peek_poke_t {
public:
std::vector<synthesized_assertions_t *> assert_endpoints;
AssertTorture_t(int argc, char **argv) {
std::vector<std::string> args(argv + 1, argv + argc);
#ifdef ASSERTBRIDGEMODULE_0_PRESENT
ASSERTBRIDGEMODULE_0_substruct_create assert_endpoints.push_back(
new synthesized_assertions_t(this,
args,
ASSERTBRIDGEMODULE_0_substruct,
ASSERTBRIDGEMODULE_0_assert_count,
ASSERTBRIDGEMODULE_0_assert_messages));
#endif
#ifdef ASSERTBRIDGEMODULE_1_PRESENT
ASSERTBRIDGEMODULE_1_substruct_create assert_endpoints.push_back(
new synthesized_assertions_t(this,
args,
ASSERTBRIDGEMODULE_1_substruct,
ASSERTBRIDGEMODULE_1_assert_count,
ASSERTBRIDGEMODULE_1_assert_messages));
#endif
#ifdef ASSERTBRIDGEMODULE_2_PRESENT
ASSERTBRIDGEMODULE_2_substruct_create assert_endpoints.push_back(
new synthesized_assertions_t(this,
args,
ASSERTBRIDGEMODULE_2_substruct,
ASSERTBRIDGEMODULE_2_assert_count,
ASSERTBRIDGEMODULE_2_assert_messages));
#endif
#ifdef ASSERTBRIDGEMODULE_3_PRESENT
ASSERTBRIDGEMODULE_3_substruct_create assert_endpoints.push_back(
new synthesized_assertions_t(this,
args,
ASSERTBRIDGEMODULE_3_substruct,
ASSERTBRIDGEMODULE_3_assert_count,
ASSERTBRIDGEMODULE_3_assert_messages));
#endif
#ifdef ASSERTBRIDGEMODULE_4_PRESENT
ASSERTBRIDGEMODULE_4_substruct_create assert_endpoints.push_back(
new synthesized_assertions_t(this,
args,
ASSERTBRIDGEMODULE_4_substruct,
ASSERTBRIDGEMODULE_4_assert_count,
ASSERTBRIDGEMODULE_4_assert_messages));
#endif
#ifdef ASSERTBRIDGEMODULE_5_PRESENT
ASSERTBRIDGEMODULE_5_substruct_create assert_endpoints.push_back(
new synthesized_assertions_t(this,
args,
ASSERTBRIDGEMODULE_5_substruct,
ASSERTBRIDGEMODULE_5_assert_count,
ASSERTBRIDGEMODULE_5_assert_messages));
#endif
#ifdef ASSERTBRIDGEMODULE_6_PRESENT
ASSERTBRIDGEMODULE_6_substruct_create assert_endpoints.push_back(
new synthesized_assertions_t(this,
args,
ASSERTBRIDGEMODULE_6_substruct,
ASSERTBRIDGEMODULE_6_assert_count,
ASSERTBRIDGEMODULE_6_assert_messages));
#endif
#ifdef ASSERTBRIDGEMODULE_7_PRESENT
ASSERTBRIDGEMODULE_7_substruct_create assert_endpoints.push_back(
new synthesized_assertions_t(this,
args,
ASSERTBRIDGEMODULE_7_substruct,
ASSERTBRIDGEMODULE_7_assert_count,
ASSERTBRIDGEMODULE_7_assert_messages));
#endif
};
void run() {
for (auto ep : assert_endpoints)
ep->init();
target_reset(2);
step(40000, false);
while (!done()) {
for (auto ep : assert_endpoints) {
ep->tick();
if (ep->terminate()) {
ep->resume();
}
}
}
};
};
class AssertGlobalResetCondition_t : public AssertTorture_t {
public:
AssertGlobalResetCondition_t(int argc, char **argv)
: AssertTorture_t(argc, argv){};
void run() {
for (auto ep : assert_endpoints)
ep->init();
target_reset(2);
step(40000, false);
while (!done()) {
for (auto ep : assert_endpoints) {
ep->tick();
if (ep->terminate()) {
abort();
}
}
}
};
};