scripts/python/recordreplay.py: improved testing of normal recordings.
Set telnet_hz to 100 to reduce delay when making a recording - this avoids problem where telnet round-trip time could result in recording being 1-2s longer than we expected, leading to test failures.
This commit is contained in:
parent
930c77b69f
commit
f5243e7e7d
1 changed files with 13 additions and 2 deletions
|
@ -95,7 +95,7 @@ class Fg:
|
||||||
self.fg is a FlightGear.FlightGear instance, which uses telnet to
|
self.fg is a FlightGear.FlightGear instance, which uses telnet to
|
||||||
communicate with Flightgear.
|
communicate with Flightgear.
|
||||||
'''
|
'''
|
||||||
def __init__(self, aircraft, args, env=None, telnet_port=None, telnet_hz=None, out=None):
|
def __init__(self, aircraft, args, env=None, telnet_port=None, telnet_hz=None, out=None, screensaver_suspend=True):
|
||||||
'''
|
'''
|
||||||
aircraft:
|
aircraft:
|
||||||
Specified as: --aircraft={aircraft}. This is separate from <args>
|
Specified as: --aircraft={aircraft}. This is separate from <args>
|
||||||
|
@ -120,6 +120,7 @@ class Fg:
|
||||||
else:
|
else:
|
||||||
args += f' --telnet=_,_,{telnet_hz},_,{telnet_port},_'
|
args += f' --telnet=_,_,{telnet_hz},_,{telnet_port},_'
|
||||||
args += f' --prop:/sim/replay/tape-directory={g_tapedir}'
|
args += f' --prop:/sim/replay/tape-directory={g_tapedir}'
|
||||||
|
args += f' --prop:bool:/sim/startup/screensaver-suspend={"true" if screensaver_suspend else "false"}'
|
||||||
|
|
||||||
args2 = args.split()
|
args2 = args.split()
|
||||||
|
|
||||||
|
@ -265,13 +266,22 @@ def make_recording(
|
||||||
# time, so we sometimes need to sleep a little longer.
|
# time, so we sometimes need to sleep a little longer.
|
||||||
#
|
#
|
||||||
while 1:
|
while 1:
|
||||||
|
# Telnet interface seems very slow even if we set telnet_hz to
|
||||||
|
# 100 (for example). We want to make recording have near to the
|
||||||
|
# specified length, so we are cautious about overrunning.
|
||||||
|
#
|
||||||
|
#log(f'a: time.time()-t={time.time()-t}')
|
||||||
t_record_begin = fg.fg['sim/replay/record-normal-begin']
|
t_record_begin = fg.fg['sim/replay/record-normal-begin']
|
||||||
|
#log(f'b: time.time()-t={time.time()-t}')
|
||||||
t_record_end = fg.fg['sim/replay/record-normal-end']
|
t_record_end = fg.fg['sim/replay/record-normal-end']
|
||||||
|
#log(f'c: time.time()-t={time.time()-t}')
|
||||||
t_delta = t_record_end - t_record_begin
|
t_delta = t_record_end - t_record_begin
|
||||||
log(f't_record_begin={t_record_begin} t_record_end={t_record_end} t_delta={t_delta}')
|
log(f't_record_begin={t_record_begin} t_record_end={t_record_end} t_delta={t_delta}')
|
||||||
if t_delta >= length:
|
if t_delta >= length:
|
||||||
break
|
break
|
||||||
time.sleep(length - t_delta + 0.1)
|
ts = max(length - t_delta - 1, 0.2)
|
||||||
|
log(f'd: ts={ts}')
|
||||||
|
time.sleep(ts)
|
||||||
log(f'/sim/time/elapsed-sec={t}')
|
log(f'/sim/time/elapsed-sec={t}')
|
||||||
log(f'/sim/replay/start-time={fg.fg["/sim/replay/start-time"]}')
|
log(f'/sim/replay/start-time={fg.fg["/sim/replay/start-time"]}')
|
||||||
log(f'/sim/replay/end-time={fg.fg["/sim/replay/end-time"]}')
|
log(f'/sim/replay/end-time={fg.fg["/sim/replay/end-time"]}')
|
||||||
|
@ -315,6 +325,7 @@ def test_record_replay(
|
||||||
# Start Flightgear.
|
# Start Flightgear.
|
||||||
fg = Fg(aircraft, f'{fgfs_save} {args}',
|
fg = Fg(aircraft, f'{fgfs_save} {args}',
|
||||||
#env='SG_LOG_DELTAS=flightgear/src/Network/props.cxx=4',
|
#env='SG_LOG_DELTAS=flightgear/src/Network/props.cxx=4',
|
||||||
|
telnet_hz=100,
|
||||||
)
|
)
|
||||||
fg.waitfor('/sim/fdm-initialized', 1, timeout=45)
|
fg.waitfor('/sim/fdm-initialized', 1, timeout=45)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue