From 2a6ae24ba769892993ec7a173c564f59feb06495 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Mon, 23 Nov 2020 19:24:15 -0700 Subject: Update the testing harness to insulate tests in --nofork mode. Before, when running a test binary in --nofork mode, it was up to the test to reset the program state before exiting to avoid dependencies on other tests. Now after each test the test harness will: 1. Wipeout the fake environmennt. 2. Reset the data segment to its initialization state. This achieves reasonable insulation between tests even though certain things (like a segfault) are stil not practical to completely insulate without fork()'ing. --- 02-usart/tests/metatest.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 02-usart/tests/metatest.c (limited to '02-usart/tests/metatest.c') diff --git a/02-usart/tests/metatest.c b/02-usart/tests/metatest.c new file mode 100644 index 0000000..1024156 --- /dev/null +++ b/02-usart/tests/metatest.c @@ -0,0 +1,22 @@ +#include "test_harness.h" + +/* Tests the test harness itself. */ + +static int my_variable; +static int my_initialized_variable = 5; + +TEST(meta, clobbers_variables) +{ + my_variable = 6; + my_initialized_variable = 5; + + return 0; +} + +TEST(meta, variables_reset) +{ + ASSERT_EQ(my_variable, 0); + ASSERT_EQ(my_initialized_variable, 5); + + return 0; +} -- cgit