diff --git a/tests/stdin/main.c b/tests/stdin/main.c index 7d071685ba..0b44dc2863 100644 --- a/tests/stdin/main.c +++ b/tests/stdin/main.c @@ -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; } diff --git a/tests/stdin/tests/01-run.py b/tests/stdin/tests/01-run.py index f1d287543b..4acff33846 100755 --- a/tests/stdin/tests/01-run.py +++ b/tests/stdin/tests/01-run.py @@ -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__":