Merge pull request #12816 from aabadie/pr/tests/stdin_fix_avr

tests/stdin: fix automatic test on slow platforms
This commit is contained in:
Francisco 2019-12-05 14:09:56 +01:00 committed by GitHub
commit 2b934dea5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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__":