Skip to content

Commit

Permalink
Fix se050 test result always failing
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Aug 16, 2023
1 parent dab5dc6 commit e1ef89c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pynitrokey/cli/nk3/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,19 +355,20 @@ def select(conn: CardConnection, aid: list[int]) -> bool:

@test_case("se050", "SE050")
def test_se050(ctx: TestContext, device: Nitrokey3Base) -> TestResult:
from queue import Queue

if not isinstance(device, Nitrokey3Device):
return TestResult(TestStatus.SKIPPED)
firmware_version = ctx.firmware_version or device.version()
if firmware_version.core() < Version(1, 5, 0):
return TestResult(TestStatus.SKIPPED)

result = None
que: Queue[Optional[bytes]] = Queue()

def internal_se050_run():
result = AdminApp(device).se050_tests()
print(result)
def internal_se050_run(q: Queue[Optional[bytes]]) -> None:
q.put(AdminApp(device).se050_tests())

t = Thread(target=internal_se050_run)
t = Thread(target=internal_se050_run, args=[que])
t.start()
bar = tqdm(
desc="Running SE050 test", unit="%", bar_format="{l_bar}{bar}", total=900
Expand All @@ -382,10 +383,11 @@ def internal_se050_run():
bar.close()
return TestResult(
TestStatus.FAILURE,
f"Test timed out after 1m30",
"Test timed out after 1m30",
)

bar.close()
result = que.get()

if result is None or len(result) < 11:
return TestResult(TestStatus.FAILURE, "Did not get test run data")
Expand Down

0 comments on commit e1ef89c

Please sign in to comment.