DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ciara Power <ciara.power@intel.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, declan.doherty@intel.com,
	gakhil@marvell.com, aconole@redhat.com, hemant.agrawal@nxp.com,
	anoobj@marvell.com, ruifeng.wang@arm.com, asomalap@amd.com,
	ajit.khaparde@broadcom.com, g.singh@nxp.com,
	Ciara Power <ciara.power@intel.com>
Subject: [dpdk-dev] [PATCH v3 2/7] test: introduce parent testsuite format
Date: Fri, 23 Apr 2021 16:18:15 +0000	[thread overview]
Message-ID: <20210423161820.2135053-3-ciara.power@intel.com> (raw)
In-Reply-To: <20210423161820.2135053-1-ciara.power@intel.com>

The current structure for unit testing only allows for running a
test suite with nested test cases. This means all test cases for an
autotest must be in one suite, which is not ideal.
For example, in some cases we may want to run multiple lists of test
cases that each require different setup, so should be in separate suites.

The unit test suite struct is modified to hold a pointer to a list of
sub-testsuite pointers, along with the list of testcases as before.

Signed-off-by: Ciara Power <ciara.power@intel.com>

---
v3:
  - Added condition check to macro that loops sub-testsuites.
  - Changed execution to allow for mixture of sub-testsuites and
    testcases, by removing the if/else condition.
  - Moved testcase execution above sub-testsuite execution,
    to improve output readability.
v2:
  - Added macro to loop sub-testsuites.
  - Added sub-testsuite summary detail.
---
 app/test/test.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++---
 app/test/test.h |  1 +
 2 files changed, 68 insertions(+), 3 deletions(-)

diff --git a/app/test/test.c b/app/test/test.c
index 2fb99d0855..ac0a66392a 100644
--- a/app/test/test.c
+++ b/app/test/test.c
@@ -41,6 +41,12 @@ extern cmdline_parse_ctx_t main_ctx[];
 		suite->unit_test_cases[iter].testcase;			\
 		iter++, case = suite->unit_test_cases[iter])
 
+#define FOR_EACH_SUITE_TESTSUITE(iter, suite, sub_ts)			\
+	for (iter = 0, sub_ts = suite->unit_test_suites ?		\
+		suite->unit_test_suites[0]:NULL; sub_ts &&		\
+		suite->unit_test_suites[iter]->suite_name != NULL;	\
+		iter++, sub_ts = suite->unit_test_suites[iter])
+
 const char *prgname; /* to be set to argv[0] */
 
 static const char *recursive_call; /* used in linux for MP and other tests */
@@ -241,11 +247,26 @@ main(int argc, char **argv)
 
 static void
 unit_test_suite_count_tcs_on_setup_fail(struct unit_test_suite *suite,
-		int test_success)
+		int test_success, unsigned int *sub_ts_failed,
+		unsigned int *sub_ts_skipped, unsigned int *sub_ts_total)
 {
 	struct unit_test_case tc;
+	struct unit_test_suite *ts;
 	int i;
 
+	FOR_EACH_SUITE_TESTSUITE(i, suite, ts) {
+		unit_test_suite_count_tcs_on_setup_fail(
+			ts, test_success, sub_ts_failed,
+			sub_ts_skipped, sub_ts_total);
+		suite->total += ts->total;
+		suite->failed += ts->failed;
+		suite->skipped += ts->skipped;
+		if (ts->failed)
+			(*sub_ts_failed)++;
+		else
+			(*sub_ts_skipped)++;
+		(*sub_ts_total)++;
+	}
 	FOR_EACH_SUITE_TESTCASE(i, suite, tc) {
 		suite->total++;
 		if (!tc.enabled || test_success == TEST_SKIPPED)
@@ -258,6 +279,11 @@ unit_test_suite_count_tcs_on_setup_fail(struct unit_test_suite *suite,
 static void
 unit_test_suite_reset_counts(struct unit_test_suite *suite)
 {
+	struct unit_test_suite *ts;
+	int i;
+
+	FOR_EACH_SUITE_TESTSUITE(i, suite, ts)
+		unit_test_suite_reset_counts(ts);
 	suite->total = 0;
 	suite->executed = 0;
 	suite->succeeded = 0;
@@ -269,9 +295,12 @@ unit_test_suite_reset_counts(struct unit_test_suite *suite)
 int
 unit_test_suite_runner(struct unit_test_suite *suite)
 {
-	int test_success;
+	int test_success, i, ret;
 	const char *status;
 	struct unit_test_case tc;
+	struct unit_test_suite *ts;
+	unsigned int sub_ts_succeeded = 0, sub_ts_failed = 0;
+	unsigned int sub_ts_skipped = 0, sub_ts_total = 0;
 
 	unit_test_suite_reset_counts(suite);
 
@@ -288,7 +317,8 @@ unit_test_suite_runner(struct unit_test_suite *suite)
 			 * mark them as failed/skipped
 			 */
 			unit_test_suite_count_tcs_on_setup_fail(suite,
-					test_success);
+					test_success, &sub_ts_failed,
+					&sub_ts_skipped, &sub_ts_total);
 			goto suite_summary;
 		}
 	}
@@ -342,6 +372,23 @@ unit_test_suite_runner(struct unit_test_suite *suite)
 		printf(" + TestCase [%2d] : %s %s\n", suite->total,
 				tc.name, status);
 	}
+	FOR_EACH_SUITE_TESTSUITE(i, suite, ts) {
+		ret = unit_test_suite_runner(ts);
+		if (ret == TEST_SUCCESS)
+			sub_ts_succeeded++;
+		else if (ret == TEST_SKIPPED)
+			sub_ts_skipped++;
+		else
+			sub_ts_failed++;
+		sub_ts_total++;
+
+		suite->total += ts->total;
+		suite->succeeded += ts->succeeded;
+		suite->failed += ts->failed;
+		suite->skipped += ts->skipped;
+		suite->unsupported += ts->unsupported;
+		suite->executed += ts->executed;
+	}
 
 	/* Run test suite teardown */
 	if (suite->teardown)
@@ -352,6 +399,23 @@ unit_test_suite_runner(struct unit_test_suite *suite)
 suite_summary:
 	printf(" + ------------------------------------------------------- +\n");
 	printf(" + Test Suite Summary : %s\n", suite->suite_name);
+	printf(" + ------------------------------------------------------- +\n");
+
+	FOR_EACH_SUITE_TESTSUITE(i, suite, ts)
+		printf(" + %s : %d/%d passed, %d/%d skipped, "
+			"%d/%d failed, %d/%d unsupported\n", ts->suite_name,
+			ts->succeeded, ts->total, ts->skipped, ts->total,
+			ts->failed, ts->total, ts->unsupported, ts->total);
+
+	if (suite->unit_test_suites) {
+		printf(" + ------------------------------------------------------- +\n");
+		printf(" + Sub Testsuites Total :     %2d\n", sub_ts_total);
+		printf(" + Sub Testsuites Skipped :   %2d\n", sub_ts_skipped);
+		printf(" + Sub Testsuites Passed :    %2d\n", sub_ts_succeeded);
+		printf(" + Sub Testsuites Failed :    %2d\n", sub_ts_failed);
+		printf(" + ------------------------------------------------------- +\n");
+	}
+
 	printf(" + Tests Total :       %2d\n", suite->total);
 	printf(" + Tests Skipped :     %2d\n", suite->skipped);
 	printf(" + Tests Executed :    %2d\n", suite->executed);
diff --git a/app/test/test.h b/app/test/test.h
index 55f2850fed..f277df7c9d 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -144,6 +144,7 @@ struct unit_test_suite {
 	unsigned int skipped;
 	unsigned int failed;
 	unsigned int unsupported;
+	struct unit_test_suite **unit_test_suites;
 	struct unit_test_case unit_test_cases[];
 };
 
-- 
2.25.1


  parent reply	other threads:[~2021-04-23 16:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-23 16:18 [dpdk-dev] [PATCH v3 0/7] test: refactor crypto unit test framework Ciara Power
2021-04-23 16:18 ` [dpdk-dev] [PATCH v3 1/7] app/test: refactor of unit test suite runner Ciara Power
2021-04-23 16:18 ` Ciara Power [this message]
2021-04-23 16:32   ` [dpdk-dev] [PATCH v3 2/7] test: introduce parent testsuite format Aaron Conole
2021-04-23 16:18 ` [dpdk-dev] [PATCH v3 3/7] test/crypto: refactor to use sub-testsuites Ciara Power
2021-04-30 20:59   ` Doherty, Declan
2021-04-23 16:18 ` [dpdk-dev] [PATCH v3 4/7] test/crypto: replace unsupported with skipped Ciara Power
2021-04-23 16:18 ` [dpdk-dev] [PATCH v3 5/7] test/crypto: move testsuite params to header file Ciara Power
2021-04-23 16:18 ` [dpdk-dev] [PATCH v3 6/7] test/crypto: fix return value on test skipped Ciara Power
2021-04-23 16:18 ` [dpdk-dev] [PATCH v3 7/7] test/crypto: dynamically build blockcipher suite Ciara Power
2021-04-25  9:24 ` [dpdk-dev] [PATCH v3 0/7] test: refactor crypto unit test framework Ruifeng Wang
2021-04-30 21:00 ` Doherty, Declan
2021-05-05 10:41   ` Hemant Agrawal
2021-05-05 12:20     ` Hemant Agrawal
2021-05-08 15:38 ` [dpdk-dev] [EXT] " Akhil Goyal

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=20210423161820.2135053-3-ciara.power@intel.com \
    --to=ciara.power@intel.com \
    --cc=aconole@redhat.com \
    --cc=ajit.khaparde@broadcom.com \
    --cc=anoobj@marvell.com \
    --cc=asomalap@amd.com \
    --cc=declan.doherty@intel.com \
    --cc=dev@dpdk.org \
    --cc=g.singh@nxp.com \
    --cc=gakhil@marvell.com \
    --cc=hemant.agrawal@nxp.com \
    --cc=ruifeng.wang@arm.com \
    --cc=thomas@monjalon.net \
    /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).