Skip to content

Commit c31ab5b

Browse files
authored
Fix test count (#23)
1 parent 059783a commit c31ab5b

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

include/test/test.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class test
2121
vector<json> test_scenarios;
2222

2323
json read_json(string path);
24-
void traverse(emulation_devices *device, test_total_result *total_result, json test_target, json test_template, json testcase, string path);
24+
int traverse(emulation_devices *device, test_total_result *total_result, json test_target, json test_template, json testcase, string path);
2525
test_result do_test(string id, json test_target, json test_template, json testcase);
2626
void print_call_stack();
2727

src/test/test.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,12 @@ test::test(args_parser *_args)
5858
bool test::execute()
5959
{
6060
test_total_result total_result{args};
61-
int num_cases = 0;
61+
int num_tests = 0;
6262

6363
for (auto test_scenario : test_scenarios)
6464
{
65-
num_cases += test_scenario["cases"].size();
6665
device = new emulation_devices(args, test_scenario["config"], debug);
67-
traverse(
66+
num_tests += traverse(
6867
device,
6968
&total_result,
7069
test_scenario["target"],
@@ -73,7 +72,7 @@ bool test::execute()
7372
"");
7473
}
7574

76-
total_result.set_total(num_cases);
75+
total_result.set_total(num_tests);
7776

7877
debug->save_coverage();
7978

@@ -82,8 +81,10 @@ bool test::execute()
8281
return total_result.is_success();
8382
}
8483

85-
void test::traverse(emulation_devices *device, test_total_result *total_result, json test_target, json test_template, json test_case, string path)
84+
int test::traverse(emulation_devices *device, test_total_result *total_result, json test_target, json test_template, json test_case, string path)
8685
{
86+
int num_tests = 0;
87+
8788
for (auto &element : test_case.items())
8889
{
8990
auto id = element.key();
@@ -93,7 +94,7 @@ void test::traverse(emulation_devices *device, test_total_result *total_result,
9394

9495
if (test_id_path.ends_with("/"))
9596
{
96-
traverse(device, total_result, test_target, test_template, sub_test_case, test_id_path);
97+
num_tests += traverse(device, total_result, test_target, test_template, sub_test_case, test_id_path);
9798
continue;
9899
}
99100

@@ -103,7 +104,11 @@ void test::traverse(emulation_devices *device, test_total_result *total_result,
103104
total_result->add_and_print_result(
104105
device,
105106
do_test(test_id_path, test_target, test_template, sub_test_case));
107+
108+
num_tests++;
106109
}
110+
111+
return num_tests;
107112
}
108113

109114
test_result test::do_test(string id, json test_target, json test_template, json test_case)

0 commit comments

Comments
 (0)