From cb48b78265898f0b2849716f5ce48498eb092dcc Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Thu, 3 Jan 2019 21:08:10 +0100 Subject: [PATCH] Complete autogen, first stab at scheduling each test on an individual period_ms basis --- autogen.sh | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/autogen.sh b/autogen.sh index bbad0ac..bbca3d9 100755 --- a/autogen.sh +++ b/autogen.sh @@ -19,7 +19,11 @@ EOF gen_src_body() { echo "GEN $OUT_SRC" ( - for func in create run destroy; do + for n in $*; do + echo "extern uint32_t test_${n}_period_ms;" + done + echo "" + for func in create destroy; do echo "bool tests_${func}(void) {" echo " uint32_t total=0, success=0;" for n in $*; do @@ -39,6 +43,36 @@ EOF EOF done + + cat << EOF +bool tests_run(void) { + double now; + uint32_t total, success; +EOF + for n in $*; do + echo " static double next_${n}_run = 0;" + done + cat << EOF + for (;;) { + now = mg_time(); +EOF + for n in $*; do + cat << EOF + if (now > next_${n}_run) { + if (test_${n}_run()) success++; + next_${n}_run = now + (test_${n}_period_ms/1000.f); + total++; + } +EOF + done + + cat << EOF + mgos_usleep(1000); + } + return (total == success); +} + +EOF ) >> $OUT_SRC }