1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tests/stdin: refactor test application

The test application now prints in a loop the input character. In case
stdin is not ready yet after startup this lets the possibility to try to
send several time a character before failing.
The automatic test is now more robust on platforms where stdin takes
time before it gets in a ready state (some AVR, hifive).
This commit is contained in:
Alexandre Abadie 2019-11-26 15:36:39 +01:00
parent f5252bf482
commit a4c3d7342a
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405
2 changed files with 20 additions and 4 deletions

View File

@ -18,7 +18,10 @@
int main(void)
{
int value = getchar();
printf("You entered '%c'\n", (char)value);
while (1) {
int value = getchar();
printf("You entered '%c'\n", (char)value);
}
return 0;
}

View File

@ -7,12 +7,25 @@
# directory for more details.
import sys
import pexpect
from testrunner import run
TEST_INPUT = 'O'
RETRIES = 5
TIMEOUT = 3
def testfunc(child):
child.sendline('O')
child.expect_exact('You entered \'O\'')
expected_output = 'You entered \'{}\''.format(TEST_INPUT)
for _ in range(0, RETRIES):
child.sendline(TEST_INPUT)
ret = child.expect_exact([expected_output, pexpect.TIMEOUT],
timeout=TIMEOUT)
if ret == 0:
break
else:
child.expect_exact(expected_output)
if __name__ == "__main__":