1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-24 05:53:49 +01:00

Merge pull request #20445 from benpicco/cpu/native-AUTO_EXIT

tests: exit `native` with error value on failure
This commit is contained in:
benpicco 2024-03-04 15:27:36 +00:00 committed by GitHub
commit 31d2300b8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 22 additions and 8 deletions

View File

@ -74,6 +74,17 @@ static void *main_trampoline(void *arg)
}
#endif
#ifdef CPU_NATIVE
extern unsigned _native_retval;
if (!_native_retval) {
_native_retval = res;
}
#endif
if (IS_ACTIVE(CONFIG_CORE_EXIT_WITH_MAIN)) {
pm_off();
}
return NULL;
}

View File

@ -184,8 +184,9 @@ void cpu_switch_context_exit(void)
{
#ifdef NATIVE_AUTO_EXIT
if (sched_num_threads <= 1) {
extern unsigned _native_retval;
DEBUG("cpu_switch_context_exit: last task has ended. exiting.\n");
real_exit(EXIT_SUCCESS);
real_exit(_native_retval);
}
#endif

View File

@ -99,7 +99,7 @@ void TestRunner_runTest(Test* test)
Test_run(test, &result_);
}
void TestRunner_end(void)
int TestRunner_end(void)
{
char buf[16];
if (result_.failureCount) {
@ -118,4 +118,6 @@ void TestRunner_end(void)
stdimpl_print(buf);
stdimpl_print(" tests)\n");
}
return TestRunnerHadErrors;
}

View File

@ -41,7 +41,7 @@ extern "C" {
void TestRunner_start(void);
void TestRunner_runTest(Test* test);
void TestRunner_end(void);
int TestRunner_end(void);
extern int TestRunnerHadErrors;

View File

@ -12,6 +12,9 @@ ifneq (,$(wildcard $(CURDIR)/tests*/.))
endif
endif
# terminate native when the test is complete
CFLAGS += -DNATIVE_AUTO_EXIT=1
BOARD ?= native
RIOTBASE ?= $(CURDIR)/../..
QUIET ?= 1

View File

@ -4,6 +4,4 @@ USEMODULE += posix_headers
USEMODULE += pthread
USEMODULE += xtimer
CFLAGS += -DNATIVE_AUTO_EXIT
include $(RIOTBASE)/Makefile.include

View File

@ -35,6 +35,7 @@ INCLUDES += -I$(RIOTBASE)/tests/unittests/common
# some tests need more stack
CFLAGS += -DTHREAD_STACKSIZE_MAIN=THREAD_STACKSIZE_LARGE
CFLAGS += -DCONFIG_CORE_EXIT_WITH_MAIN=1
# for these boards, enable asan (Address Sanitizer)
ASAN_BOARDS ?= native native64

View File

@ -49,7 +49,5 @@ int main(void)
#ifndef NO_TEST_SUITES
UNCURRY(RUN_TEST_SUITES, TEST_SUITES)
#endif
TESTS_END();
return 0;
return TESTS_END();
}