1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
19030: tests/periph_timer_short_relative_set: improve test r=benpicco a=maribu

### Contribution description

Reduce the number lines to output by only testing for intervals 0..15 to speed up the test.

In addition, run each test case 128 repetitions (it is still faster than before) to give some confidence the short relative set actually succeeded.

### Testing procedure

The test application should consistently fail or succeed, rather than occasionally passing.

### Issues/PRs references

None

19085: makefiles/tests/tests.inc.mk: fix test/available target r=benpicco a=maribu

### Contribution description

`dist/tools/compile_and_test_for_board/compile_and_test_for_board.py` relies on `make test/available` to check if a test if available. However, this so far did not take `TEST_ON_CI_BLACKLIST` and `TEST_ON_CI_WHITELIST` into account, resulting in tests being executed for boards which they are not available. This should fix the issue.

### Testing procedure


#### Expected to fail

```
$ make BOARD=nrf52840dk -C tests/gcoap_fileserver test/available
$ make BOARD=microbit -C tests/log_color test/available
```

(On `master`, they succeed, but fail in this PR.)

#### Expected to succeed

```
$ make BOARD=native -C tests/gcoap_fileserver test/available
$ make BOARD=nrf52840dk -C tests/pkg_edhoc_c test/available
$ make BOARD=nrf52840dk -C tests/log_color test/available
```

(Succeed in both `master` and this PR.)

### Issues/PRs references

None

Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
This commit is contained in:
bors[bot] 2023-01-04 01:20:19 +00:00 committed by GitHub
commit 21af24729e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 17 deletions

View File

@ -28,6 +28,16 @@ test: $(TEST_DEPS)
done
test/available:
ifneq (,$(TEST_ON_CI_WHITELIST))
ifeq (,$(filter $(BOARD),$(TEST_ON_CI_WHITELIST)))
@echo "Board $(BOARD) not in TEST_ON_CI_WHITELIST"
$(Q)false
endif
endif
ifneq (,$(filter $(BOARD) all,$(TEST_ON_CI_BLACKLIST)))
@echo "Board $(BOARD) is in TEST_ON_CI_BLACKLIST"
$(Q)false
endif
$(Q)test -n "$(strip $(TESTS))"
# Tests that require root privileges

View File

@ -75,33 +75,36 @@ int main(void)
puts("\nTest for peripheral TIMER short timer_set()\n");
printf("This test tries timer_set() with decreasing intervals down to 0.\n"
"You should see lines like 'interval <n> ok', followed by a success"
"You should see lines like 'interval <n>: OK', followed by a success"
" message.\n"
"On failure, this test prints an error message.\n\n");
printf("testing periph_timer %u, freq %lu\n", TEST_TIMER_DEV, TEST_TIMER_FREQ);
printf("testing periph_timer %u, freq %lu, bits = %u\n",
TEST_TIMER_DEV, TEST_TIMER_FREQ, TEST_TIMER_WIDTH);
timer_init(TEST_TIMER_DEV, TEST_TIMER_FREQ, cb, thread_get_active());
uint32_t interval = 100;
uint32_t interval = 16;
const unsigned max_repetitions = 128;
while (interval--) {
uint32_t before = timer_read(TEST_TIMER_DEV);
timer_set(TEST_TIMER_DEV, 0, interval);
while(!thread_flags_clear(1)) {
uint32_t diff = (timer_read(TEST_TIMER_DEV) - before)
& TEST_TIMER_MAX;
if (diff > TEST_MAX_DIFF) {
printf("ERROR: too long delay, aborted after %" PRIu32
" (TEST_MAX_DIFF=%lu)\n"
"TEST FAILED\n"
"Note: This is currently expected to fail on most boards.\n",
diff, TEST_MAX_DIFF);
while(1) {}
for (unsigned rep = 0; rep < max_repetitions; rep++) {
uint32_t before = timer_read(TEST_TIMER_DEV);
timer_set(TEST_TIMER_DEV, 0, interval);
while (!thread_flags_clear(1)) {
uint32_t diff = (timer_read(TEST_TIMER_DEV) - before)
& TEST_TIMER_MAX;
if (diff > TEST_MAX_DIFF) {
printf("ERROR: too long delay, aborted after %" PRIu32
" (TEST_MAX_DIFF=%lu) on repetition %u\n"
"TEST FAILED\n",
diff, TEST_MAX_DIFF, rep);
return EXIT_FAILURE;
}
}
}
printf("interval %" PRIu32 " ok\n", interval);
printf("interval %" PRIu32 ": OK\n", interval);
}
puts("\nTEST SUCCEEDED");
return 0;
return EXIT_SUCCESS;
}