1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00
RIOT/tests/unittests/main.c
René Kijewski 0246329050 unittests: separate test suites from main.c
This change removes the need to patch the main.c if you add or remove a
test suite. A test suite in `tests/unittests/tests-XXX` needs to export
the function `void tests_XXX(void)`, which gets called by `main()`.

The `tests-XXX/Makefile` looks like your average module:
```
MODULE = tests-XXX
include $(RIOTBASE)/Makefile.base
```
2014-05-14 12:57:52 +02:00

42 lines
861 B
C

/*
* Copyright (C) 2014 Martin Lenders
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License. See the file LICENSE in the top level directory for more
* details.
*/
#include "unittests.h"
#include "map.h"
#include "lpm.h"
#define UNCURRY(FUN, ARGS) FUN(ARGS)
#define RUN_TEST_SUITES(...) MAP(RUN_TEST_SUITE, __VA_ARGS__)
#define RUN_TEST_SUITE(TEST_SUITE) \
do { \
extern void tests_##TEST_SUITE(void); \
tests_##TEST_SUITE(); \
} while (0);
int main(void)
{
#ifdef OUTPUT
TextUIRunner_setOutputter(OUTPUTTER);
#endif
TESTS_START();
#ifndef NO_TEST_SUITES
UNCURRY(RUN_TEST_SUITES, TEST_SUITES)
#endif
TESTS_END();
#if defined (BOARD_NATIVE) && !defined (OUTPUT)
void _exit(int);
_exit(TestRunnerHadErrors);
#endif
lpm_set(LPM_POWERDOWN);
return 0;
}