Add test_*_enabled to enable/disable tests

This commit is contained in:
Pim van Pelt
2019-01-03 21:37:58 +01:00
parent 031bd34655
commit 62ce68f2e0
4 changed files with 23 additions and 3 deletions

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
build/
libs/
tests/
mgos_i2c

View File

@ -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

View File

@ -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

20
tests/example.c Normal file
View File

@ -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;
}