[v8,1/4] app/dma-perf: add skip support

Message ID 5e281065a07a24e67c6954d2740626a3f45d4365.1700650397.git.gmuthukrishn@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series PCI Dev and SG copy support |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Gowrishankar Muthukrishnan Nov. 22, 2023, 11:06 a.m. UTC
  From: Amit Prakash Shukla <amitprakashs@marvell.com>

Add support to skip running a dma-perf test-case.

Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>
Acked-by: Anoob Joseph <anoobj@marvell.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
v8:
 - abstracted csv file write error log
---
 app/test-dma-perf/config.ini |  2 ++
 app/test-dma-perf/main.c     | 48 ++++++++++++++++++++++--------------
 app/test-dma-perf/main.h     |  1 +
 3 files changed, 32 insertions(+), 19 deletions(-)
  

Patch

diff --git a/app/test-dma-perf/config.ini b/app/test-dma-perf/config.ini
index b550f4b23f..4d59234b2a 100644
--- a/app/test-dma-perf/config.ini
+++ b/app/test-dma-perf/config.ini
@@ -36,6 +36,8 @@ 
 ; If you do not specify a result file, one will be generated with the same name as the configuration
 ; file, with the addition of "_result.csv" at the end.
 
+; "skip" To skip a test-case set skip to 1.
+
 [case1]
 type=DMA_MEM_COPY
 mem_size=10
diff --git a/app/test-dma-perf/main.c b/app/test-dma-perf/main.c
index 5f8bab8f45..33c3750bb1 100644
--- a/app/test-dma-perf/main.c
+++ b/app/test-dma-perf/main.c
@@ -86,6 +86,19 @@  output_header(uint32_t case_id, struct test_configure *case_cfg)
 	output_csv(true);
 }
 
+static int
+open_output_csv(const char *rst_path_ptr)
+{
+	fd = fopen(rst_path_ptr, "a");
+	if (!fd) {
+		printf("Open output CSV file error.\n");
+		return 1;
+	}
+	output_csv(true);
+	fclose(fd);
+	return 0;
+}
+
 static void
 run_test_case(struct test_configure *case_cfg)
 {
@@ -320,6 +333,7 @@  load_configs(const char *path)
 	const char *case_type;
 	const char *lcore_dma;
 	const char *mem_size_str, *buf_size_str, *ring_size_str, *kick_batch_str;
+	const char *skip;
 	int args_nr, nb_vp;
 	bool is_dma;
 
@@ -339,6 +353,13 @@  load_configs(const char *path)
 	for (i = 0; i < nb_sections; i++) {
 		snprintf(section_name, CFG_NAME_LEN, "case%d", i + 1);
 		test_case = &test_cases[i];
+
+		skip = rte_cfgfile_get_entry(cfgfile, section_name, "skip");
+		if (skip && (atoi(skip) == 1)) {
+			test_case->is_skip = true;
+			continue;
+		}
+
 		case_type = rte_cfgfile_get_entry(cfgfile, section_name, "type");
 		if (case_type == NULL) {
 			printf("Error: No case type in case %d, the test will be finished here.\n",
@@ -523,31 +544,20 @@  main(int argc, char *argv[])
 
 	printf("Running cases...\n");
 	for (i = 0; i < case_nb; i++) {
-		if (!test_cases[i].is_valid) {
-			printf("Invalid test case %d.\n\n", i + 1);
-			snprintf(output_str[0], MAX_OUTPUT_STR_LEN, "Invalid case %d\n", i + 1);
-
-			fd = fopen(rst_path_ptr, "a");
-			if (!fd) {
-				printf("Open output CSV file error.\n");
+		if (test_cases[i].is_skip) {
+			printf("Test case %d configured to be skipped.\n\n", i + 1);
+			snprintf(output_str[0], MAX_OUTPUT_STR_LEN, "Skip the test-case %d\n",
+				 i + 1);
+			if (open_output_csv(rst_path_ptr))
 				return 0;
-			}
-			output_csv(true);
-			fclose(fd);
 			continue;
 		}
 
-		if (test_cases[i].test_type == TEST_TYPE_NONE) {
-			printf("No valid test type in test case %d.\n\n", i + 1);
+		if (!test_cases[i].is_valid) {
+			printf("Invalid test case %d.\n\n", i + 1);
 			snprintf(output_str[0], MAX_OUTPUT_STR_LEN, "Invalid case %d\n", i + 1);
-
-			fd = fopen(rst_path_ptr, "a");
-			if (!fd) {
-				printf("Open output CSV file error.\n");
+			if (open_output_csv(rst_path_ptr))
 				return 0;
-			}
-			output_csv(true);
-			fclose(fd);
 			continue;
 		}
 
diff --git a/app/test-dma-perf/main.h b/app/test-dma-perf/main.h
index 62085e6e8f..32670151af 100644
--- a/app/test-dma-perf/main.h
+++ b/app/test-dma-perf/main.h
@@ -40,6 +40,7 @@  struct lcore_dma_map_t {
 
 struct test_configure {
 	bool is_valid;
+	bool is_skip;
 	uint8_t test_type;
 	const char *test_type_str;
 	uint16_t src_numa_node;