split slow tests

This commit is contained in:
Philippe Teuwen
2019-09-21 18:32:07 +02:00
parent e7d67fc2b0
commit 782feb934a
9 changed files with 43 additions and 17 deletions

View File

@@ -1716,19 +1716,21 @@ static int CmdEMVList(const char *Cmd) {
static int CmdEMVTest(const char *Cmd) {
CLIParserInit("emv test",
"Executes tests\n",
"Usage:\n\temv test\n");
"Usage:\n\temv test [l]\n");
void *argtable[] = {
arg_param_begin,
arg_lit0("iI", "ignore", "ignore timing tests for VM"),
arg_lit0("lL", "long", "run long tests too"),
arg_param_end
};
CLIExecWithReturn(Cmd, argtable, true);
bool ignoreTimeTest = arg_get_lit(1);
bool runSlowTests = arg_get_lit(2);
CLIParserFree();
return ExecuteCryptoTests(true, ignoreTimeTest);
return ExecuteCryptoTests(true, ignoreTimeTest, runSlowTests);
}
static int CmdEMVRoca(const char *Cmd) {

View File

@@ -301,8 +301,9 @@ close_pub:
return ret;
}
int exec_crypto_test(bool verbose) {
unsigned int keylengths[] = {1024, 1152, 1408, 1984, 2048, 3072, 4096};
int exec_crypto_test(bool verbose, bool include_slow_tests) {
unsigned int keylengths[] = {1024, 2048};
unsigned int extra_keylengths[] = {1152, 1408, 1984, 3072, 4096};
int i;
int ret;
fprintf(stdout, "\n");
@@ -322,6 +323,15 @@ int exec_crypto_test(bool verbose) {
return ret;
}
}
if (include_slow_tests) {
for (i = 0; i < ARRAYLEN(extra_keylengths); i++) {
unsigned int kl = extra_keylengths[i];
ret = test_genkey(kl, message, kl / 8, verbose);
if (ret) {
fprintf(stderr, "Crypto generate key[%u] test: failed\n", kl);
return ret;
}
}
}
return 0;
}

View File

@@ -17,5 +17,5 @@
#define __CRYPTO_TEST_H
#include <stdbool.h>
int exec_crypto_test(bool verbose);
int exec_crypto_test(bool verbose, bool include_slow_tests);
#endif

View File

@@ -33,7 +33,7 @@
#include "crypto/libpcrypto.h"
#include "emv/emv_roca.h"
int ExecuteCryptoTests(bool verbose, bool ignore_time) {
int ExecuteCryptoTests(bool verbose, bool ignore_time, bool include_slow_tests) {
int res;
bool TestFail = false;
@@ -94,7 +94,7 @@ int ExecuteCryptoTests(bool verbose, bool ignore_time) {
res = exec_cda_test(verbose);
if (res) TestFail = true;
res = exec_crypto_test(verbose);
res = exec_crypto_test(verbose, include_slow_tests);
if (res) TestFail = true;
res = roca_self_test();

View File

@@ -12,5 +12,5 @@
#define __CRYPTOTEST_H
#include <stdbool.h>
int ExecuteCryptoTests(bool verbose, bool ignore_time);
int ExecuteCryptoTests(bool verbose, bool ignore_time, bool include_slow_tests);
#endif