From 1704d55e052efd9896fbefa18a0d67833239b939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sosth=C3=A8ne=20Gu=C3=A9don?= Date: Wed, 7 Dec 2022 09:59:57 +0100 Subject: [PATCH] Add basic opensc test --- Cargo.toml | 2 ++ Makefile | 2 +- tests/opensc.rs | 22 ++++++++++++++++++++++ tests/pivy.rs | 2 +- 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 tests/opensc.rs diff --git a/Cargo.toml b/Cargo.toml index 8261708..45056f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,6 +51,8 @@ default = [] strict-pin = [] std = [] virtual = ["std", "vpicc","trussed/virt"] +pivy-tests = [] +opensc-tests = [] log-all = [] log-none = [] diff --git a/Makefile b/Makefile index ac78149..77f35c6 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ build-cortex-m4: .PHONY: test test: - cargo test --features virtual + cargo test --features virtual,pivy-tests,opensc-tests .PHONY: check check: diff --git a/tests/opensc.rs b/tests/opensc.rs new file mode 100644 index 0000000..a119a4d --- /dev/null +++ b/tests/opensc.rs @@ -0,0 +1,22 @@ +// Copyright (C) 2022 Nitrokey GmbH +// SPDX-License-Identifier: LGPL-3.0-only + +#![cfg(all(feature = "virtual", feature = "opensc-tests"))] + +mod card; + +use card::with_vsc; + +use expectrl::{spawn, Eof, Regex, WaitStatus}; + +#[test] +fn list() { + with_vsc(|| { + let mut p = spawn("piv-tool -n").unwrap(); + p.check("Using reader with a card: Virtual PCD 00 00") + .unwrap(); + p.check("Personal Identity Verification Card").unwrap(); + p.check(Eof).unwrap(); + assert_eq!(p.wait().unwrap(), WaitStatus::Exited(p.pid(), 0)); + }); +} diff --git a/tests/pivy.rs b/tests/pivy.rs index 1370e57..addb0ea 100644 --- a/tests/pivy.rs +++ b/tests/pivy.rs @@ -1,7 +1,7 @@ // Copyright (C) 2022 Nitrokey GmbH // SPDX-License-Identifier: LGPL-3.0-only -#![cfg(feature = "virtual")] +#![cfg(all(feature = "virtual", feature = "pivy-tests"))] mod card;