1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests/cpp_ctors/main.c
Francisco Molina 416c048737 tests: add test_utils_interactive_sync when possible
- Define test_utils_interactive_sync as DEFAULT_MODULE in Makefile.tests_common
- For tests disabling autoinit, add test_utils_interactive_sync to main
- Add DISABLE_MODULE += test_utils_interactive_sync for tests requiring
  sudo,  `tests/shell`, `tests/minimal` and `tests/stdin`
- Add shell_commands to tests/periph_wdt and tests/struct_tm_utility to
  pull `r` and `s` commands
- Remove includes and usage in `tests/main.c` for tests that where
  already using test_utils_interactive_sync
2019-11-27 15:07:42 +01:00

69 lines
1.8 KiB
C

/*
* Copyright (C) 2016-2017 Eistec AB
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
#include "embUnit.h"
#include "tests-cpp_ctors.h"
#include "thread.h" /* For thread_getpid() */
#include "test_utils/interactive_sync.h"
long tests_cpp_ctors_global_value(void);
long tests_cpp_ctors_static_value(void);
long tests_cpp_ctors_local_value(long number);
extern volatile long tests_cpp_ctors_magic1;
extern volatile long tests_cpp_ctors_magic2;
extern void *tests_cpp_ctors_order[8];
static void tests_cpp_global_ctors(void)
{
long expected = tests_cpp_ctors_magic1;
long actual = tests_cpp_ctors_global_value();
/* Test to ensure that global constructors have executed */
TEST_ASSERT_EQUAL_INT(expected, actual);
}
static void tests_cpp_static_ctors(void)
{
for (long i = 1; i < 10; ++i) {
long expected = tests_cpp_ctors_magic2 + i;
long actual = tests_cpp_ctors_static_value();
TEST_ASSERT_EQUAL_INT(expected, actual);
}
}
static void tests_cpp_local_ctors(void)
{
/* Test to ensure that local constructors are executed properly */
long expected = thread_getpid() + 1;
long actual = tests_cpp_ctors_local_value(thread_getpid());
TEST_ASSERT_EQUAL_INT(expected, actual);
}
Test *tests_cpp_ctors_tests(void)
{
EMB_UNIT_TESTFIXTURES(fixtures) {
new_TestFixture(tests_cpp_local_ctors),
new_TestFixture(tests_cpp_global_ctors),
new_TestFixture(tests_cpp_static_ctors),
};
EMB_UNIT_TESTCALLER(cpp_tests, NULL, NULL, fixtures);
return (Test *)&cpp_tests;
}
int main(void)
{
test_utils_interactive_sync();
TESTS_START();
TESTS_RUN(tests_cpp_ctors_tests());
TESTS_END();
return 0;
}