diff --git a/src/test/tick0.py b/src/test/tick0.py index b40a60ad479..732d31d5764 100644 --- a/src/test/tick0.py +++ b/src/test/tick0.py @@ -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()