mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
tests: ensure Shamir persistence test runs only for core
This commit is contained in:
parent
bc1696b947
commit
f22f4d920e
@ -72,5 +72,6 @@ class BackgroundDeviceHandler:
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_value, traceback):
|
def __exit__(self, exc_type, exc_value, traceback):
|
||||||
if not self.check_finalize():
|
finalized_ok = self.check_finalize()
|
||||||
|
if exc_type is None and not finalized_ok:
|
||||||
raise RuntimeError("Exit while task is unfinished")
|
raise RuntimeError("Exit while task is unfinished")
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from ..emulators import EmulatorWrapper
|
||||||
|
|
||||||
|
SELECTED_GENS = [
|
||||||
|
gen.strip() for gen in os.environ.get("TREZOR_UPGRADE_TEST", "").split(",") if gen
|
||||||
|
]
|
||||||
|
|
||||||
|
if SELECTED_GENS:
|
||||||
|
# if any gens were selected via the environment variable, force enable all selected
|
||||||
|
LEGACY_ENABLED = "legacy" in SELECTED_GENS
|
||||||
|
CORE_ENABLED = "core" in SELECTED_GENS
|
||||||
|
|
||||||
|
else:
|
||||||
|
# if no selection was provided, select those for which we have emulators
|
||||||
|
try:
|
||||||
|
EmulatorWrapper("legacy")
|
||||||
|
LEGACY_ENABLED = True
|
||||||
|
except Exception:
|
||||||
|
LEGACY_ENABLED = False
|
||||||
|
|
||||||
|
try:
|
||||||
|
EmulatorWrapper("core")
|
||||||
|
CORE_ENABLED = True
|
||||||
|
except Exception:
|
||||||
|
CORE_ENABLED = False
|
||||||
|
|
||||||
|
|
||||||
|
legacy_only = pytest.mark.skipif(
|
||||||
|
not LEGACY_ENABLED, reason="This test requires legacy emulator"
|
||||||
|
)
|
||||||
|
|
||||||
|
core_only = pytest.mark.skipif(
|
||||||
|
not CORE_ENABLED, reason="This test requires core emulator"
|
||||||
|
)
|
@ -14,14 +14,13 @@
|
|||||||
# You should have received a copy of the License along with this library.
|
# You should have received a copy of the License along with this library.
|
||||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from trezorlib import MINIMUM_FIRMWARE_VERSION, btc, debuglink, device
|
from trezorlib import MINIMUM_FIRMWARE_VERSION, btc, debuglink, device
|
||||||
from trezorlib.tools import H_
|
from trezorlib.tools import H_
|
||||||
|
|
||||||
from ..emulators import ALL_TAGS, EmulatorWrapper
|
from ..emulators import ALL_TAGS, EmulatorWrapper
|
||||||
|
from . import SELECTED_GENS
|
||||||
|
|
||||||
MINIMUM_FIRMWARE_VERSION["1"] = (1, 0, 0)
|
MINIMUM_FIRMWARE_VERSION["1"] = (1, 0, 0)
|
||||||
MINIMUM_FIRMWARE_VERSION["T"] = (2, 0, 0)
|
MINIMUM_FIRMWARE_VERSION["T"] = (2, 0, 0)
|
||||||
@ -41,11 +40,8 @@ def for_all(*args, minimum_version=(1, 0, 0)):
|
|||||||
if not args:
|
if not args:
|
||||||
args = ("core", "legacy")
|
args = ("core", "legacy")
|
||||||
|
|
||||||
specified_gens = os.environ.get("TREZOR_UPGRADE_TEST")
|
# If any gens were selected, use them. If none, select all.
|
||||||
if specified_gens is not None:
|
enabled_gens = SELECTED_GENS or args
|
||||||
enabled_gens = specified_gens.split(",")
|
|
||||||
else:
|
|
||||||
enabled_gens = args
|
|
||||||
|
|
||||||
all_params = []
|
all_params = []
|
||||||
for gen in args:
|
for gen in args:
|
||||||
|
@ -19,6 +19,7 @@ from trezorlib import device
|
|||||||
from .. import buttons
|
from .. import buttons
|
||||||
from ..device_handler import BackgroundDeviceHandler
|
from ..device_handler import BackgroundDeviceHandler
|
||||||
from ..emulators import EmulatorWrapper
|
from ..emulators import EmulatorWrapper
|
||||||
|
from . import core_only
|
||||||
|
|
||||||
|
|
||||||
def enter_word(debug, word):
|
def enter_word(debug, word):
|
||||||
@ -28,6 +29,7 @@ def enter_word(debug, word):
|
|||||||
return debug.click(buttons.CONFIRM_WORD, wait=True)
|
return debug.click(buttons.CONFIRM_WORD, wait=True)
|
||||||
|
|
||||||
|
|
||||||
|
@core_only
|
||||||
def test_persistence():
|
def test_persistence():
|
||||||
with EmulatorWrapper("core") as emu, BackgroundDeviceHandler(
|
with EmulatorWrapper("core") as emu, BackgroundDeviceHandler(
|
||||||
emu.client
|
emu.client
|
||||||
|
Loading…
Reference in New Issue
Block a user