Skip to content

Commit

Permalink
Merge pull request RIOT-OS#12816 from aabadie/pr/tests/stdin_fix_avr
Browse files Browse the repository at this point in the history
tests/stdin: fix automatic test on slow platforms
  • Loading branch information
fjmolinas authored Dec 5, 2019
2 parents cf0fb1d + a4c3d73 commit 2b934de
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
7 changes: 5 additions & 2 deletions tests/stdin/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
17 changes: 15 additions & 2 deletions tests/stdin/tests/01-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down

0 comments on commit 2b934de

Please sign in to comment.