From: Konstantin Ananyev <konstantin.ananyev@intel.com>
To: dev@dpdk.org
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCHv2 2/5] acl: update UT to reflect latest changes in the librte_acl.
Date: Wed, 28 May 2014 20:26:47 +0100 [thread overview]
Message-ID: <1401305210-10357-3-git-send-email-konstantin.ananyev@intel.com> (raw)
In-Reply-To: <1401305210-10357-1-git-send-email-konstantin.ananyev@intel.com>
Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
app/test/test_acl.c | 128 ++++++++++++++++++++++++++++++++++-----------------
1 files changed, 85 insertions(+), 43 deletions(-)
diff --git a/app/test/test_acl.c b/app/test/test_acl.c
index 790cdf3..c171eac 100644
--- a/app/test/test_acl.c
+++ b/app/test/test_acl.c
@@ -96,47 +96,13 @@ bswap_test_data(struct ipv4_7tuple * data, int len, int to_be)
* Test scalar and SSE ACL lookup.
*/
static int
-test_classify(void)
+test_classify_run(struct rte_acl_ctx * acx)
{
- struct rte_acl_ctx * acx;
int ret, i;
uint32_t result, count;
-
uint32_t results[RTE_DIM(acl_test_data) * RTE_ACL_MAX_CATEGORIES];
-
const uint8_t * data[RTE_DIM(acl_test_data)];
- const uint32_t layout[RTE_ACL_IPV4VLAN_NUM] = {
- offsetof(struct ipv4_7tuple, proto),
- offsetof(struct ipv4_7tuple, vlan),
- offsetof(struct ipv4_7tuple, ip_src),
- offsetof(struct ipv4_7tuple, ip_dst),
- offsetof(struct ipv4_7tuple, port_src),
- };
-
- acx = rte_acl_create(&acl_param);
- if (acx == NULL) {
- printf("Line %i: Error creating ACL context!\n", __LINE__);
- return -1;
- }
-
- /* add rules to the context */
- ret = rte_acl_ipv4vlan_add_rules(acx, acl_test_rules,
- RTE_DIM(acl_test_rules));
- if (ret != 0) {
- printf("Line %i: Adding rules to ACL context failed!\n", __LINE__);
- rte_acl_free(acx);
- return -1;
- }
-
- /* try building the context */
- ret = rte_acl_ipv4vlan_build(acx, layout, RTE_ACL_MAX_CATEGORIES);
- if (ret != 0) {
- printf("Line %i: Building ACL context failed!\n", __LINE__);
- rte_acl_free(acx);
- return -1;
- }
-
/* swap all bytes in the data to network order */
bswap_test_data(acl_test_data, RTE_DIM(acl_test_data), 1);
@@ -213,21 +179,97 @@ test_classify(void)
}
}
- /* free ACL context */
- rte_acl_free(acx);
+ ret = 0;
+err:
/* swap data back to cpu order so that next time tests don't fail */
bswap_test_data(acl_test_data, RTE_DIM(acl_test_data), 0);
+ return (ret);
+}
- return 0;
-err:
+static int
+test_classify_buid(struct rte_acl_ctx * acx)
+{
+ int ret;
+ const uint32_t layout[RTE_ACL_IPV4VLAN_NUM] = {
+ offsetof(struct ipv4_7tuple, proto),
+ offsetof(struct ipv4_7tuple, vlan),
+ offsetof(struct ipv4_7tuple, ip_src),
+ offsetof(struct ipv4_7tuple, ip_dst),
+ offsetof(struct ipv4_7tuple, port_src),
+ };
- /* swap data back to cpu order so that next time tests don't fail */
- bswap_test_data(acl_test_data, RTE_DIM(acl_test_data), 0);
+ /* add rules to the context */
+ ret = rte_acl_ipv4vlan_add_rules(acx, acl_test_rules,
+ RTE_DIM(acl_test_rules));
+ if (ret != 0) {
+ printf("Line %i: Adding rules to ACL context failed!\n",
+ __LINE__);
+ return (ret);
+ }
- rte_acl_free(acx);
+ /* try building the context */
+ ret = rte_acl_ipv4vlan_build(acx, layout, RTE_ACL_MAX_CATEGORIES);
+ if (ret != 0) {
+ printf("Line %i: Building ACL context failed!\n", __LINE__);
+ return (ret);
+ }
- return -1;
+ return (0);
+}
+
+#define TEST_CLASSIFY_ITER 4
+
+/*
+ * Test scalar and SSE ACL lookup.
+ */
+static int
+test_classify(void)
+{
+ struct rte_acl_ctx * acx;
+ int i, ret;
+
+ acx = rte_acl_create(&acl_param);
+ if (acx == NULL) {
+ printf("Line %i: Error creating ACL context!\n", __LINE__);
+ return -1;
+ }
+
+ ret = 0;
+ for (i = 0; i != TEST_CLASSIFY_ITER; i++) {
+
+ if ((i & 1) == 0)
+ rte_acl_reset(acx);
+ else
+ rte_acl_reset_rules(acx);
+
+ ret = test_classify_buid(acx);
+ if (ret != 0) {
+ printf("Line %i, iter: %d: "
+ "Adding rules to ACL context failed!\n",
+ __LINE__, i);
+ break;
+ }
+
+ ret = test_classify_run(acx);
+ if (ret != 0) {
+ printf("Line %i, iter: %d: %s failed!\n",
+ __LINE__, i, __func__);
+ break;
+ }
+
+ /* reset rules and make sure that classify still works ok. */
+ rte_acl_reset_rules(acx);
+ ret = test_classify_run(acx);
+ if (ret != 0) {
+ printf("Line %i, iter: %d: %s failed!\n",
+ __LINE__, i, __func__);
+ break;
+ }
+ }
+
+ rte_acl_free(acx);
+ return (ret);
}
/*
--
1.7.7.6
next prev parent reply other threads:[~2014-05-28 19:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-28 19:26 [dpdk-dev] [PATCHv2 0/5] ACL library Konstantin Ananyev
2014-05-28 19:26 ` [dpdk-dev] [PATCHv2 1/5] acl: Add ACL library (librte_acl) into DPDK Konstantin Ananyev
2014-05-28 19:26 ` Konstantin Ananyev [this message]
2014-05-28 19:26 ` [dpdk-dev] [PATCHv2 3/5] acl: New test-acl application Konstantin Ananyev
2014-05-28 19:26 ` [dpdk-dev] [PATCHv2 4/5] acl: New sample l3fwd-acl Konstantin Ananyev
2014-05-28 19:26 ` [dpdk-dev] [PATCHv2 5/5] acl: add doxygen configuration and start page Konstantin Ananyev
2014-06-06 5:54 ` [dpdk-dev] [PATCHv2 0/5] ACL library Cao, Waterman
2014-06-06 8:32 ` De Lara Guarch, Pablo
2014-06-11 22:01 ` Thomas Monjalon
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=1401305210-10357-3-git-send-email-konstantin.ananyev@intel.com \
--to=konstantin.ananyev@intel.com \
--cc=dev@dpdk.org \
/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).