[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/5] pkd: support -m to match multiple tests
[Thread Prev] | [Thread Next]
- Subject: [PATCH 5/5] pkd: support -m to match multiple tests
- From: Jon Simons <jon@xxxxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Wed, 12 Jul 2017 15:46:47 -0700
- To: libssh@xxxxxxxxxx
From 1bb60162316feacb638c7764b4e0b887e3b1d871 Mon Sep 17 00:00:00 2001 From: Jon Simons <jon@xxxxxxxxxxxxx> Date: Wed, 12 Jul 2017 13:34:59 -0700 Subject: [PATCH 5/5] pkd: support -m to match multiple tests Signed-off-by: Jon Simons <jon@xxxxxxxxxxxxx> --- tests/pkd/pkd_daemon.h | 1 + tests/pkd/pkd_hello.c | 30 +++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/tests/pkd/pkd_daemon.h b/tests/pkd/pkd_daemon.h index c42573c1..7f553fdf 100644 --- a/tests/pkd/pkd_daemon.h +++ b/tests/pkd/pkd_daemon.h @@ -26,6 +26,7 @@ struct pkd_daemon_args { int libssh_log_level; const char *testname; + const char *testmatch; unsigned int iterations; } opts; }; diff --git a/tests/pkd/pkd_hello.c b/tests/pkd/pkd_hello.c index de3c4768..096e5b6f 100644 --- a/tests/pkd/pkd_hello.c +++ b/tests/pkd/pkd_hello.c @@ -1,7 +1,7 @@ /* * pkd_hello.c -- * - * (c) 2014 Jon Simons + * (c) 2014, 2017 Jon Simons <jon@xxxxxxxxxxxxx> */ #include <setjmp.h> // for cmocka @@ -25,9 +25,9 @@ static struct pkd_daemon_args pkd_dargs; #include <argp.h> #define PROGNAME "pkd_hello" #define ARGP_PROGNAME "libssh " PROGNAME -const char *argp_program_version = ARGP_PROGNAME " 2014-04-12"; +const char *argp_program_version = ARGP_PROGNAME " 2017-07-12"; const char *argp_program_bug_address = "Jon Simons <jon@xxxxxxxxxxxxx>"; -//static char **cmdline; + static char doc[] = \ "\nExample usage:\n\n" " " PROGNAME "\n" @@ -36,6 +36,8 @@ static char doc[] = \ " List available individual test names.\n" " " PROGNAME " -i 1000 -t torture_pkd_rsa_ecdh_sha2_nistp256\n" " Run only the torture_pkd_rsa_ecdh_sha2_nistp256 testcase 1000 times.\n" + " " PROGNAME " -i 1000 -m curve25519\n" + " Run all tests with the string 'curve25519' 1000 times.\n" " " PROGNAME " -v -v -v -v -e -o\n" " Run all tests with maximum libssh and pkd logging.\n" ; @@ -47,6 +49,8 @@ static struct argp_option options[] = { "List available individual test names", 0 }, { "iterations", 'i', "number", 0, "Run each test for the given number of iterations (default is 10)", 0 }, + { "match", 'm', "testmatch", 0, + "Run all tests with the given string", 0 }, { "stdout", 'o', NULL, 0, "Emit pkd stdout messages", 0 }, { "test", 't', "testname", 0, @@ -71,6 +75,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { case 'i': pkd_dargs.opts.iterations = atoi(arg); break; + case 'm': + pkd_dargs.opts.testmatch = arg; + break; case 'o': pkd_dargs.opts.log_stdout = 1; break; @@ -478,12 +485,14 @@ static int pkd_run_tests(void) { memcpy(&all_tests[tindex], &noop_tests[0], sizeof(noop_tests)); tindex += (sizeof(noop_tests) / sizeof(noop_tests[0])); - if (pkd_dargs.opts.testname == NULL) { + if ((pkd_dargs.opts.testname == NULL) && + (pkd_dargs.opts.testmatch == NULL)) { rc = _cmocka_run_group_tests("all tests", all_tests, tindex, NULL, NULL); } else { int i = 0; int num_found = 0; const char *testname = pkd_dargs.opts.testname; + const char *testmatch = pkd_dargs.opts.testmatch; struct CMUnitTest matching_tests[sizeof(all_tests)]; memset(&matching_tests[0], 0x0, sizeof(matching_tests)); @@ -491,10 +500,21 @@ static int pkd_run_tests(void) { while (testmap[i].testname != NULL) { if ((testname != NULL) && (strcmp(testmap[i].testname, testname) == 0)) { - memcpy(&matching_tests[0], &testmap[i].test, sizeof(struct CMUnitTest)); + memcpy(&matching_tests[0], + &testmap[i].test, + sizeof(struct CMUnitTest)); num_found += 1; break; } + + if ((testmatch != NULL) && + (strstr(testmap[i].testname, testmatch) != NULL)) { + memcpy(&matching_tests[num_found], + &testmap[i].test, + sizeof(struct CMUnitTest)); + num_found += 1; + } + i += 1; } -- 2.13.2
Archive administrator: postmaster@lists.cynapses.org