From patchwork Mon Aug 20 10:00:08 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: 144558 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3768051ljj; Mon, 20 Aug 2018 03:02:32 -0700 (PDT) X-Google-Smtp-Source: AA+uWPw9qLdqDoXukkFtoJm0Ur8HawpO2pL1Hg1/PQduykNl+pEbwyfrObwT2Wk28D9W8OgSt9VL X-Received: by 2002:a37:93c6:: with SMTP id v189-v6mr40529459qkd.140.1534759352233; Mon, 20 Aug 2018 03:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534759352; cv=none; d=google.com; s=arc-20160816; b=W3PUh36m7Mixdl1Nkjwhy3+xvK0zrRxc29/0fnZRkuvHbMXDGXs47xjyxAAMZElrHz nA4p9JCpVOU3KhpDhW5rA4nptPlE41W544TMcq94Hp9bWEUHJ5591xBqZYiCyJ+b0gK1 gFVJQa7rTDJs0CG0/eTpYxXj/AHmxWEAfDb2MPorh87xkHyVl+/C2+OudN03sV/gR0Tm u1M1tA9VLPlAy9dTpLAkwFnKTmn/echEkMrb8t1xbGujX8ztcA5PYYfZOGwMHY/FstlT 5yG+7LC2SP7yNC6aLuciaBHeW5/PbkDDSBPBfRvm6CNI8uX8D5hJpnKp4frsc7QB0mB5 aU7g== 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=vAOvbMKf+HydWxoQKKN6+0t5NEMWu0DRIAzlk2Oxn7E=; b=pJViUBrIai9O5wc0szGLeEnXlwPlEZd0s2hk1grKryH1vrRJukL8+9Q/ax/7h+CUNP /Du2z2YDeven6RwTN5jaqNdw1Vhhp09WV6+WR97ek20ORQ17TKvXSq7MJRl+WlD0LZVb dsuv5k0/5H7UJ/ozAvQm7VYa6gCtjObElkFQGmET0o1gq/lWLxmXAVs/301eslvEJzxk LDRjtjGbz2zxiAG8TZKqMwN6NjeWu1aKIGxdzo7WHKdPsK4FqbvfLxefp1qtnArCQYlu 9iYvrelYy258e0AkjsEaAMNLCkJ0pIvXOWdNwfL7tKUkLGPLRCt8EwQjhjjfYcSgA9De KYzg== 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 p25-v6si2196679qtl.303.2018.08.20.03.02.32; Mon, 20 Aug 2018 03:02:32 -0700 (PDT) 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 EFA836863F; Mon, 20 Aug 2018 10:02:31 +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=-3.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW 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 E42186095C; Mon, 20 Aug 2018 10:00:40 +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 250B260AA8; Mon, 20 Aug 2018 10:00:31 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id 36F3460AA8 for ; Mon, 20 Aug 2018 10:00:22 +0000 (UTC) Received: from mxback5o.mail.yandex.net (mxback5o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1f]) by forward102j.mail.yandex.net (Yandex) with ESMTP id 9A8A65605A9C for ; Mon, 20 Aug 2018 13:00:19 +0300 (MSK) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [2a02:6b8:0:1a2d::25]) by mxback5o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id rlngf35Vwo-0JdiAC2u; Mon, 20 Aug 2018 13:00:19 +0300 Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id mI7U2yzlYn-0IPGIOMK; Mon, 20 Aug 2018 13:00:18 +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: Mon, 20 Aug 2018 10:00:08 +0000 Message-Id: <1534759208-15203-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534759208-15203-1-git-send-email-odpbot@yandex.ru> References: <1534759208-15203-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 672 Subject: [lng-odp] [PATCH API-NEXT v3 4/4] validation: packet: add parse result test 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 Test new parse result functions. Signed-off-by: Petri Savolainen --- /** Email created from pull request 672 (psavol:next-packet-metadata) ** https://github.com/Linaro/odp/pull/672 ** Patch: https://github.com/Linaro/odp/pull/672.patch ** Base sha: 2722279b31b075586551801eb2860687ff966ea8 ** Merge commit sha: e76448d8a8f2575ab3a4c445be84d19f055cbf2d **/ test/validation/api/packet/packet.c | 109 ++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index 280e5c829..0c86b0510 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -3306,6 +3306,114 @@ static void parse_eth_ipv4_rr_nop_icmp(void) odp_packet_free_multi(pkt, num_pkt); } +static void parse_result(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + odp_packet_parse_result_t result[num_pkt]; + odp_packet_parse_result_t *result_ptr[num_pkt]; + + /* Ethernet/VLAN/IPv6/UDP */ + parse_test_alloc(pkt, test_packet_vlan_ipv6_udp, + sizeof(test_packet_vlan_ipv6_udp), num_pkt); + + parse.proto = ODP_PROTO_ETH; + parse.last_layer = ODP_PROTO_LAYER_ALL; + parse.chksums.all_chksum = 0; + + CU_ASSERT(odp_packet_parse(pkt[0], 0, &parse) == 0); + CU_ASSERT(odp_packet_parse_multi(&pkt[1], parse_test.offset_zero, + num_pkt - 1, &parse) == (num_pkt - 1)); + + for (i = 0; i < num_pkt; i++) { + result_ptr[i] = &result[i]; + memset(&result[i], 0, sizeof(odp_packet_parse_result_t)); + } + + odp_packet_parse_result(pkt[0], result_ptr[0]); + odp_packet_parse_result_multi(&pkt[1], &result_ptr[1], num_pkt - 1); + + for (i = 0; i < num_pkt; i++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_vlan(pkt[i])); + CU_ASSERT(odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(odp_packet_has_udp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT(odp_packet_l2_type(pkt[i]) == ODP_PROTO_L2_TYPE_ETH); + CU_ASSERT(odp_packet_l3_type(pkt[i]) == ODP_PROTO_L3_TYPE_IPV6); + CU_ASSERT(odp_packet_l4_type(pkt[i]) == ODP_PROTO_L4_TYPE_UDP); + + CU_ASSERT(result[i].flag.all != 0); + CU_ASSERT(result[i].flag.has_error == + odp_packet_has_error(pkt[i])); + CU_ASSERT(result[i].flag.has_l2_error == + odp_packet_has_l2_error(pkt[i])); + CU_ASSERT(result[i].flag.has_l3_error == + odp_packet_has_l3_error(pkt[i])); + CU_ASSERT(result[i].flag.has_l4_error == + odp_packet_has_l4_error(pkt[i])); + CU_ASSERT(result[i].flag.has_l2 == + odp_packet_has_l2(pkt[i])); + CU_ASSERT(result[i].flag.has_l3 == + odp_packet_has_l3(pkt[i])); + CU_ASSERT(result[i].flag.has_l4 == + odp_packet_has_l4(pkt[i])); + CU_ASSERT(result[i].flag.has_eth == + odp_packet_has_eth(pkt[i])); + CU_ASSERT(result[i].flag.has_eth_bcast == + odp_packet_has_eth_bcast(pkt[i])); + CU_ASSERT(result[i].flag.has_eth_mcast == + odp_packet_has_eth_mcast(pkt[i])); + CU_ASSERT(result[i].flag.has_jumbo == + odp_packet_has_jumbo(pkt[i])); + CU_ASSERT(result[i].flag.has_vlan == + odp_packet_has_vlan(pkt[i])); + CU_ASSERT(result[i].flag.has_vlan_qinq == + odp_packet_has_vlan_qinq(pkt[i])); + CU_ASSERT(result[i].flag.has_arp == + odp_packet_has_arp(pkt[i])); + CU_ASSERT(result[i].flag.has_ipv4 == + odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(result[i].flag.has_ipv6 == + odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(result[i].flag.has_ip_bcast == + odp_packet_has_ip_bcast(pkt[i])); + CU_ASSERT(result[i].flag.has_ip_mcast == + odp_packet_has_ip_mcast(pkt[i])); + CU_ASSERT(result[i].flag.has_ipfrag == + odp_packet_has_ipfrag(pkt[i])); + CU_ASSERT(result[i].flag.has_ipopt == + odp_packet_has_ipopt(pkt[i])); + CU_ASSERT(result[i].flag.has_ipsec == + odp_packet_has_ipsec(pkt[i])); + CU_ASSERT(result[i].flag.has_udp == + odp_packet_has_udp(pkt[i])); + CU_ASSERT(result[i].flag.has_tcp == + odp_packet_has_tcp(pkt[i])); + CU_ASSERT(result[i].flag.has_sctp == + odp_packet_has_sctp(pkt[i])); + CU_ASSERT(result[i].flag.has_icmp == + odp_packet_has_icmp(pkt[i])); + + CU_ASSERT(result[i].packet_len == odp_packet_len(pkt[i])); + CU_ASSERT(result[i].l2_offset == odp_packet_l2_offset(pkt[i])); + CU_ASSERT(result[i].l3_offset == odp_packet_l3_offset(pkt[i])); + CU_ASSERT(result[i].l4_offset == odp_packet_l4_offset(pkt[i])); + CU_ASSERT(result[i].l3_chksum_status == + odp_packet_l3_chksum_status(pkt[i])); + CU_ASSERT(result[i].l4_chksum_status == + odp_packet_l4_chksum_status(pkt[i])); + CU_ASSERT(result[i].l2_type == odp_packet_l2_type(pkt[i])); + CU_ASSERT(result[i].l3_type == odp_packet_l3_type(pkt[i])); + CU_ASSERT(result[i].l4_type == odp_packet_l4_type(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + odp_testinfo_t packet_suite[] = { ODP_TEST_INFO(packet_test_alloc_free), ODP_TEST_INFO(packet_test_alloc_free_multi), @@ -3363,6 +3471,7 @@ odp_testinfo_t packet_parse_suite[] = { ODP_TEST_INFO(parse_eth_ipv4_udp_first_frag), ODP_TEST_INFO(parse_eth_ipv4_udp_last_frag), ODP_TEST_INFO(parse_eth_ipv4_rr_nop_icmp), + ODP_TEST_INFO(parse_result), ODP_TEST_INFO_NULL, };