Skip to contentSkip to conversation

app/acl: add script for automate testing

PATCH In review Konstantin Ananyev 2 participants 6 messages May 18, 2021 – Jul 30, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 app/acl: add script for automate testing

The purpose of this script is to help automate ACL library functional testing using test-acl app.
Sample input files are also provided.

---
 app/test-acl/input/acl1v4_5_rule  |  5 ++
 app/test-acl/input/acl1v4_5_trace |  5 ++
 app/test-acl/input/acl1v6_1_rule  |  1 +
 app/test-acl/input/acl1v6_1_trace |  2 +
 app/test-acl/test-acl.sh          | 92 +++++++++++++++++++++++++++++++
 5 files changed, 105 insertions(+)
 create mode 100644 app/test-acl/input/acl1v4_5_rule
 create mode 100644 app/test-acl/input/acl1v4_5_trace
 create mode 100644 app/test-acl/input/acl1v6_1_rule
 create mode 100644 app/test-acl/input/acl1v6_1_trace
 create mode 100644 app/test-acl/test-acl.sh
app/test-acl/input/acl1v4_5_rule new file +5 -0
new file mode 100644
index 0000000000..45301f3a3d
@@ -0,0 +1,5 @@
[email protected]/32	2.1.0.0/16	0 : 65535	0 : 65535 0/0
[email protected]/24	2.1.1.0/24	0 : 65535	0 : 65535 0/0
[email protected]/16	16.32.1.1/32	0 : 65535	0 : 65535 0/0
[email protected]/16	16.32.1.0/24	1000 : 2000	0 : 65535 0/0
[email protected]/24	16.32.1.0/24	0 : 65535	0 : 65535 0/0
app/test-acl/input/acl1v4_5_trace new file +5 -0
new file mode 100644
index 0000000000..bfbcd31f88
@@ -0,0 +1,5 @@
+0x10200101 0x02010304 100 100 6 0
+0x10200103 0x02010104 100 100 6 1
+0x02010304 0x10200101 100 100 6 2
+0x02010104 0x10200103 100 100 6 4
+0x02010104 0x10200101 100 100 6 2
app/test-acl/input/acl1v6_1_rule new file +1 -0
new file mode 100644
index 0000000000..2ea9856b27
@@ -0,0 +1 @@
+@9baa:cead:8000:0000:e300:00ff:fe04:c5a8/33	d1b5:2feb:0000:0000:6600:00ff:fed9:aeaa/33	0 : 65535	1526 : 1526	0x00/0x00
app/test-acl/input/acl1v6_1_trace new file +2 -0
new file mode 100644
index 0000000000..6e86741edf
@@ -0,0 +1,2 @@
+9baa:cead:8000:0000:0000:0000:0000:0000 d1b5:2feb:0000:0000:0000:0000:0000:0000 37826 1526 6 0
+2eba:cc41:0000:0000:0000:0000:0000:0000 16ef:6cdb:0000:0000:0000:0000:0000:0000 25946 1525 0 4294967295
app/test-acl/test-acl.sh new file +92 -0

92 lines not on this page · raw message

Signature · 1 line
2.26.3
#1 lore raw

18/05/2021 13:26, Konstantin Ananyev:

Quoted 5 lines

The purpose of this script is to help automate ACL library functional testing using test-acl app.
Sample input files are also provided.

The input files make the script devtools/check-spdx-tag.sh failing.

#2 lore raw

v2 cover app/acl: help to automate testing

In reply to Konstantin Ananyev

The purpose of this series is to help automate ACL library functional testing using test-acl app.
First patch adds into test-acl ability to skip comment/empty lines. Second patch adds script for automate testing.
Sample input files are also provided.

v2:
- Added ability to skip comment/empty lines
- Fixed check-spdx-tag.sh complains (Thomas)

Konstantin Ananyev (2):
app/acl: allow comment and empty lines
app/acl: add script for automate testing

 app/test-acl/input/acl1v4_5_rule  |  7 +++
 app/test-acl/input/acl1v4_5_trace |  7 +++
 app/test-acl/input/acl1v6_1_rule  |  3 +
 app/test-acl/input/acl1v6_1_trace |  4 ++
 app/test-acl/main.c               | 51 ++++++++++++++---
 app/test-acl/test-acl.sh          | 94 +++++++++++++++++++++++++++++++
 6 files changed, 157 insertions(+), 9 deletions(-)
 create mode 100644 app/test-acl/input/acl1v4_5_rule
 create mode 100644 app/test-acl/input/acl1v4_5_trace
 create mode 100644 app/test-acl/input/acl1v6_1_rule
 create mode 100644 app/test-acl/input/acl1v6_1_trace
 create mode 100644 app/test-acl/test-acl.sh
Signature · 1 line
2.26.3
#3 lore raw

PATCH v2 1/2 app/acl: allow comment and empty lines

Allow comment (lines starting with '#') and empty lines in input (rules, traces) files. These lines will be just skipped and shouldn't affect the result anyhow.

---
 app/test-acl/main.c | 51 +++++++++++++++++++++++++++++++++++++--------
 1 file changed, 42 insertions(+), 9 deletions(-)
app/test-acl/main.c +42 -9
index 2cb2fe2579..c2de18770d 100644
@@ -48,6 +48,8 @@
 
 #define	RULE_NUM		0x10000
 
+#define COMMENT_LEAD_CHAR	'#'
+
 enum {
 	DUMP_NONE,
 	DUMP_SEARCH,
@@ -472,13 +474,28 @@ parse_cb_ipv6_trace(char *str, struct ipv6_5tuple *v)
 	return 0;
 }
 
+/* Bypass comment and empty lines */
+static int
+skip_line(const char *buf)
+{
+	uint32_t i;
+
+	for (i = 0; isspace(buf[i]) != 0; i++)
+		;
+
+	if (buf[i] == 0 || buf[i] == COMMENT_LEAD_CHAR)
+		return 1;
+
+	return 0;
+}
+
 static void
 tracef_init(void)
 {
 	static const char name[] = APP_NAME;
 	FILE *f;
 	size_t sz;
-	uint32_t n;
+	uint32_t i, k, n;
 	struct ipv4_5tuple *v;
 	struct ipv6_5tuple *w;
 
@@ -497,27 +514,36 @@ tracef_init(void)
 
 	v = config.traces;
 	w = config.traces;
-	for (n = 0; n != config.nb_traces; n++) {
+	k = 0;
+	n = 0;
+	for (i = 0; n != config.nb_traces; i++) {
 
 		if (fgets(line, sizeof(line), f) == NULL)
 			break;
 
+		if (skip_line(line) != 0) {
+			k++;
+			continue;
+		}
+
+		n = i - k;
+
 		if (config.ipv6) {
 			if (parse_cb_ipv6_trace(line, w + n) != 0)
 				rte_exit(EXIT_FAILURE,
 					"%s: failed to parse ipv6 trace "
 					"record at line %u\n",
-					config.trace_file, n + 1);
+					config.trace_file, i + 1);
 		} else {
 			if (parse_cb_ipv4_trace(line, v + n) != 0)
 				rte_exit(EXIT_FAILURE,
 					"%s: failed to parse ipv4 trace "
 					"record at line %u\n",
-					config.trace_file, n + 1);
+					config.trace_file, i + 1);
 		}
 	}
 
-	config.used_traces = n;
+	config.used_traces = i - k;
 	fclose(f);
 }
 
@@ -727,20 +753,27 @@ static int
 add_cb_rules(FILE *f, struct rte_acl_ctx *ctx)
 {
 	int rc;
-	uint32_t n;
+	uint32_t i, k, n;
 	struct acl_rule v;
 	parse_5tuple parser;
 
 	memset(&v, 0, sizeof(v));
 	parser = (config.ipv6 != 0) ? parse_cb_ipv6_rule : parse_cb_ipv4_rule;
 
-	for (n = 1; fgets(line, sizeof(line), f) != NULL; n++) {
+	k = 0;
+	for (i = 1; fgets(line, sizeof(line), f) != NULL; i++) {
+
+		if (skip_line(line) != 0) {
+			k++;
+			continue;
+		}
 
+		n = i - k;
 		rc = parser(line, &v);
 		if (rc != 0) {
 			RTE_LOG(ERR, TESTACL, "line %u: parse_cb_ipv4vlan_rule"
 				" failed, error code: %d (%s)\n",
-				n, rc, strerror(-rc));
+				i, rc, strerror(-rc));
 			return rc;
 		}
 
@@ -753,7 +786,7 @@ add_cb_rules(FILE *f, struct rte_acl_ctx *ctx)
 		if (rc != 0) {
 			RTE_LOG(ERR, TESTACL, "line %u: failed to add rules "
 				"into ACL context, error code: %d (%s)\n",
-				n, rc, strerror(-rc));
+				i, rc, strerror(-rc));
 			return rc;
 		}
 	}
Signature · 1 line
2.26.3
#4 lore raw

PATCH v2 2/2 app/acl: add script for automate testing

In reply to Konstantin Ananyev

The purpose of this script is to help automate ACL library functional testing using test-acl app.
Sample input files are also provided.

---
 app/test-acl/input/acl1v4_5_rule  |  7 +++
 app/test-acl/input/acl1v4_5_trace |  7 +++
 app/test-acl/input/acl1v6_1_rule  |  3 +
 app/test-acl/input/acl1v6_1_trace |  4 ++
 app/test-acl/test-acl.sh          | 94 +++++++++++++++++++++++++++++++
 5 files changed, 115 insertions(+)
 create mode 100644 app/test-acl/input/acl1v4_5_rule
 create mode 100644 app/test-acl/input/acl1v4_5_trace
 create mode 100644 app/test-acl/input/acl1v6_1_rule
 create mode 100644 app/test-acl/input/acl1v6_1_trace
 create mode 100644 app/test-acl/test-acl.sh
app/test-acl/input/acl1v4_5_rule new file +7 -0
new file mode 100644
index 0000000000..ae5b7826c0
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+
[email protected]/32	2.1.0.0/16	0 : 65535	0 : 65535 0/0
[email protected]/24	2.1.1.0/24	0 : 65535	0 : 65535 0/0
[email protected]/16	16.32.1.1/32	0 : 65535	0 : 65535 0/0
[email protected]/16	16.32.1.0/24	1000 : 2000	0 : 65535 0/0
[email protected]/24	16.32.1.0/24	0 : 65535	0 : 65535 0/0
app/test-acl/input/acl1v4_5_trace new file +7 -0
new file mode 100644
index 0000000000..80a988c280
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: BSD-3-Clause
+
+0x10200101 0x02010304 100 100 6 0
+0x10200103 0x02010104 100 100 6 1
+0x02010304 0x10200101 100 100 6 2
+0x02010104 0x10200103 100 100 6 4
+0x02010104 0x10200101 100 100 6 2
app/test-acl/input/acl1v6_1_rule new file +3 -0
new file mode 100644
index 0000000000..3e03124186
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: BSD-3-Clause
+
+@9baa:cead:8000:0000:e300:00ff:fe04:c5a8/33	d1b5:2feb:0000:0000:6600:00ff:fed9:aeaa/33	0 : 65535	1526 : 1526	0x00/0x00
app/test-acl/input/acl1v6_1_trace new file +4 -0
new file mode 100644
index 0000000000..8551386b41
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: BSD-3-Clause
+
+9baa:cead:8000:0000:0000:0000:0000:0000 d1b5:2feb:0000:0000:0000:0000:0000:0000 37826 1526 6 0
+2eba:cc41:0000:0000:0000:0000:0000:0000 16ef:6cdb:0000:0000:0000:0000:0000:0000 25946 1525 0 4294967295
app/test-acl/test-acl.sh new file +94 -0

94 lines not on this page · raw message

Signature · 1 line
2.26.3
#5 lore raw

Re: [dpdk-dev] [PATCH v2 0/2] app/acl: help to automate testing

In reply to Konstantin Ananyev

26/07/2021 13:51, Konstantin Ananyev:

Quoted 6 lines

The purpose of this series is to help automate ACL library functional testing using test-acl app.
First patch adds into test-acl ability to skip comment/empty lines. Second patch adds script for automate testing.
Sample input files are also provided.

Quoted 7 lines

v2:
- Added ability to skip comment/empty lines
- Fixed check-spdx-tag.sh complains (Thomas)

Konstantin Ananyev (2):
app/acl: allow comment and empty lines
app/acl: add script for automate testing

Applied, thanks.