aboutsummaryrefslogtreecommitdiff
path: root/02-usart/tests
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2020-11-23 19:24:15 -0700
committerJosh Rahm <joshuarahm@gmail.com>2020-11-23 19:24:15 -0700
commit2a6ae24ba769892993ec7a173c564f59feb06495 (patch)
treeba08a86b4423dd013a047719f6352fcbdb218478 /02-usart/tests
parentca6957820c5dd156e313161b75f37afc85a57b1d (diff)
downloadstm32l4-2a6ae24ba769892993ec7a173c564f59feb06495.tar.gz
stm32l4-2a6ae24ba769892993ec7a173c564f59feb06495.tar.bz2
stm32l4-2a6ae24ba769892993ec7a173c564f59feb06495.zip
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.
Diffstat (limited to '02-usart/tests')
-rw-r--r--02-usart/tests/metatest.c22
1 files changed, 22 insertions, 0 deletions
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;
+}