mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests/periph/gpio_ll: fix randomly failing test
A test intended to ensure that a configuration toggling the direction of a GPIO two times restores the original configuration not only compared the configuration at the two points in time, but also the value of the input buffer. Since a floating input reads back random values when not externally driven, the test was actually randomly failing. Apparently I got lucky before consistently and this never triggered until now. This now clears the input value from both the configuration reported before and after toggling the direction twice and should now indeed succeed consistently.
This commit is contained in:
parent
97b91b4f8f
commit
84a4399135
@ -909,6 +909,11 @@ static void test_switch_dir(void)
|
||||
expect(conf.state == GPIO_INPUT);
|
||||
gpio_conf_t conf_orig = conf;
|
||||
|
||||
/* conf_orig.initial_value contains the current value in query_conf.
|
||||
* Since this is a floating input connected to a floating input, it is
|
||||
* random here. ==> Clear it. */
|
||||
conf_orig.initial_value = false;
|
||||
|
||||
/* capture output state before switching from input mode to output mode, so
|
||||
* that it can be restored when switching back to input mode */
|
||||
uword_t out_state = gpio_ll_read_output(port_out);
|
||||
@ -935,6 +940,8 @@ static void test_switch_dir(void)
|
||||
gpio_ll_write(port_out, out_state);
|
||||
/* verify we are back at the old config */
|
||||
conf = gpio_ll_query_conf(port_out, PIN_OUT_0);
|
||||
/* again, initial_value is random due to floating input ==> clear it */
|
||||
conf.initial_value = false;
|
||||
test_passed = (conf.bits == conf_orig.bits);
|
||||
printf_optional("Returning back to input had no side effects on config: %s\n",
|
||||
noyes[test_passed]);
|
||||
|
Loading…
Reference in New Issue
Block a user