From patchwork Tue Feb 13 10:00:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 128208 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4086580ljc; Tue, 13 Feb 2018 02:04:26 -0800 (PST) X-Google-Smtp-Source: AH8x227rP4rGJP3pVw1W/Bd1r8eKaZMwFBma9f72ZyFjcfOAcuT16a9sN4S6NNGsNc/ls4I8TWHj X-Received: by 10.237.52.34 with SMTP id w31mr986305qtd.257.1518516266249; Tue, 13 Feb 2018 02:04:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518516266; cv=none; d=google.com; s=arc-20160816; b=H6lyUREIdLv8wc/dMEft5onHu/pP+x3HA2ahHge87rr2zyhYi0QDofZECqZyZVntJo Q/THeM/IxRCPAPq0znxSp56EPMsSFhXbm5y43lODMpib+mjfDYc032b/wTT8fIyDjGZK beXZvjWBYRHVqB1Z2Uvj2ejHpzSo1TcDe/qiCbwnvsJtKjPq+CBjzGbzmH/X3I+Gfygz Xk9iOb+jDcogHFUSI5VgnRnfPO1BafdNHbxWLY/iBmJJVOtU9c/eO4tSZuMpruiMm7+J 4RrQMcNWShACFHweaP/NJW0CEpd1zkcVNqO9/9NZ2DQHr6dYh66Fca7oz2KPuS+dv3zB zLkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=0memTclRqh48qo+AcCD0Xp0oVHM5ml931eZcxTTdsBE=; b=kNETrIphJJ22njQhm1S5qTVmgcmMnfHRgwyuFCyqMbKGRm6nZKGz1F7SHKV1S+yIGd Pd0dlJp01VjJYeB07y7/bH8tFXX0DMtlJXGkfdr+YL6DBXa6XRZfsVkZs09JmCWMc9Lj i5k8AXe/TDrfxsw15f3ZwMD165EnMeoFoXb5xHvbh5rxF9xocwFWv4WBAnk6kWJ8f0cX r+I+uccGFUqMl6hb6XY+231xeHCy/5BH31hJf88CTb8JX/pr79VWE7QuHyaVT/iC0KWu w5dwawcLL0LskRXDKSBbBt7b6sVgE2/IcnOip5kyFXkc7hjW95n1m2rnEm2d6uBq/p31 kzCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id o24si3242669qto.49.2018.02.13.02.04.26; Tue, 13 Feb 2018 02:04:26 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id E837E617B4; Tue, 13 Feb 2018 10:04:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 0835D6176F; Tue, 13 Feb 2018 10:00:45 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 4F90C6150C; Tue, 13 Feb 2018 10:00:35 +0000 (UTC) Received: from forward100o.mail.yandex.net (forward100o.mail.yandex.net [37.140.190.180]) by lists.linaro.org (Postfix) with ESMTPS id C7EBC6172B for ; Tue, 13 Feb 2018 10:00:15 +0000 (UTC) Received: from mxback10o.mail.yandex.net (mxback10o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::24]) by forward100o.mail.yandex.net (Yandex) with ESMTP id D7EBF2A231EE for ; Tue, 13 Feb 2018 13:00:11 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback10o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id h3mSSwVRwZ-0BOaCxVI; Tue, 13 Feb 2018 13:00:11 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 6ASWNO8Dvc-0BaGcntj; Tue, 13 Feb 2018 13:00:11 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 13 Feb 2018 13:00:07 +0300 Message-Id: <1518516009-30109-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518516009-30109-1-git-send-email-odpbot@yandex.ru> References: <1518516009-30109-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 472 Subject: [lng-odp] [PATCH v1 2/4] validation: packet: create parse test suite X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen Move parse tests into own suite before adding new test cases. There will be many parse test cases as there are many combinations of good and bad packet formats. Signed-off-by: Petri Savolainen --- /** Email created from pull request 472 (psavol:master-parser-validation) ** https://github.com/Linaro/odp/pull/472 ** Patch: https://github.com/Linaro/odp/pull/472.patch ** Base sha: 41b3fa2cd994a7ef68290a07dcde5564e4640847 ** Merge commit sha: aa702da6919f7e56a6ed59d3120233c97590b4f1 **/ test/validation/api/packet/packet.c | 215 +++++++++++++++++++++++------------- test/validation/api/packet/packet.h | 1 - 2 files changed, 137 insertions(+), 79 deletions(-) diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index 1188c683c..ea3db0c61 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -41,6 +41,25 @@ static struct udata_struct { "abcdefg", }; +static struct { + odp_pool_t pool; + odp_proto_chksums_t all_chksums; + int num_pkt; +} parse_test; + +static uint32_t parse_test_pkt_len[] = { + sizeof(test_packet_arp), + sizeof(test_packet_ipv4_icmp), + sizeof(test_packet_ipv4_tcp), + sizeof(test_packet_ipv4_udp), + sizeof(test_packet_vlan_ipv4_udp), + sizeof(test_packet_vlan_qinq_ipv4_udp), + sizeof(test_packet_ipv6_icmp), + sizeof(test_packet_ipv6_tcp), + sizeof(test_packet_ipv6_udp), + sizeof(test_packet_vlan_ipv6_udp) +}; + #define packet_compare_offset(pkt1, off1, pkt2, off2, len) \ _packet_compare_offset((pkt1), (off1), (pkt2), (off2), (len), __LINE__) @@ -2459,41 +2478,18 @@ void packet_test_ref(void) odp_packet_free(ref_pkt[1]); } -void packet_test_parse(void) +static int packet_parse_suite_init(void) { - odp_pool_t pool; + int num_test_pkt, i; + uint32_t max_len; odp_pool_param_t param; - odp_packet_parse_param_t parse; - int ret, num_test_pkt, i; - uint32_t len, max_len; - odp_packet_chksum_status_t chksum_status; - odp_proto_chksums_t all_chksums; - int num_pkt = 10; - odp_packet_t pkt[num_pkt]; - uint32_t offset[num_pkt]; - uint32_t test_pkt_len[] = {sizeof(test_packet_arp), - sizeof(test_packet_ipv4_icmp), - sizeof(test_packet_ipv4_tcp), - sizeof(test_packet_ipv4_udp), - sizeof(test_packet_vlan_ipv4_udp), - sizeof(test_packet_vlan_qinq_ipv4_udp), - sizeof(test_packet_ipv6_icmp), - sizeof(test_packet_ipv6_tcp), - sizeof(test_packet_ipv6_udp), - sizeof(test_packet_vlan_ipv6_udp) }; - - all_chksums.all_chksum = 0; - all_chksums.chksum.ipv4 = 1; - all_chksums.chksum.udp = 1; - all_chksums.chksum.tcp = 1; - all_chksums.chksum.sctp = 1; - - num_test_pkt = sizeof(test_pkt_len) / sizeof(uint32_t); + + num_test_pkt = sizeof(parse_test_pkt_len) / sizeof(uint32_t); max_len = 0; for (i = 0; i < num_test_pkt; i++) { - if (max_len < test_pkt_len[i]) - max_len = test_pkt_len[i]; + if (max_len < parse_test_pkt_len[i]) + max_len = parse_test_pkt_len[i]; } odp_pool_param_init(¶m); @@ -2503,19 +2499,59 @@ void packet_test_parse(void) param.pkt.len = max_len; param.pkt.num = 100; - pool = odp_pool_create("test_parse_pool", ¶m); - CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + parse_test.pool = odp_pool_create("parse_test_pool", ¶m); + + if (parse_test.pool == ODP_POOL_INVALID) + return -1; + + parse_test.all_chksums.all_chksum = 0; + parse_test.all_chksums.chksum.ipv4 = 1; + parse_test.all_chksums.chksum.udp = 1; + parse_test.all_chksums.chksum.tcp = 1; + parse_test.all_chksums.chksum.sctp = 1; + + parse_test.num_pkt = 10; + + return 0; +} + +static int packet_parse_suite_term(void) +{ + if (odp_pool_destroy(parse_test.pool)) + return -1; + + return 0; +} + +static void parse_test_alloc(odp_packet_t pkt[], const uint8_t test_packet[], + uint32_t len) +{ + int ret, i; + int num_pkt = parse_test.num_pkt; - /* Ethernet/IPv4/UDP */ - len = sizeof(test_packet_ipv4_udp); - ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); + ret = odp_packet_alloc_multi(parse_test.pool, len, pkt, num_pkt); CU_ASSERT_FATAL(ret == num_pkt); for (i = 0; i < num_pkt; i++) { - ret = odp_packet_copy_from_mem(pkt[i], 0, len, - test_packet_ipv4_udp); - CU_ASSERT(ret == 0); + ret = odp_packet_copy_from_mem(pkt[i], 0, len, test_packet); + CU_ASSERT_FATAL(ret == 0); + } +} +/* Ethernet/IPv4/UDP */ +static void parse_eth_ipv4_udp(void) +{ + odp_packet_parse_param_t parse; + int i; + odp_packet_chksum_status_t chksum_status; + int num_pkt = parse_test.num_pkt; + odp_packet_t pkt[num_pkt]; + uint32_t offset[num_pkt]; + + parse_test_alloc(pkt, test_packet_ipv4_udp, + sizeof(test_packet_ipv4_udp)); + + for (i = 0; i < num_pkt; i++) { offset[i] = 0; chksum_status = odp_packet_l3_chksum_status(pkt[i]); @@ -2526,7 +2562,7 @@ void packet_test_parse(void) parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_ALL; - parse.chksums = all_chksums; + parse.chksums = parse_test.all_chksums; CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); CU_ASSERT(odp_packet_parse_multi(&pkt[1], &offset[1], @@ -2541,19 +2577,22 @@ void packet_test_parse(void) } odp_packet_free_multi(pkt, num_pkt); +} - /* IPv4/UDP */ - len = sizeof(test_packet_ipv4_udp); - ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); - CU_ASSERT_FATAL(ret == num_pkt); +/* IPv4/UDP */ +static void parse_ipv4_udp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = parse_test.num_pkt; + odp_packet_t pkt[num_pkt]; + uint32_t offset[num_pkt]; - for (i = 0; i < num_pkt; i++) { - ret = odp_packet_copy_from_mem(pkt[i], 0, len, - test_packet_ipv4_udp); - CU_ASSERT(ret == 0); + parse_test_alloc(pkt, test_packet_ipv4_udp, + sizeof(test_packet_ipv4_udp)); + for (i = 0; i < num_pkt; i++) offset[i] = 14; - } parse.proto = ODP_PROTO_IPV4; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -2571,19 +2610,22 @@ void packet_test_parse(void) } odp_packet_free_multi(pkt, num_pkt); +} - /* Ethernet/IPv4/TCP */ - len = sizeof(test_packet_ipv4_tcp); - ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); - CU_ASSERT_FATAL(ret == num_pkt); +/* Ethernet/IPv4/TCP */ +static void parse_eth_ipv4_tcp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = parse_test.num_pkt; + odp_packet_t pkt[num_pkt]; + uint32_t offset[num_pkt]; - for (i = 0; i < num_pkt; i++) { - ret = odp_packet_copy_from_mem(pkt[i], 0, len, - test_packet_ipv4_tcp); - CU_ASSERT(ret == 0); + parse_test_alloc(pkt, test_packet_ipv4_tcp, + sizeof(test_packet_ipv4_tcp)); + for (i = 0; i < num_pkt; i++) offset[i] = 0; - } parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -2601,19 +2643,22 @@ void packet_test_parse(void) } odp_packet_free_multi(pkt, num_pkt); +} - /* Ethernet/IPv6/UDP */ - len = sizeof(test_packet_ipv6_udp); - ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); - CU_ASSERT_FATAL(ret == num_pkt); +/* Ethernet/IPv6/UDP */ +static void parse_eth_ipv6_udp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = parse_test.num_pkt; + odp_packet_t pkt[num_pkt]; + uint32_t offset[num_pkt]; - for (i = 0; i < num_pkt; i++) { - ret = odp_packet_copy_from_mem(pkt[i], 0, len, - test_packet_ipv6_udp); - CU_ASSERT(ret == 0); + parse_test_alloc(pkt, test_packet_ipv6_udp, + sizeof(test_packet_ipv6_udp)); + for (i = 0; i < num_pkt; i++) offset[i] = 0; - } parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; @@ -2632,19 +2677,22 @@ void packet_test_parse(void) } odp_packet_free_multi(pkt, num_pkt); +} - /* Ethernet/IPv6/TCP */ - len = sizeof(test_packet_ipv6_tcp); - ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); - CU_ASSERT_FATAL(ret == num_pkt); +/* Ethernet/IPv6/TCP */ +static void parse_eth_ipv6_tcp(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = parse_test.num_pkt; + odp_packet_t pkt[num_pkt]; + uint32_t offset[num_pkt]; - for (i = 0; i < num_pkt; i++) { - ret = odp_packet_copy_from_mem(pkt[i], 0, len, - test_packet_ipv6_tcp); - CU_ASSERT(ret == 0); + parse_test_alloc(pkt, test_packet_ipv6_tcp, + sizeof(test_packet_ipv6_tcp)); + for (i = 0; i < num_pkt; i++) offset[i] = 0; - } parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_ALL; @@ -2663,8 +2711,6 @@ void packet_test_parse(void) } odp_packet_free_multi(pkt, num_pkt); - - odp_pool_destroy(pool); } odp_testinfo_t packet_suite[] = { @@ -2698,7 +2744,15 @@ odp_testinfo_t packet_suite[] = { ODP_TEST_INFO(packet_test_align), ODP_TEST_INFO(packet_test_offset), ODP_TEST_INFO(packet_test_ref), - ODP_TEST_INFO(packet_test_parse), + ODP_TEST_INFO_NULL, +}; + +odp_testinfo_t packet_parse_suite[] = { + ODP_TEST_INFO(parse_eth_ipv4_udp), + ODP_TEST_INFO(parse_ipv4_udp), + ODP_TEST_INFO(parse_eth_ipv4_tcp), + ODP_TEST_INFO(parse_eth_ipv6_udp), + ODP_TEST_INFO(parse_eth_ipv6_tcp), ODP_TEST_INFO_NULL, }; @@ -2708,6 +2762,11 @@ odp_suiteinfo_t packet_suites[] = { .init_func = packet_suite_init, .term_func = packet_suite_term, }, + { .name = "packet parse tests", + .testinfo_tbl = packet_parse_suite, + .init_func = packet_parse_suite_init, + .term_func = packet_parse_suite_term, + }, ODP_SUITE_INFO_NULL, }; diff --git a/test/validation/api/packet/packet.h b/test/validation/api/packet/packet.h index 1d9947afa..798b272b9 100644 --- a/test/validation/api/packet/packet.h +++ b/test/validation/api/packet/packet.h @@ -40,7 +40,6 @@ void packet_test_extend_ref(void); void packet_test_align(void); void packet_test_offset(void); void packet_test_ref(void); -void packet_test_parse(void); /* test arrays: */ extern odp_testinfo_t packet_suite[];