From patchwork Tue Feb 13 14:00:05 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: 128237 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4281585ljc; Tue, 13 Feb 2018 06:01:17 -0800 (PST) X-Google-Smtp-Source: AH8x225SMeNY//LrP6oEo6ipGN6BkCVgLv7xAFT1IqO/88cI0HvCJdFlcbCV/L9g9UVuyCaPTj4B X-Received: by 10.200.12.203 with SMTP id o11mr2063312qti.95.1518530477269; Tue, 13 Feb 2018 06:01:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518530477; cv=none; d=google.com; s=arc-20160816; b=dqhLkhN6b2zti84/TRJ0yPzaN+0TxodckwfFy9/mzUY+is8ubO/SJ+tz5dZPRDjYW3 gd8ECUoikoGGb9Ivz/wt+BWjdQYVMt459w/H/X/6QfK0KgRCXT96rybCP9EmpjHOjr7/ hMU4ZabLeu0d8Q3Chf1ppXsDRnS2pVZnve7KSlih/bJnPTn+kDlv8diCE8SBCckWXFRi djt10xq798/38qq9njupN+nOzjH586idVpHtMKstyliOD0lozXT0X3lTkquBPHhqtHVM n66F4RTr4ceC0bhmJrq7pVTbumb51M3zcL/yexvh6sVqYCDa2oJprNcvOXU1OxoAdeZq 8epw== 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=AV8Itd/lJv3mMRk+auToDNd+AIG9BjRrvAPkf76mrpk=; b=O8KdcE5a8vqVeXQmysO6lO4fUuHmgGjIgR6ySyjhOjPgZiN8d6DdL4NAKP0PE3w3L7 y/5yrQh4WLZhlC2lkVa+q0KyOZyaaa31Mjko05rNca4SSb17ZyhCbyMRmdm/iCHlJwxo ySzBsqRfDOpTJMF2cN9VoqzFlSs6UAavpaFuwLEBieRY+oDbpjVbg0PV+l0p7P0I3irP Zxh9yk23OxVHo5CJBVCNXmS0CeT23hbIUYQerVE+YNNUB5DikrTB+agyn3BjEYbcxRWj wKQ/uF2ZDvn30BEz6g56UHQV8KUbd8M3xHHaHiLuRuGEcI3b2iDSgstKEYF4xOEOtPgq Pmbg== 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 s65si1909089qks.388.2018.02.13.06.01.16; Tue, 13 Feb 2018 06:01:17 -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 DBCC160BF4; Tue, 13 Feb 2018 14:01:16 +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_H3, RCVD_IN_MSPIKE_WL 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 9E9A4608A2; Tue, 13 Feb 2018 14:00:26 +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 15789616E8; Tue, 13 Feb 2018 14:00:19 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id 4527160C5E for ; Tue, 13 Feb 2018 14:00:15 +0000 (UTC) Received: from mxback9g.mail.yandex.net (mxback9g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:170]) by forward103j.mail.yandex.net (Yandex) with ESMTP id 3F5A534C4DEC for ; Tue, 13 Feb 2018 17:00:14 +0300 (MSK) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [2a02:6b8:0:1a2d::25]) by mxback9g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id kirrbNZcW3-0EE8Nrqi; Tue, 13 Feb 2018 17:00:14 +0300 Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 6Ss5leStGE-0DFqTfhf; Tue, 13 Feb 2018 17:00:13 +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 17:00:05 +0300 Message-Id: <1518530410-18574-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518530410-18574-1-git-send-email-odpbot@yandex.ru> References: <1518530410-18574-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 472 Subject: [lng-odp] [PATCH v2 2/7] 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: 38d924655e8119f902e986011a477e1ad9094ab6 **/ test/validation/api/packet/packet.c | 234 ++++++++++++++++++++++-------------- test/validation/api/packet/packet.h | 1 - 2 files changed, 141 insertions(+), 94 deletions(-) diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index 1188c683c..05ec2b554 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -23,6 +23,9 @@ ODP_STATIC_ASSERT(PACKET_POOL_NUM_SEG > 1 && PACKET_POOL_NUM_SEG < PACKET_POOL_NUM, "Invalid PACKET_POOL_NUM_SEG value"); +/* Number of packets in parse test */ +#define PARSE_TEST_NUM_PKT 10 + static odp_pool_t packet_pool, packet_pool_no_uarea, packet_pool_double_uarea; static uint32_t packet_len; @@ -41,6 +44,25 @@ static struct udata_struct { "abcdefg", }; +static struct { + odp_pool_t pool; + odp_proto_chksums_t all_chksums; + uint32_t offset_zero[PARSE_TEST_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 +2481,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,21 +2502,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; + + for (i = 0; i < PARSE_TEST_NUM_PKT; i++) + parse_test.offset_zero[i] = 0; + + return 0; +} + +static int packet_parse_suite_term(void) +{ + if (odp_pool_destroy(parse_test.pool)) + return -1; - /* Ethernet/IPv4/UDP */ - len = sizeof(test_packet_ipv4_udp); - ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); + 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; + + 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); + } +} - offset[i] = 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]; + + parse_test_alloc(pkt, test_packet_ipv4_udp, + sizeof(test_packet_ipv4_udp)); + for (i = 0; i < num_pkt; i++) { chksum_status = odp_packet_l3_chksum_status(pkt[i]); CU_ASSERT(chksum_status == ODP_PACKET_CHKSUM_UNKNOWN); chksum_status = odp_packet_l4_chksum_status(pkt[i]); @@ -2526,10 +2563,10 @@ 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], + 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++) { @@ -2541,19 +2578,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,26 +2611,25 @@ 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); - - 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); +/* 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]; - offset[i] = 0; - } + parse_test_alloc(pkt, test_packet_ipv4_tcp, + sizeof(test_packet_ipv4_tcp)); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; parse.chksums.all_chksum = 0; - CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); - CU_ASSERT(odp_packet_parse_multi(&pkt[1], &offset[1], + 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++) { @@ -2601,26 +2640,25 @@ 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); - - 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); +/* 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]; - offset[i] = 0; - } + parse_test_alloc(pkt, test_packet_ipv6_udp, + sizeof(test_packet_ipv6_udp)); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_L4; parse.chksums.all_chksum = 0; - CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); - CU_ASSERT(odp_packet_parse_multi(&pkt[1], &offset[1], + 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++) { @@ -2632,26 +2670,25 @@ 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); - - 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); +/* 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]; - offset[i] = 0; - } + parse_test_alloc(pkt, test_packet_ipv6_tcp, + sizeof(test_packet_ipv6_tcp)); parse.proto = ODP_PROTO_ETH; parse.last_layer = ODP_PROTO_LAYER_ALL; parse.chksums.all_chksum = 0; - CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); - CU_ASSERT(odp_packet_parse_multi(&pkt[1], &offset[1], + 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++) { @@ -2663,8 +2700,6 @@ void packet_test_parse(void) } odp_packet_free_multi(pkt, num_pkt); - - odp_pool_destroy(pool); } odp_testinfo_t packet_suite[] = { @@ -2698,7 +2733,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 +2751,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[];