Skip to content

Commit 53377a1

Browse files
niklarm0xc0170
authored andcommitted
Adapt Harness to call init and run functions.
1 parent df1d9f5 commit 53377a1

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

frameworks\utest/source/harness.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ static void die() {
8484

8585
bool Harness::set_scheduler(const utest_v1_scheduler_t scheduler)
8686
{
87-
if (!scheduler.post || !scheduler.cancel)
87+
if (!scheduler.init || !scheduler.post || !scheduler.cancel || !scheduler.run)
8888
return false;
8989

9090
::scheduler = scheduler;
9191
return true;
9292
}
9393

94-
bool Harness::run(const Specification& specification, std::size_t)
94+
bool Harness::run(const Specification& specification, size_t)
9595
{
9696
return run(specification);
9797
}
@@ -102,7 +102,10 @@ bool Harness::run(const Specification& specification)
102102
if (is_busy())
103103
return false;
104104

105-
if (!scheduler.post || !scheduler.cancel)
105+
if (!scheduler.init || !scheduler.post || !scheduler.cancel || !scheduler.run)
106+
return false;
107+
108+
if (scheduler.init() != 0)
106109
return false;
107110

108111
test_cases = specification.cases;
@@ -143,6 +146,14 @@ bool Harness::run(const Specification& specification)
143146
case_current = &test_cases[case_index];
144147

145148
scheduler.post(run_next_case, 0);
149+
if (scheduler.run() != 0) {
150+
failure.reason = REASON_SCHEDULER;
151+
if (handlers.test_failure) handlers.test_failure(failure);
152+
if (handlers.test_teardown) handlers.test_teardown(0, 0, failure);
153+
test_cases = NULL;
154+
exit(1);
155+
return true;
156+
}
146157
return true;
147158
}
148159

0 commit comments

Comments
 (0)