Check test-cases for script-engine.
44{
45 string Line;
47 UINT64 ExpectedValue = 0;
49 string Expr = "";
50 std::vector<std::string> TestFiles;
51
52 try
53 {
55 }
56 catch (const std::exception &)
57 {
58 ShowMessages("err, test-cases not found, make sure to run test-environment.py "
59 "before running test cases\n");
61 }
62
63 for (auto item : TestFiles)
64 {
65
66
67
68 ifstream File(item.c_str());
69
70 if (File.is_open())
71 {
73
74
75
76
77 ShowMessages("Running from : %s\n\n", item.c_str());
78
79 while (std::getline(File, Line))
80 {
81
82
83
84 ShowMessages("Test-case number : %s\n", Line.c_str());
85
86
87
88
89 if (!std::getline(File, Line))
90 {
91 goto ErrorMessage;
92 }
93
94 Expr = Line;
95 ShowMessages("Statement : %s\n", Line.c_str());
96
97
98
99
100 if (!std::getline(File, Line))
101 {
102 goto ErrorMessage;
103 }
104
105 if (!Line.compare("$error$"))
106 {
107
108
109
110 ShowMessages("Expected result : %s\n", Line.c_str());
111
113 ExpectedValue =
NULL;
114 }
116 {
117 ShowMessages("err, the expected results are in incorrect format\n");
118 goto ErrorMessage;
119 }
120 else
121 {
122
123
124
126 ShowMessages("Expected result : %llx\n", ExpectedValue);
127 }
128
129
130
131
132 Expr.append(" ");
133
134
135
136
138 {
139 ShowMessages("Test result : Passed\n");
140 }
141 else
142 {
143 ShowMessages("Test result : Failed\n");
144 }
145
146
147
148
149 if (!std::getline(File, Line))
150 {
151 goto ErrorMessage;
152 }
153
154
155
156
157 if (Line.compare("$end$"))
158 {
159
160
161
162 goto ErrorMessage;
163 }
164
165 ShowMessages("\n------------------------------------------------------------\n\n");
166 }
167
168 File.close();
169 }
170 }
171
172 if (!IsOpened)
173 {
174 ShowMessages("err, could not find files for script engine test-cases\n");
176 }
177
179
180ErrorMessage:
181
182 ShowMessages("\nerr, testing failed! incorrect file format for the testing "
183 "script engine\nmake sure files have a correct ending format\n");
185}
#define SCRIPT_ENGINE_TEST_CASES_DIRECTORY
Test cases file name.
Definition Definition.h:100
std::vector< std::string > ListDirectory(const std::string &Directory, const std::string &Extension)
Create a list of special files in a directory.
Definition common.cpp:820
NULL()
Definition test-case-generator.py:530
BOOLEAN ScriptAutomaticStatementsTestWrapper(const string &Expr, UINT64 ExpectationValue, BOOLEAN ExceptError)
massive tests for script engine statements
Definition script-engine-wrapper.cpp:497