From c5ea6b54ce8535652dbef92779fcc91d15cd31fa Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Mon, 16 Sep 2019 17:37:18 +0300 Subject: [PATCH] add ignoring results of some tests --- client/emv/cmdemv.c | 17 +++++++++++++++-- client/emv/test/cryptotest.c | 6 +++--- client/emv/test/cryptotest.h | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/client/emv/cmdemv.c b/client/emv/cmdemv.c index 8656e4902..8bb630074 100644 --- a/client/emv/cmdemv.c +++ b/client/emv/cmdemv.c @@ -1714,8 +1714,21 @@ static int CmdEMVList(const char *Cmd) { } static int CmdEMVTest(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - return ExecuteCryptoTests(true); + CLIParserInit("emv test", + "Executes tests\n", + "Usage:\n\temv test\n"); + + void *argtable[] = { + arg_param_begin, + arg_lit0("iI", "ignore", "ignore timing tests for VM"), + arg_param_end + }; + CLIExecWithReturn(Cmd, argtable, true); + + bool ignoreTimeTest = arg_get_lit(1); + CLIParserFree(); + + return ExecuteCryptoTests(true, ignoreTimeTest); } static int CmdEMVRoca(const char *Cmd) { diff --git a/client/emv/test/cryptotest.c b/client/emv/test/cryptotest.c index 937ff7e8e..b8ea1239e 100644 --- a/client/emv/test/cryptotest.c +++ b/client/emv/test/cryptotest.c @@ -33,7 +33,7 @@ #include "crypto/libpcrypto.h" #include "emv/emv_roca.h" -int ExecuteCryptoTests(bool verbose) { +int ExecuteCryptoTests(bool verbose, bool ignore_time) { int res; bool TestFail = false; @@ -56,7 +56,7 @@ int ExecuteCryptoTests(bool verbose) { if (res) TestFail = true; res = mbedtls_entropy_self_test(verbose); - if (res) TestFail = true; + if (res && !ignore_time) TestFail = true; // retry for CI (when resources too low) for (int i = 0; i < 3; i++) { @@ -65,7 +65,7 @@ int ExecuteCryptoTests(bool verbose) { break; PrintAndLogEx(WARNING, "Repeat timing test %d", i + 1); } - if (res) TestFail = true; + if (res && !ignore_time) TestFail = true; res = mbedtls_ctr_drbg_self_test(verbose); if (res) TestFail = true; diff --git a/client/emv/test/cryptotest.h b/client/emv/test/cryptotest.h index 74a317e4e..aeecce556 100644 --- a/client/emv/test/cryptotest.h +++ b/client/emv/test/cryptotest.h @@ -12,5 +12,5 @@ #define __CRYPTOTEST_H #include -int ExecuteCryptoTests(bool verbose); +int ExecuteCryptoTests(bool verbose, bool ignore_time); #endif