[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/5] pkd: refactor -t testname lookup-by-name
[Thread Prev] | [Thread Next]
- Subject: [PATCH 4/5] pkd: refactor -t testname lookup-by-name
- From: Jon Simons <jon@xxxxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Wed, 12 Jul 2017 15:46:40 -0700
- To: libssh@xxxxxxxxxx
From 079585c51979c247cc195b0fc99bc374f926e4b4 Mon Sep 17 00:00:00 2001 From: Jon Simons <jon@xxxxxxxxxxxxx> Date: Wed, 12 Jul 2017 13:27:46 -0700 Subject: [PATCH 4/5] pkd: refactor -t testname lookup-by-name Signed-off-by: Jon Simons <jon@xxxxxxxxxxxxx> --- tests/pkd/pkd_hello.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/pkd/pkd_hello.c b/tests/pkd/pkd_hello.c index e4e3993b..de3c4768 100644 --- a/tests/pkd/pkd_hello.c +++ b/tests/pkd/pkd_hello.c @@ -482,19 +482,24 @@ static int pkd_run_tests(void) { rc = _cmocka_run_group_tests("all tests", all_tests, tindex, NULL, NULL); } else { int i = 0; - const struct CMUnitTest *found = NULL; + int num_found = 0; const char *testname = pkd_dargs.opts.testname; + struct CMUnitTest matching_tests[sizeof(all_tests)]; + memset(&matching_tests[0], 0x0, sizeof(matching_tests)); + while (testmap[i].testname != NULL) { - if (strcmp(testmap[i].testname, testname) == 0) { - found = &testmap[i].test; + if ((testname != NULL) && + (strcmp(testmap[i].testname, testname) == 0)) { + memcpy(&matching_tests[0], &testmap[i].test, sizeof(struct CMUnitTest)); + num_found += 1; break; } i += 1; } - if (found != NULL) { - rc = _cmocka_run_group_tests("found", found, 1, NULL, NULL); + if (num_found > 0) { + rc = _cmocka_run_group_tests("found", matching_tests, num_found, NULL, NULL); } else { fprintf(stderr, "Did not find test '%s'\n", testname); } -- 2.13.2
Archive administrator: postmaster@lists.cynapses.org