Complete autogen, first stab at scheduling each test on an individual period_ms basis

This commit is contained in:
Pim van Pelt
2019-01-03 21:08:10 +01:00
parent 637779681f
commit cb48b78265

View File

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