From 62ce68f2e0a6d60c6a7813372cb6fcabe8de42cc Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Thu, 3 Jan 2019 21:37:58 +0100 Subject: [PATCH] Add test_*_enabled to enable/disable tests --- .gitignore | 1 - README.md | 3 ++- autogen.sh | 2 +- tests/example.c | 20 ++++++++++++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 tests/example.c diff --git a/.gitignore b/.gitignore index ad39a62..2056d7b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ build/ libs/ -tests/ mgos_i2c diff --git a/README.md b/README.md index 1aaf124..8445852 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ bool test_*_destroy(); And static variables named: ``` -uint32_t test_*_period_ms; +uint32_t test_*_period_ms = 1000; +bool test_*_enabled = true; ``` Running `make` will then generate the test skeleton, recursively compile diff --git a/autogen.sh b/autogen.sh index bbca3d9..07f5be1 100755 --- a/autogen.sh +++ b/autogen.sh @@ -120,7 +120,7 @@ gen_src_head for f in tests/*.c; do base=$(basename $f | cut -f1 -d'.') echo "CHK $base in $f" - base_list="$base_list $base" + egrep -q "test_${base}_enabled.*true" $f && base_list="$base_list $base" done gen_inc_body $base_list diff --git a/tests/example.c b/tests/example.c new file mode 100644 index 0000000..015bee0 --- /dev/null +++ b/tests/example.c @@ -0,0 +1,20 @@ +#include "mgos.h" +#include "tests_autogen.h" + +uint32_t test_example_period_ms = 10000; +bool test_example_enabled = true; + +bool test_example_create(void) { + // LOG(LL_INFO, ("Setting up")); + return true; +} + +bool test_example_run(void) { + // LOG(LL_INFO, ("Hello World!")); + return true; +} + +bool test_example_destroy(void) { + // LOG(LL_INFO, ("Tearing down")); + return true; +}