diff options
author | Robin Krahl <me@robin-krahl.de> | 2019-01-13 12:04:51 +0100 |
---|---|---|
committer | Robin Krahl <me@robin-krahl.de> | 2019-01-13 13:27:05 +0100 |
commit | 4f7c1b31191d98904276fecd236e6b68b405c349 (patch) | |
tree | 4c1f5c76357aba3d914031b73ed97ab7284f2dd9 /unittest/test_multiple_devices.cc | |
parent | 66763febd7990f35d34345175257b2ad9401e829 (diff) | |
download | libnitrokey-4f7c1b31191d98904276fecd236e6b68b405c349.tar.gz libnitrokey-4f7c1b31191d98904276fecd236e6b68b405c349.tar.bz2 |
Add test case for Device::enumerate to test_multiple_devices
The current test case is renamed to “List Storage devices” as it also
displays the SD card ID. The new test case, “List devices”, lists all
connected devices and prints their model, path and serial number.
Diffstat (limited to 'unittest/test_multiple_devices.cc')
-rw-r--r-- | unittest/test_multiple_devices.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/unittest/test_multiple_devices.cc b/unittest/test_multiple_devices.cc index 183af4f..2ea8a20 100644 --- a/unittest/test_multiple_devices.cc +++ b/unittest/test_multiple_devices.cc @@ -34,6 +34,28 @@ using namespace nitrokey; TEST_CASE("List devices", "[BASIC]") { + auto v = Device::enumerate(); + REQUIRE(v.size() > 0); + for (auto i : v){ + auto d = Device::create(i.m_deviceModel); + if (!d) { + std::cout << "Could not create device with model " << i.m_deviceModel << "\n"; + continue; + } + std::cout << i.m_deviceModel << " " << i.m_path << " "; + std::wcout << i.m_serialNumber; + std::cout << " |"; + d->set_path(i.m_path); + d->connect(); + auto res = GetStatus::CommandTransaction::run(d); + std::cout << " " << res.data().card_serial_u32 << " " + << res.data().get_card_serial_hex() + << std::endl; + d->disconnect(); + } +} + +TEST_CASE("List Storage devices", "[BASIC]") { shared_ptr<Stick20> d = make_shared<Stick20>(); auto v = Device::enumerate(); REQUIRE(v.size() > 0); |