Skip to content

Commit

Permalink
Change tick0 test to check for consistent seek-ticks event
Browse files Browse the repository at this point in the history
  • Loading branch information
dzaima committed Nov 9, 2023
1 parent 921cf98 commit 46de444
Showing 1 changed file with 36 additions and 25 deletions.
61 changes: 36 additions & 25 deletions src/test/tick0.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,47 @@

send_gdb('handle SIGKILL stop')

send_gdb('when')
expect_gdb(re.compile(r'Current event: (\d+)'))
event = eval(last_match().group(1));
def get_when():
send_gdb('when')
expect_gdb(re.compile(r'Current event: (\d+)'))
event = eval(last_match().group(1))

send_gdb('when-ticks')
expect_gdb(re.compile(r'Current tick: (\d+)'))
ticks = eval(last_match().group(1));
if ticks != 0:
failed('ERROR in first "when-ticks"')
send_gdb('when-ticks')
expect_gdb(re.compile(r'Current tick: (\d+)'))
ticks = eval(last_match().group(1))
return (event, ticks)

(event_start, ticks_start) = get_when()
if ticks_start != 0:
failed('ERROR: Wrong initial ticks')

send_gdb('c')

send_gdb('when-ticks')
expect_gdb(re.compile(r'Current tick: (\d+)'))
ticks2 = eval(last_match().group(1));
if ticks2 < 99999:
failed('ERROR in second "when-ticks"')
(event_end, ticks_end) = get_when()
if ticks_end < 99999:
failed('End ticks too low')

send_gdb("seek-ticks %d" % ticks)
send_gdb("seek-ticks %d" % ticks_start)
expect_gdb("Program stopped.")
send_gdb('when-ticks')
expect_gdb(re.compile(r'Current tick: (\d+)'))
ticks3 = eval(last_match().group(1));
if ticks3 != ticks:
failed('ERROR: Failed to seek back to ticks')

send_gdb('when')
expect_gdb(re.compile(r'Current event: (\d+)'))
event2 = eval(last_match().group(1));
if event2 != event:
failed('ERROR: Failed to seek back to ticks')
(event_exp, ticks_from_end) = get_when()
if ticks_from_end != ticks_start:
failed('ERROR: Failed to seek back to tick 0 from end')

# test some starting events (at least all at tick 0)
for event in range(event_start-1, min(event_start+5, event_end-1)):
send_gdb('run %d' % event)
expect_gdb('from the beginning')
send_gdb('y')
expect_gdb(re.compile(r'(Thread \d+|Program) stopped'))


send_gdb("seek-ticks %d" % ticks_start)
expect_gdb("Program stopped.")

(event, ticks) = get_when()
if ticks != 0:
failed('ERROR: Failed to seek back to tick 0 from run')
if event != event_exp:
failed('ERROR: Inconsistent result events from seek-ticks 0')

ok()

0 comments on commit 46de444

Please sign in to comment.