Skip to content
Snippets Groups Projects
Commit 07b1dd55 authored by Martine Lenders's avatar Martine Lenders
Browse files

Merge pull request #1161 from Kijewski/unittests-exit-code

unittests: exit(1) or error
parents ba00bdb8 5e6bf869
No related branches found
No related tags found
No related merge requests found
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
static TestResult result_; static TestResult result_;
static Test* root_; static Test* root_;
int TestRunnerHadErrors;
static void TestRunner_startTest(TestListner* self,Test* test) static void TestRunner_startTest(TestListner* self,Test* test)
{ {
...@@ -73,6 +74,8 @@ static void TestRunner_addFailure(TestListner* self,Test* test,char* msg,int lin ...@@ -73,6 +74,8 @@ static void TestRunner_addFailure(TestListner* self,Test* test,char* msg,int lin
} }
stdimpl_print(msg); stdimpl_print(msg);
stdimpl_print("\n"); stdimpl_print("\n");
TestRunnerHadErrors = 1;
} }
static const TestListnerImplement TestRunnerImplement = { static const TestListnerImplement TestRunnerImplement = {
...@@ -107,6 +110,8 @@ void TestRunner_end(void) ...@@ -107,6 +110,8 @@ void TestRunner_end(void)
stdimpl_itoa(result_.failureCount, buf, 10); stdimpl_itoa(result_.failureCount, buf, 10);
stdimpl_print(buf); stdimpl_print(buf);
stdimpl_print("\n"); stdimpl_print("\n");
TestRunnerHadErrors = 1;
} else { } else {
stdimpl_print("\nOK ("); stdimpl_print("\nOK (");
stdimpl_itoa(result_.runCount, buf, 10); stdimpl_itoa(result_.runCount, buf, 10);
......
...@@ -43,6 +43,8 @@ void TestRunner_start(void); ...@@ -43,6 +43,8 @@ void TestRunner_start(void);
void TestRunner_runTest(Test* test); void TestRunner_runTest(Test* test);
void TestRunner_end(void); void TestRunner_end(void);
extern int TestRunnerHadErrors;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -58,6 +58,11 @@ int main(void) ...@@ -58,6 +58,11 @@ int main(void)
/* put test TEST_RUN() calls here */ /* put test TEST_RUN() calls here */
TESTS_END(); TESTS_END();
#if defined (BOARD_NATIVE) && !defined (OUTPUT)
void _exit(int);
_exit(TestRunnerHadErrors);
#endif
lpm_set(LPM_POWERDOWN); lpm_set(LPM_POWERDOWN);
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment