tests/periph_rtt_min: harden test
- Better self-containment: read number of expected samples from output rather than the environment - Less reliance on `stdout` timing: Count samples in application and output it rather then counting flushed dots.
This commit is contained in:
parent
e28ec7907b
commit
fc6dc25da4
@ -23,5 +23,3 @@ else
|
|||||||
SAMPLES ?= 1024
|
SAMPLES ?= 1024
|
||||||
endif
|
endif
|
||||||
CFLAGS += -DSAMPLES=$(SAMPLES)
|
CFLAGS += -DSAMPLES=$(SAMPLES)
|
||||||
|
|
||||||
$(call target-export-variables, test, SAMPLES)
|
|
||||||
|
|||||||
@ -44,6 +44,7 @@ void cb(void *arg)
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
uint32_t value = 0;
|
uint32_t value = 0;
|
||||||
|
uint32_t samples = 0;
|
||||||
/* mutex starts out locked, and each time an rtt callback is successfully
|
/* mutex starts out locked, and each time an rtt callback is successfully
|
||||||
called it will be locked again for the next iteration */
|
called it will be locked again for the next iteration */
|
||||||
mutex_t lock = MUTEX_INIT_LOCKED;
|
mutex_t lock = MUTEX_INIT_LOCKED;
|
||||||
@ -69,10 +70,12 @@ int main(void)
|
|||||||
}
|
}
|
||||||
printf(".");
|
printf(".");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
samples++;
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
printf("RTT_MIN_OFFSET for %s: %" PRIu32 "\n", RIOT_BOARD, value);
|
printf("RTT_MIN_OFFSET for %s over %" PRIu32 " samples: %" PRIu32 "\n",
|
||||||
|
RIOT_BOARD, samples, value);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,18 +6,19 @@
|
|||||||
# General Public License v2.1. See the file LICENSE in the top level
|
# General Public License v2.1. See the file LICENSE in the top level
|
||||||
# directory for more details.
|
# directory for more details.
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from testrunner import run
|
from testrunner import run
|
||||||
|
|
||||||
SAMPLES = int(os.getenv("SAMPLES", "1024"))
|
|
||||||
|
|
||||||
|
|
||||||
def testfunc(child):
|
def testfunc(child):
|
||||||
for _ in range(0, SAMPLES):
|
child.expect(r"Evaluate RTT_MIN_OFFSET over (\d+) samples")
|
||||||
child.expect_exact('.')
|
|
||||||
child.expect(r'RTT_MIN_OFFSET for [a-zA-Z\-\_0-9]+: \d+')
|
exp_samples = int(child.match.group(1))
|
||||||
|
child.expect(
|
||||||
|
r'RTT_MIN_OFFSET for [a-zA-Z\-\_0-9]+ over {samples} samples: \d+'
|
||||||
|
.format(samples=exp_samples)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user