diff options
-rw-r--r-- | test/py/conftest.py | 8 | ||||
-rw-r--r-- | test/py/tests/test_sleep.py | 7 | ||||
-rw-r--r-- | test/py/u_boot_console_base.py | 3 | ||||
-rw-r--r-- | test/py/u_boot_console_sandbox.py | 5 | ||||
-rw-r--r-- | test/py/u_boot_spawn.py | 12 |
5 files changed, 26 insertions, 9 deletions
diff --git a/test/py/conftest.py b/test/py/conftest.py index 3e162ca..09638e6 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -71,6 +71,9 @@ def pytest_addoption(parser): help='U-Boot board identity/instance') parser.addoption('--build', default=False, action='store_true', help='Compile U-Boot before running tests') + parser.addoption('--gdbserver', default=None, + help='Run sandbox under gdbserver. The argument is the channel '+ + 'over which gdbserver should communicate, e.g. localhost:1234') def pytest_configure(config): """pytest hook: Perform custom initialization at startup time. @@ -110,6 +113,10 @@ def pytest_configure(config): persistent_data_dir = build_dir + '/persistent-data' mkdir_p(persistent_data_dir) + gdbserver = config.getoption('gdbserver') + if gdbserver and board_type != 'sandbox': + raise Exception('--gdbserver only supported with sandbox') + import multiplexed_log log = multiplexed_log.Logfile(result_dir + '/test-log.html') @@ -169,6 +176,7 @@ def pytest_configure(config): ubconfig.persistent_data_dir = persistent_data_dir ubconfig.board_type = board_type ubconfig.board_identity = board_identity + ubconfig.gdbserver = gdbserver env_vars = ( 'board_type', diff --git a/test/py/tests/test_sleep.py b/test/py/tests/test_sleep.py index 74add89..5c1a262 100644 --- a/test/py/tests/test_sleep.py +++ b/test/py/tests/test_sleep.py @@ -15,6 +15,7 @@ def test_sleep(u_boot_console): u_boot_console.run_command('sleep %d' % sleep_time) tend = time.time() elapsed = tend - tstart - delta_to_expected = abs(elapsed - sleep_time) - # 0.25s margin is hopefully enough to account for any system overhead. - assert delta_to_expected < 0.25 + assert elapsed >= sleep_time + if not u_boot_console.config.gdbserver: + # 0.25s margin is hopefully enough to account for any system overhead. + assert elapsed < (sleep_time + 0.25) diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py index 392f8cb..cc54273 100644 --- a/test/py/u_boot_console_base.py +++ b/test/py/u_boot_console_base.py @@ -300,7 +300,8 @@ class ConsoleBase(object): # text if LCD is enabled. This value may need tweaking in the # future, possibly per-test to be optimal. This works for 'help' # on board 'seaboard'. - self.p.timeout = 30000 + if not self.config.gdbserver: + self.p.timeout = 30000 self.p.logfile_read = self.logstream if self.config.buildconfig.get('CONFIG_SPL', False) == 'y': m = self.p.expect([pattern_u_boot_spl_signon] + self.bad_patterns) diff --git a/test/py/u_boot_console_sandbox.py b/test/py/u_boot_console_sandbox.py index a7263f3..3de0fe4 100644 --- a/test/py/u_boot_console_sandbox.py +++ b/test/py/u_boot_console_sandbox.py @@ -39,7 +39,10 @@ class ConsoleSandbox(ConsoleBase): A u_boot_spawn.Spawn object that is attached to U-Boot. """ - cmd = [ + cmd = [] + if self.config.gdbserver: + cmd += ['gdbserver', self.config.gdbserver] + cmd += [ self.config.build_dir + '/u-boot', '-d', self.config.build_dir + '/arch/sandbox/dts/test.dtb' diff --git a/test/py/u_boot_spawn.py b/test/py/u_boot_spawn.py index 0f52d3e..4b9e81a 100644 --- a/test/py/u_boot_spawn.py +++ b/test/py/u_boot_spawn.py @@ -148,10 +148,14 @@ class Spawn(object): self.buf = self.buf[posafter:] return earliest_pi tnow_s = time.time() - tdelta_ms = (tnow_s - tstart_s) * 1000 - if tdelta_ms > self.timeout: - raise Timeout() - events = self.poll.poll(self.timeout - tdelta_ms) + if self.timeout: + tdelta_ms = (tnow_s - tstart_s) * 1000 + poll_maxwait = self.timeout - tdelta_ms + if tdelta_ms > self.timeout: + raise Timeout() + else: + poll_maxwait = None + events = self.poll.poll(poll_maxwait) if not events: raise Timeout() c = os.read(self.fd, 1024) |