| 31 | # This is a self-contained test, it needs only a pexpect child |
| 32 | # |
| 33 | def runHistoryTest(child): |
| 34 | # find out history size |
| 35 | child.sendline(cmdline_test_data.CMD_GET_BUFSIZE) |
| 36 | child.expect("History buffer size: \\d+", timeout=1) |
| 37 | history_size = int(child.after[len(cmdline_test_data.BUFSIZE_TEMPLATE):]) |
| 38 | i = 0 |
| 39 | |
| 40 | # fill the history with numbers |
| 41 | while i < history_size // 10: |
| 42 | # add 1 to prevent from parsing as octals |
| 43 | child.send("1" + str(i).zfill(8) + cmdline_test_data.ENTER) |
| 44 | # the app will simply print out the number |
| 45 | child.expect(str(i + 100000000), timeout=1) |
| 46 | i += 1 |
| 47 | # scroll back history |
| 48 | child.send(cmdline_test_data.UP * (i + 2) + cmdline_test_data.ENTER) |
| 49 | child.expect("100000000", timeout=1) |
| 50 | |
| 51 | # the path to cmdline_test executable is supplied via command-line. |
| 52 | if len(sys.argv) < 2: |