From 003189e780af8208f243bbd312df5f5295015eb1 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Mon, 24 Oct 2016 15:50:15 +0200 Subject: Test: check more commands Add delay after each command by default. Check EnableHiddenEncryptedPartition more than once. Signed-off-by: Szczepan Zalega --- unittest/test2.cc | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'unittest/test2.cc') diff --git a/unittest/test2.cc b/unittest/test2.cc index 503ab49..61fb502 100644 --- a/unittest/test2.cc +++ b/unittest/test2.cc @@ -18,11 +18,16 @@ using namespace nitrokey::misc; template -void execute_password_command(Device &stick, const char *password) { +void execute_password_command(Device &stick, const char *password, const char kind = 'P') { auto p = get_payload(); - p.set_kind_user(); + if (kind == 'P'){ + p.set_kind_user(); + } else { + p.set_kind_admin(); + } strcpyT(p.password, password); CMDTYPE::CommandTransaction::run(stick, p); + this_thread::sleep_for(1000ms); } @@ -36,10 +41,33 @@ TEST_CASE("test", "[test]") { stick10::LockDevice::CommandTransaction::run(stick); // execute_password_command(stick, "123456"); // execute_password_command(stick, "123456"); - execute_password_command(stick, "123456"); this_thread::sleep_for(1000ms); - execute_password_command(stick, "123123123"); + execute_password_command(stick, "123456"); + this_thread::sleep_for(4000ms); + bool passed = false; + for(int i=0; i<5; i++){ + try { + execute_password_command(stick, "123123123"); + CHECK(true); + passed=true; + break; + } + catch (CommandFailedException &e){ + this_thread::sleep_for(2000ms); + } + } + if(!passed){ + CHECK(false); + } + + execute_password_command(stick, "123123123"); + execute_password_command(stick, "123456"); + execute_password_command(stick, "123456"); + execute_password_command(stick, "12345678", 'A'); this_thread::sleep_for(1000ms); +// execute_password_command(stick, "123123123"); +// execute_password_command(stick, "123123123"); //FIRMWARE PIN + stick10::LockDevice::CommandTransaction::run(stick); stick.disconnect(); -- cgit v1.2.1