diff --git a/test/py/conftest.py b/test/py/conftest.py index e1674dfce053512be1dccd923371604db6bceb37..38aa3f922a86afbde3536def5a38f4d2288307f9 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -227,7 +227,7 @@ def pytest_generate_tests(metafunc): vals = subconfig.get(fn + 's', []) metafunc.parametrize(fn, vals) -@pytest.fixture(scope='session') +@pytest.fixture(scope='function') def u_boot_console(request): '''Generate the value of a test's u_boot_console fixture. @@ -238,6 +238,7 @@ def u_boot_console(request): The fixture value. ''' + console.ensure_spawned() return console tests_not_run = set() diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py index a3e8dd30330b97261f8d6d1ffcc6e967dc56f1b7..557c3afe5c0ad39ea08e86d94056d0d5d89598fc 100644 --- a/test/py/tests/test_env.py +++ b/test/py/tests/test_env.py @@ -77,11 +77,15 @@ class StateTestEnv(object): return var n += 1 -@pytest.fixture(scope='module') +ste = None +@pytest.fixture(scope='function') def state_test_env(u_boot_console): '''pytest fixture to provide a StateTestEnv object to tests.''' - return StateTestEnv(u_boot_console) + global ste + if not ste: + ste = StateTestEnv(u_boot_console) + return ste def unset_var(state_test_env, var): '''Unset an environment variable. diff --git a/test/py/tests/test_sandbox_exit.py b/test/py/tests/test_sandbox_exit.py index 2aa8eb4abc68656376e3b5fcd5c1f11939427fed..1ec3607eb28a161ab7351cfd03e69fb1793966e3 100644 --- a/test/py/tests/test_sandbox_exit.py +++ b/test/py/tests/test_sandbox_exit.py @@ -13,7 +13,6 @@ def test_reset(u_boot_console): u_boot_console.run_command('reset', wait_for_prompt=False) assert(u_boot_console.validate_exited()) - u_boot_console.ensure_spawned() @pytest.mark.boardspec('sandbox') def test_ctrl_c(u_boot_console): @@ -21,4 +20,3 @@ def test_ctrl_c(u_boot_console): u_boot_console.kill(signal.SIGINT) assert(u_boot_console.validate_exited()) - u_boot_console.ensure_spawned() diff --git a/test/py/tests/test_sleep.py b/test/py/tests/test_sleep.py index 64f1ddf9a09f4e59952b333ed83f863326348647..437b6bb9fea9089949c47cf66e117892b1c3a540 100644 --- a/test/py/tests/test_sleep.py +++ b/test/py/tests/test_sleep.py @@ -9,10 +9,6 @@ def test_sleep(u_boot_console): '''Test the sleep command, and validate that it sleeps for approximately the correct amount of time.''' - # Do this before we time anything, to make sure U-Boot is already running. - # Otherwise, the system boot time is included in the time measurement. - u_boot_console.ensure_spawned() - # 3s isn't too long, but is enough to cross a few second boundaries. sleep_time = 3 tstart = time.time() diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py index 520f9a9e9f311d1b66d022ae14016344ee4b0e0f..10fe3dbdd37221412b71add656c7f79574d99f19 100644 --- a/test/py/u_boot_console_base.py +++ b/test/py/u_boot_console_base.py @@ -144,8 +144,6 @@ class ConsoleBase(object): command string and emitted the subsequent command prompts. ''' - self.ensure_spawned() - if self.at_prompt and \ self.at_prompt_logevt != self.logstream.logfile.cur_evt: self.logstream.write(self.prompt, implicit=True) diff --git a/test/py/u_boot_console_sandbox.py b/test/py/u_boot_console_sandbox.py index 88b137e8c3a1feff164bc5dfd4f26d82f82eecc4..eb84150a1e44ff5d4bf8a66d2103074794e45b1c 100644 --- a/test/py/u_boot_console_sandbox.py +++ b/test/py/u_boot_console_sandbox.py @@ -51,7 +51,6 @@ class ConsoleSandbox(ConsoleBase): Nothing. ''' - self.ensure_spawned() self.log.action('kill %d' % sig) self.p.kill(sig)