Skip to contentSkip to conversation

accel-config/test: Split shared/dedicated wq

PATCH In review ramesh.thomas at intel.com 2 participants 5 messages Aug 12, 2021 – Aug 17, 2021

lore
Share & tools
lore

ramesh.thomas at intel.com

#0 lore raw

cover accel-config/test: Split shared/dedicated wq

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Shared and Dedicated wqs require different handling so split their configuration functions. Split tests that call them into 2. Add an option for tests to return a status indicating feature not supported which will result in *skipped* being printed in their status. Skipping test this way will not abort the entire unit test.

Ramesh Thomas (3):
accel-config/test: Add support for skipping tests accel-config/test: Split config func to handle sh and ded wqs accel-config/test: Skip shared wq config test if shm support

 test/libaccfg.c | 100 +++++++++++++++++++++++++++++++++++-------------
 1 file changed, 74 insertions(+), 26 deletions(-)
Signature · 1 line
2.26.3
#1 lore raw

PATCH 1/3 accel-config/test: Add support for skipping tests

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Add option for tests to skip individual tests without aborting entire unit test if a required feature is absent.

Following status will be printed for each test:
-passed
-failed
-disabled
-skipped

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 test/libaccfg.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
test/libaccfg.c +12 -9
index 516adbc..44e10df 100644
@@ -807,6 +807,9 @@ static int test_mdev_1swq(struct accfg_ctx *ctx)
 {
 	int rc = 0;
 
+	if (mdev_disabled)
+		return -EOPNOTSUPP;
+
 	rc = device_test_reset(ctx, test_ctx.device, false);
 	if (rc)
 		return rc;
@@ -840,6 +843,9 @@ static int test_mdev_1dwq(struct accfg_ctx *ctx)
 {
 	int rc = 0;
 
+	if (mdev_disabled)
+		return -EOPNOTSUPP;
+
 	rc = device_test_reset(ctx, test_ctx.device, false);
 	if (rc)
 		return rc;
@@ -873,7 +879,6 @@ struct _test_case {
 	do_test_fn test_fn;
 	char *desc;
 	bool enabled;
-	bool mdev;
 };
 
 static struct _test_case test_cases[] = {
@@ -881,31 +886,26 @@ static struct _test_case test_cases[] = {
 		.test_fn = test_config,
 		.desc = "set and get configurations",
 		.enabled = true,
-		.mdev = false,
 	},
 	{
 		.test_fn = test_max_wq_size,
 		.desc = "max wq size",
 		.enabled = true,
-		.mdev = false,
 	},
 	{
 		.test_fn = test_wq_boundary_conditions,
 		.desc = "wq boundary conditions",
 		.enabled = true,
-		.mdev = false,
 	},
 	{
 		.test_fn = test_mdev_1swq,
 		.desc = "1swq type mdev creation and removal",
 		.enabled = true,
-		.mdev = true,
 	},
 	{
 		.test_fn = test_mdev_1dwq,
 		.desc = "1dwq type mdev creation and removal",
 		.enabled = true,
-		.mdev = true,
 	},
 };
 
@@ -1009,11 +1009,14 @@ int test_libaccfg(int loglevel, struct accfg_test *test,
 			continue;
 		}
 
-		if (test_cases[i].mdev && mdev_disabled)
-			continue;
-
 		printf("\nRunning accfg-test%d: %s\n", i, test_cases[i].desc);
 		err = test_cases[i].test_fn(ctx);
+		if (err == -EOPNOTSUPP) {
+			fprintf(stderr,
+				"accfg-test%d *skipped*: required feature not found\n",
+				i);
+			continue;
+		}
 		if (err < 0) {
 			fprintf(stderr, "accfg-test%d *failed*: %d\n", i, err);
 			break;
Signature · 1 line
2.26.3
#2 lore raw

PATCH 2/3 accel-config/test: Split config func to handle sh and ded wqs

In reply to ramesh.thomas at intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Split config functions and related tests into 2 functions handling shared and dedicated wqs separately.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 test/libaccfg.c | 69 +++++++++++++++++++++++++++++++++++++------------
 1 file changed, 53 insertions(+), 16 deletions(-)
test/libaccfg.c +53 -16
index 44e10df..9ac4bcd 100644
@@ -394,7 +394,8 @@ static void test_cleanup(struct accfg_ctx *ctx)
 		device_test_reset(ctx, device, true);
 }
 
-static int set_config(struct accfg_ctx *ctx, struct config_test_ctx *ct_ctx)
+static int set_config(struct accfg_ctx *ctx, struct config_test_ctx *ct_ctx,
+		char *wq_mode)
 {
 	int rc = 0;
 	struct accfg_device *device;
@@ -422,6 +423,9 @@ static int set_config(struct accfg_ctx *ctx, struct config_test_ctx *ct_ctx)
 	}
 
 	for (i = 0; i < 4; i++) {
+		if (wq_mode && strcmp(ct_ctx->wq_param[i]->mode, wq_mode))
+			continue;
+
 		wq = ct_ctx->wq[i];
 		printf("configuring wq %s\n", accfg_wq_get_devname(wq));
 		rc = config_wq(ctx, device, wq, ct_ctx->wq_param[i]);
@@ -444,7 +448,8 @@ static int set_config(struct accfg_ctx *ctx, struct config_test_ctx *ct_ctx)
 	return 0;
 }
 
-static int check_config(struct accfg_ctx *ctx, struct config_test_ctx *ct_ctx)
+static int check_config(struct accfg_ctx *ctx, struct config_test_ctx *ct_ctx,
+		char *wq_mode)
 {
 	int rc = 0;
 	struct accfg_device *device;
@@ -472,6 +477,9 @@ static int check_config(struct accfg_ctx *ctx, struct config_test_ctx *ct_ctx)
 	}
 
 	for (i = 0; i < 4; i++) {
+		if (wq_mode && strcmp(ct_ctx->wq_param[i]->mode, wq_mode))
+			continue;
+
 		wq = ct_ctx->wq[i];
 		printf("check wq %s\n", accfg_wq_get_devname(wq));
 		rc = check_wq(ctx, device, wq, ct_ctx->wq_param[i]);
@@ -519,17 +527,17 @@ static int set_exceed_config(struct accfg_ctx *ctx,
 	}
 
 	/* configure 2 wqs with some wq sizes */
-	wq = ct_ctx->wq[0];
+	wq = ct_ctx->wq[1];
 	printf("configuring wq %s\n", accfg_wq_get_devname(wq));
-	rc = config_wq(ctx, device, wq, ct_ctx->wq_param[0]);
+	rc = config_wq(ctx, device, wq, ct_ctx->wq_param[1]);
 	if (rc) {
 		fprintf(stderr, "config wq failed\n");
 		return rc;
 	}
 
-	wq = ct_ctx->wq[2];
+	wq = ct_ctx->wq[3];
 	printf("configuring wq %s\n", accfg_wq_get_devname(wq));
-	rc = config_wq(ctx, device, wq, ct_ctx->wq_param[2]);
+	rc = config_wq(ctx, device, wq, ct_ctx->wq_param[3]);
 	if (rc) {
 		fprintf(stderr, "config wq failed\n");
 		return rc;
@@ -561,7 +569,7 @@ static int wq_bounds_test(struct accfg_ctx *ctx, struct config_test_ctx *ct_ctx)
 
 	device = ct_ctx->device;
 	group = ct_ctx->group[0];
-	wq = ct_ctx->wq[0];
+	wq = ct_ctx->wq[1];
 
 	printf("configure device %s, group %s, wq %s for bounds test\n",
 			accfg_device_get_devname(device),
@@ -580,7 +588,7 @@ static int wq_bounds_test(struct accfg_ctx *ctx, struct config_test_ctx *ct_ctx)
 		return rc;
 	}
 
-	rc = config_wq(ctx, device, wq, ct_ctx->wq_param[0]);
+	rc = config_wq(ctx, device, wq, ct_ctx->wq_param[1]);
 	if (rc) {
 		fprintf(stderr, "config wq failed\n");
 		return rc;
@@ -659,8 +667,8 @@ static int fill_test_ctx(struct accfg_ctx *ctx)
 	return 0;
 }
 
-/* test the set and get libaccfg functions */
-static int test_config(struct accfg_ctx *ctx)
+/* test set and get libaccfg functions for shared wqs */
+static int test_config_shared(struct accfg_ctx *ctx)
 {
 	int rc = 0;
 
@@ -668,11 +676,35 @@ static int test_config(struct accfg_ctx *ctx)
 	if (rc)
 		return rc;
 
-	rc = set_config(ctx, &test_ctx);
+	rc = set_config(ctx, &test_ctx, "shared");
 	if (rc)
 		return rc;
 
-	rc = check_config(ctx, &test_ctx);
+	rc = check_config(ctx, &test_ctx, "shared");
+	if (rc)
+		return rc;
+
+	rc = device_test_reset(ctx, test_ctx.device, false);
+	if (rc)
+		return rc;
+
+	return 0;
+}
+
+/* test set and get libaccfg functions for dedicated wqs */
+static int test_config_dedicated(struct accfg_ctx *ctx)
+{
+	int rc = 0;
+
+	rc = device_test_reset(ctx, test_ctx.device, false);
+	if (rc)
+		return rc;
+
+	rc = set_config(ctx, &test_ctx, "dedicated");
+	if (rc)
+		return rc;
+
+	rc = check_config(ctx, &test_ctx, "dedicated");
 	if (rc)
 		return rc;
 
@@ -814,7 +846,7 @@ static int test_mdev_1swq(struct accfg_ctx *ctx)
 	if (rc)
 		return rc;
 
-	rc = set_config(ctx, &test_ctx);
+	rc = set_config(ctx, &test_ctx, NULL);
 	if (rc)
 		return rc;
 
@@ -850,7 +882,7 @@ static int test_mdev_1dwq(struct accfg_ctx *ctx)
 	if (rc)
 		return rc;
 
-	rc = set_config(ctx, &test_ctx);
+	rc = set_config(ctx, &test_ctx, NULL);
 	if (rc)
 		return rc;
 
@@ -883,8 +915,13 @@ struct _test_case {
 
 static struct _test_case test_cases[] = {
 	{
-		.test_fn = test_config,
-		.desc = "set and get configurations",
+		.test_fn = test_config_shared,
+		.desc = "set and get configurations for shared wqs",
+		.enabled = true,
+	},
+	{
+		.test_fn = test_config_dedicated,
+		.desc = "set and get configurations for dedicated wqs",
 		.enabled = true,
 	},
 	{
Signature · 1 line
2.26.3
#3 lore raw

PATCH 3/3 accel-config/test: Skip shared wq config test if shm support

In reply to ramesh.thomas at intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Skip config tests that use shared wqs if shared memory support is not available.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 test/libaccfg.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
test/libaccfg.c +10 -2
index 9ac4bcd..5a17650 100644
@@ -244,7 +244,9 @@ static int config_wq(struct accfg_ctx *ctx, struct accfg_device *device,
 {
 	int rc = 0;
 
-	SET_ERR(rc, accfg_wq_set_str_mode(wq, wq_param->mode));
+	rc = accfg_wq_set_str_mode(wq, wq_param->mode);
+	if (rc)
+		return rc;
 	SET_ERR(rc, accfg_wq_set_str_type(wq, wq_param->type));
 	SET_ERR(rc, accfg_wq_set_str_name(wq, wq_param->name));
 	SET_ERR(rc, accfg_wq_set_size(wq, wq_param->wq_size));
@@ -677,8 +679,14 @@ static int test_config_shared(struct accfg_ctx *ctx)
 		return rc;
 
 	rc = set_config(ctx, &test_ctx, "shared");
-	if (rc)
+	if (rc) {
+		if (rc == -EINVAL) {
+			fprintf(stderr, "shared wq support not available\n");
+			device_test_reset(ctx, test_ctx.device, false);
+			return -EOPNOTSUPP;
+		}
 		return rc;
+	}
 
 	rc = check_config(ctx, &test_ctx, "shared");
 	if (rc)
Signature · 1 line
2.26.3
Reviewed-by on the v1 series
#4 lore raw
In reply to ramesh.thomas at intel.com
Quoted 8 lines · ramesh.thomas(a)intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Shared and Dedicated wqs require different handling so split their configuration functions. Split tests that call them into 2. Add an option for tests to return a status indicating feature not supported which will result in *skipped* being printed in their status. Skipping test this way will not abort the entire unit test.

Quoted 7 lines

Ramesh Thomas (3):
accel-config/test: Add support for skipping tests accel-config/test: Split config func to handle sh and ded wqs accel-config/test: Skip shared wq config test if shm support

  test/libaccfg.c | 100 +++++++++++++++++++++++++++++++++++-------------
  1 file changed, 74 insertions(+), 26 deletions(-)
Reviewed-by Dave Jiang <dave.jiang(a)intel.com>