From: Ciara Power <ciara.power@intel.com>
To: dev@dpdk.org
Cc: declan.doherty@intel.com, Ciara Power <ciara.power@intel.com>
Subject: [dpdk-dev] [PATCH 1/6] app/test: refactor of unit test suite runner
Date: Tue, 16 Mar 2021 14:32:48 +0000 [thread overview]
Message-ID: <20210316143253.3849182-2-ciara.power@intel.com> (raw)
In-Reply-To: <20210316143253.3849182-1-ciara.power@intel.com>
Some small changes were made to the unit test suite runner for
readability and to enable reuse of some of the function in a later patch.
On test suite setup skip/fail, the loop to count testcases as
skipped/failed has been moved to another function.
This will allow for recursion in a later patch when nested sub-testsuites
are used.
The unit test suite runner accessed the list of testcases in the suite
structure every time the testcase was used. This is now replaced by a
testcase variable which improves readability.
The summary output now prints the suite name, this will be useful later
when multiple nested sub-testsuites are being run.
Signed-off-by: Ciara Power <ciara.power@intel.com>
---
app/test/test.c | 51 ++++++++++++++++++++++++++++++++-----------------
1 file changed, 33 insertions(+), 18 deletions(-)
diff --git a/app/test/test.c b/app/test/test.c
index 624dd48042..72768c8854 100644
--- a/app/test/test.c
+++ b/app/test/test.c
@@ -207,6 +207,23 @@ main(int argc, char **argv)
return ret;
}
+static void
+unit_test_suite_count_tcs_on_setup_fail(struct unit_test_suite *suite,
+ int test_success, unsigned int *total, unsigned int *skipped,
+ unsigned int *failed)
+{
+ struct unit_test_case tc;
+
+ tc = suite->unit_test_cases[*total];
+ while (tc.testcase) {
+ if (!tc.enabled || test_success == TEST_SKIPPED)
+ (*skipped)++;
+ else
+ (*failed)++;
+ (*total)++;
+ tc = suite->unit_test_cases[*total];
+ }
+}
int
unit_test_suite_runner(struct unit_test_suite *suite)
@@ -215,6 +232,7 @@ unit_test_suite_runner(struct unit_test_suite *suite)
unsigned int total = 0, executed = 0, skipped = 0;
unsigned int succeeded = 0, failed = 0, unsupported = 0;
const char *status;
+ struct unit_test_case tc;
if (suite->suite_name) {
printf(" + ------------------------------------------------------- +\n");
@@ -228,38 +246,35 @@ unit_test_suite_runner(struct unit_test_suite *suite)
* setup did not pass, so count all enabled tests and
* mark them as failed/skipped
*/
- while (suite->unit_test_cases[total].testcase) {
- if (!suite->unit_test_cases[total].enabled ||
- test_success == TEST_SKIPPED)
- skipped++;
- else
- failed++;
- total++;
- }
+ unit_test_suite_count_tcs_on_setup_fail(suite,
+ test_success, &total,
+ &skipped, &failed);
goto suite_summary;
}
}
printf(" + ------------------------------------------------------- +\n");
- while (suite->unit_test_cases[total].testcase) {
- if (!suite->unit_test_cases[total].enabled) {
+ tc = suite->unit_test_cases[total];
+ while (tc.testcase) {
+ if (!tc.enabled) {
skipped++;
total++;
+ tc = suite->unit_test_cases[total];
continue;
} else {
executed++;
}
/* run test case setup */
- if (suite->unit_test_cases[total].setup)
- test_success = suite->unit_test_cases[total].setup();
+ if (tc.setup)
+ test_success = tc.setup();
else
test_success = TEST_SUCCESS;
if (test_success == TEST_SUCCESS) {
/* run the test case */
- test_success = suite->unit_test_cases[total].testcase();
+ test_success = tc.testcase();
if (test_success == TEST_SUCCESS)
succeeded++;
else if (test_success == TEST_SKIPPED)
@@ -275,8 +290,8 @@ unit_test_suite_runner(struct unit_test_suite *suite)
}
/* run the test case teardown */
- if (suite->unit_test_cases[total].teardown)
- suite->unit_test_cases[total].teardown();
+ if (tc.teardown)
+ tc.teardown();
if (test_success == TEST_SUCCESS)
status = "succeeded";
@@ -287,10 +302,10 @@ unit_test_suite_runner(struct unit_test_suite *suite)
else
status = "failed";
- printf(" + TestCase [%2d] : %s %s\n", total,
- suite->unit_test_cases[total].name, status);
+ printf(" + TestCase [%2d] : %s %s\n", total, tc.name, status);
total++;
+ tc = suite->unit_test_cases[total];
}
/* Run test suite teardown */
@@ -301,7 +316,7 @@ unit_test_suite_runner(struct unit_test_suite *suite)
suite_summary:
printf(" + ------------------------------------------------------- +\n");
- printf(" + Test Suite Summary \n");
+ printf(" + Test Suite Summary : %s\n", suite->suite_name);
printf(" + Tests Total : %2d\n", total);
printf(" + Tests Skipped : %2d\n", skipped);
printf(" + Tests Executed : %2d\n", executed);
--
2.25.1
next prev parent reply other threads:[~2021-03-16 14:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-16 14:32 [dpdk-dev] [PATCH 0/6] test: refactor crypto unit test framework Ciara Power
2021-03-16 14:32 ` Ciara Power [this message]
2021-03-31 14:42 ` [dpdk-dev] [PATCH 1/6] app/test: refactor of unit test suite runner Aaron Conole
2021-03-16 14:32 ` [dpdk-dev] [PATCH 2/6] test: introduce parent testsuite format Ciara Power
2021-03-31 14:42 ` Aaron Conole
2021-03-16 14:32 ` [dpdk-dev] [PATCH 3/6] test/crypto: refactor to use sub-testsuites Ciara Power
2021-03-16 14:32 ` [dpdk-dev] [PATCH 4/6] test/crypto: move testsuite params to header file Ciara Power
2021-03-16 14:32 ` [dpdk-dev] [PATCH 5/6] test/crypto: dynamically build blockcipher suite Ciara Power
2021-03-16 14:32 ` [dpdk-dev] [PATCH 6/6] doc: add unit test suite change to release notes Ciara Power
2021-03-30 16:15 ` [dpdk-dev] [PATCH 0/6] test: refactor crypto unit test framework Doherty, Declan
2021-03-31 14:43 ` Aaron Conole
2021-04-02 14:32 ` Power, Ciara
2021-04-01 3:13 ` Ruifeng Wang
2021-04-02 14:29 ` Power, Ciara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210316143253.3849182-2-ciara.power@intel.com \
--to=ciara.power@intel.com \
--cc=declan.doherty@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).