From patchwork Mon Jul 26 11:51:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ananyev, Konstantin" X-Patchwork-Id: 96283 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 84F14A0C47; Mon, 26 Jul 2021 13:52:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6F7C4410E1; Mon, 26 Jul 2021 13:52:27 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 35C6340DDA for ; Mon, 26 Jul 2021 13:52:25 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10056"; a="210326656" X-IronPort-AV: E=Sophos;i="5.84,270,1620716400"; d="scan'208";a="210326656" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2021 04:52:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,270,1620716400"; d="scan'208";a="473661387" Received: from sivswdev08.ir.intel.com ([10.237.217.47]) by fmsmga008.fm.intel.com with ESMTP; 26 Jul 2021 04:52:23 -0700 From: Konstantin Ananyev To: dev@dpdk.org Cc: Konstantin Ananyev Date: Mon, 26 Jul 2021 12:51:36 +0100 Message-Id: <20210726115137.6994-2-konstantin.ananyev@intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210726115137.6994-1-konstantin.ananyev@intel.com> References: <20210518112619.4237-1-konstantin.ananyev@intel.com> <20210726115137.6994-1-konstantin.ananyev@intel.com> Subject: [dpdk-dev] [PATCH v2 1/2] app/acl: allow comment and empty lines X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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. Signed-off-by: Konstantin Ananyev --- app/test-acl/main.c | 51 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/app/test-acl/main.c b/app/test-acl/main.c index 2cb2fe2579..c2de18770d 100644 --- a/app/test-acl/main.c +++ b/app/test-acl/main.c @@ -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; } } From patchwork Mon Jul 26 11:51:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ananyev, Konstantin" X-Patchwork-Id: 96284 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A465FA0C47; Mon, 26 Jul 2021 13:52:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9208040F35; Mon, 26 Jul 2021 13:52:45 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id B34C240DDA for ; Mon, 26 Jul 2021 13:52:43 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10056"; a="273303619" X-IronPort-AV: E=Sophos;i="5.84,270,1620716400"; d="scan'208";a="273303619" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2021 04:52:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,270,1620716400"; d="scan'208";a="473661421" Received: from sivswdev08.ir.intel.com ([10.237.217.47]) by fmsmga008.fm.intel.com with ESMTP; 26 Jul 2021 04:52:39 -0700 From: Konstantin Ananyev To: dev@dpdk.org Cc: Konstantin Ananyev Date: Mon, 26 Jul 2021 12:51:37 +0100 Message-Id: <20210726115137.6994-3-konstantin.ananyev@intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210726115137.6994-1-konstantin.ananyev@intel.com> References: <20210518112619.4237-1-konstantin.ananyev@intel.com> <20210726115137.6994-1-konstantin.ananyev@intel.com> Subject: [dpdk-dev] [PATCH v2 2/2] app/acl: add script for automate testing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The purpose of this script is to help automate ACL library functional testing using test-acl app. Sample input files are also provided. Signed-off-by: Konstantin Ananyev --- 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 diff --git a/app/test-acl/input/acl1v4_5_rule b/app/test-acl/input/acl1v4_5_rule new file mode 100644 index 0000000000..ae5b7826c0 --- /dev/null +++ b/app/test-acl/input/acl1v4_5_rule @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: BSD-3-Clause + +@16.32.1.1/32 2.1.0.0/16 0 : 65535 0 : 65535 0/0 +@16.32.1.0/24 2.1.1.0/24 0 : 65535 0 : 65535 0/0 +@2.1.0.0/16 16.32.1.1/32 0 : 65535 0 : 65535 0/0 +@2.1.0.0/16 16.32.1.0/24 1000 : 2000 0 : 65535 0/0 +@2.1.1.0/24 16.32.1.0/24 0 : 65535 0 : 65535 0/0 diff --git a/app/test-acl/input/acl1v4_5_trace b/app/test-acl/input/acl1v4_5_trace new file mode 100644 index 0000000000..80a988c280 --- /dev/null +++ b/app/test-acl/input/acl1v4_5_trace @@ -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 diff --git a/app/test-acl/input/acl1v6_1_rule b/app/test-acl/input/acl1v6_1_rule new file mode 100644 index 0000000000..3e03124186 --- /dev/null +++ b/app/test-acl/input/acl1v6_1_rule @@ -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 diff --git a/app/test-acl/input/acl1v6_1_trace b/app/test-acl/input/acl1v6_1_trace new file mode 100644 index 0000000000..8551386b41 --- /dev/null +++ b/app/test-acl/input/acl1v6_1_trace @@ -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 diff --git a/app/test-acl/test-acl.sh b/app/test-acl/test-acl.sh new file mode 100644 index 0000000000..c7bdc24113 --- /dev/null +++ b/app/test-acl/test-acl.sh @@ -0,0 +1,94 @@ +#! /bin/bash +# SPDX-License-Identifier: BSD-3-Clause + +# Usage: +# /bin/bash +# Expected file-naming conventions: +# - for rules: 'acl[0-9]v[4,6]_[0-9,a-z]+_rule' +# - for traces: 'acl[0-9]v[4,6]_[0-9,a-z]+_trace' +# Each rule file expects to have exactly one trace file. +# test-acl app follows classbench file format. +# Each line defines exactly one rule/trace. +# rules record format: +# '@''/' \ +# '/' \ +# ":" \ +# ":" \ +# '/' +# trace record format: +# \ +# ... +# +# As an example: +# /bin/bash app/test-acl/test-acl.sh build/app/dpdk-test-acl \ +# app/test-acl/input scalar 32 +# +# Refer to test-acl app for more information about rules/trace files format, +# available test-acl command-line options, etc. + +TACL_PATH=$1 +TACL_DIR=$2 +TACL_ALG=$3 +TACL_STEP=$4 + +if [[ ! -x ${TACL_PATH} ]]; then + echo "invalid TACL_PATH=${TACL_PATH}" + exit 127 +fi + +if [[ ! -d ${TACL_DIR} ]]; then + echo "invalid TACL_DIR=${TACL_DIR}" + exit 127 +fi + +V4F=`find ${TACL_DIR} -type f | egrep -e 'acl[0-9]v4_[0-9,a-z]+_rule$'` +V6F=`find ${TACL_DIR} -type f | egrep -e 'acl[0-9]v6_[0-9,a-z]+_rule$'` + +run_test() +{ + i=$1 + n=`basename ${i}` + + TRACEF=`echo ${i} | sed -e 's/_rule$/_trace/'` + if [[ ! -f ${TRACEF} ]]; then + echo "${TRACEF} not found" + echo "test ${n} FAILED" + exit 127 + fi + + OUTF=`mktemp ${n}_XXXXXX` + echo "start test ${n} with alg ${TACL_ALG}, burst-size ${TACL_STEP}" + ${TACL_PATH} -l 0 -n 4 --log-level="acl,debug" \ + --force-max-simd-bitwidth=0 --no-pci -- \ + ${XPRM} --tracenum=200000 --rulesf=${i} --tracef=${TRACEF} \ + --tracestep=${TACL_STEP} --alg=${TACL_ALG} \ + > ${OUTF} + grep 'result:' ${OUTF} | awk '{print $(NF);}' > ${OUTF}.out + sed -e '/^[[:space:]]*#/d' \ + -e '/^[[:space:]]*$/d' \ + -e 's/[[:space:]]*$//g' ${TRACEF} | \ + awk '{print $(NF);}' > ${OUTF}.chk + diff -u ${OUTF}.chk ${OUTF}.out + st=$? + if [[ $st -ne 0 ]]; then + echo "test ${n} FAILED" + echo "output files:" + ls ${OUTF}* + cat ${OUTF}* + exit 127 + fi + rm -f ${OUTF}* + echo "test ${n} OK" +} + +for i in ${V4F}; do + run_test $i +done + +for i in ${V6F}; do + XPRM='--ipv6' + run_test $i + unset XPRM +done + +echo "All tests have ended successfully"