From patchwork Fri Dec 1 15:00:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 120345 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1256132qgn; Fri, 1 Dec 2017 07:07:30 -0800 (PST) X-Google-Smtp-Source: AGs4zMYHUCHP7EbxKX8L9f2WBcM27IBtmGZ4Te2TLMw4GCJtIkT/Ivu2YlJehrHFkIV9mNpKFxut X-Received: by 10.55.4.136 with SMTP id 130mr7803568qke.203.1512140850247; Fri, 01 Dec 2017 07:07:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512140850; cv=none; d=google.com; s=arc-20160816; b=KBPKwuJRw9hM6HxsU2iMEFOM/jE3ywT5j+p8+RreiNHLFGLIndGQLXsHvCTBZI3d0h rWzSij3eBQe6H3+5P7WkDJT4ywKqF28ime7Lr0cjl5fN4pLdJ5Bt0FEeVgj9NTCXXt4k JZWl4+13DJtwZwo3Chp1jfwSRiYzkpXTw0tDbEsrs3YLYXh7bJtNZWzlzD4TF3xZ+ipC R6+SLjGXHqh6+if1KkdRWZExztbFInVnRTdBfGB1UsE5ekcpd9Nn4YmY8uzFwbPfy4gE fiWQZDj7I0Wag/wnUgn3DFxXjVs0rDoHJd/3gHI8Bg1Wwa/fnj8pknEjuKyjYzcY3Z6s JaCw== 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=3+5NdwmU0ENI+zuoMapVJHbkBGLSXm9tVrMfgcYtrok=; b=HsLayfqeJHFjZJaxbCYPVw8qHlrb2y4TS1/GnW1hLP/dcN53DJJeDlko8PsB/UaYNu zkuuz9c9p0Qw0ZjZZEV+/yvEsFICcZH3mmzat+xMkAMf9F5/cOuiZ7VRlOlbnI8pux1w KgETL6fVbZseRCGqTRR2sIGx9q3E+ADJQ0GtTs/089UZcykwikVv75AFdDg2wO8h8fP6 w+V2GSKKkVXYuR0M1LwfSx5srktEqUuwu9niWRv8rLMdMTE2FvSmu7JHgGiZJvZEO+u7 DVgwAC2ooaP62twb7mt9bjJc8q8BhPp95RU6U69WPDxRuHymK7Ek03yYkRy6f3Rd2zDR 4u4w== 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 u5si2554139qki.259.2017.12.01.07.07.29; Fri, 01 Dec 2017 07:07:30 -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 DA6D76098E; Fri, 1 Dec 2017 15:07:29 +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,URIBL_BLOCKED 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 19892609C4; Fri, 1 Dec 2017 15:01:08 +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 CFBF760970; Fri, 1 Dec 2017 15:00:28 +0000 (UTC) Received: from forward106o.mail.yandex.net (forward106o.mail.yandex.net [37.140.190.187]) by lists.linaro.org (Postfix) with ESMTPS id 7776F6097A for ; Fri, 1 Dec 2017 15:00:21 +0000 (UTC) Received: from mxback12g.mail.yandex.net (mxback12g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:91]) by forward106o.mail.yandex.net (Yandex) with ESMTP id 16CDA782218 for ; Fri, 1 Dec 2017 18:00:20 +0300 (MSK) Received: from smtp1j.mail.yandex.net (smtp1j.mail.yandex.net [2a02:6b8:0:801::ab]) by mxback12g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id H9Ag5RyeSR-0K4uSYCN; Fri, 01 Dec 2017 18:00:20 +0300 Received: by smtp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id I6qrBsStkX-0JeCv66Y; Fri, 01 Dec 2017 18:00:19 +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: Fri, 1 Dec 2017 18:00:04 +0300 Message-Id: <1512140407-13534-10-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512140407-13534-1-git-send-email-odpbot@yandex.ru> References: <1512140407-13534-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 318 Subject: [lng-odp] [PATCH API-NEXT v1 9/12] validation: event: type multi 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 the new event type multi function. Signed-off-by: Petri Savolainen --- /** Email created from pull request 318 (psavol:next-multi-apis) ** https://github.com/Linaro/odp/pull/318 ** Patch: https://github.com/Linaro/odp/pull/318.patch ** Base sha: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0 ** Merge commit sha: aee2bcc574d2a8efdfcecc3b8e681ce391119798 **/ test/validation/api/event/event.c | 104 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/test/validation/api/event/event.c b/test/validation/api/event/event.c index fc048c1d4..901fe6ed2 100644 --- a/test/validation/api/event/event.c +++ b/test/validation/api/event/event.c @@ -245,10 +245,114 @@ static void event_test_free_multi_mixed(void) CU_ASSERT(odp_pool_destroy(pool3) == 0); } +#define NUM_TYPE_TEST 6 + +static void type_test_init(odp_pool_t *buf_pool, odp_pool_t *pkt_pool, + odp_event_t buf_event[], + odp_event_t pkt_event[], + odp_event_t event[]) +{ + odp_pool_t pool1, pool2; + odp_pool_param_t pool_param; + int i; + odp_buffer_t buf; + odp_packet_t pkt; + + /* Buffer events */ + odp_pool_param_init(&pool_param); + pool_param.buf.num = NUM_EVENTS; + pool_param.buf.size = EVENT_SIZE; + pool_param.type = ODP_POOL_BUFFER; + + pool1 = odp_pool_create("event_type_buf", &pool_param); + CU_ASSERT_FATAL(pool1 != ODP_POOL_INVALID); + + for (i = 0; i < NUM_TYPE_TEST; i++) { + buf = odp_buffer_alloc(pool1); + CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID); + buf_event[i] = odp_buffer_to_event(buf); + } + + /* Packet events */ + odp_pool_param_init(&pool_param); + pool_param.pkt.num = NUM_EVENTS; + pool_param.pkt.len = EVENT_SIZE; + pool_param.type = ODP_POOL_PACKET; + + pool2 = odp_pool_create("event_type_pkt", &pool_param); + CU_ASSERT_FATAL(pool2 != ODP_POOL_INVALID); + + for (i = 0; i < NUM_TYPE_TEST; i++) { + pkt = odp_packet_alloc(pool2, EVENT_SIZE); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + pkt_event[i] = odp_packet_to_event(pkt); + } + + /* 1 buf, 1 pkt, 2 buf, 2 pkt, 3 buf, 3 pkt */ + event[0] = buf_event[0]; + event[1] = pkt_event[0]; + event[2] = buf_event[1]; + event[3] = buf_event[2]; + event[4] = pkt_event[1]; + event[5] = pkt_event[2]; + event[6] = buf_event[3]; + event[7] = buf_event[4]; + event[8] = buf_event[5]; + event[9] = pkt_event[3]; + event[10] = pkt_event[4]; + event[11] = pkt_event[5]; + + *buf_pool = pool1; + *pkt_pool = pool2; +} + +static void event_test_type_multi(void) +{ + odp_pool_t buf_pool, pkt_pool; + odp_event_type_t type; + int num; + odp_event_t buf_event[NUM_TYPE_TEST]; + odp_event_t pkt_event[NUM_TYPE_TEST]; + odp_event_t event[2 * NUM_TYPE_TEST]; + + type_test_init(&buf_pool, &pkt_pool, buf_event, pkt_event, event); + + num = odp_event_type_multi(&event[0], 12, &type); + CU_ASSERT(num == 1); + CU_ASSERT(type == ODP_EVENT_BUFFER); + + num = odp_event_type_multi(&event[1], 11, &type); + CU_ASSERT(num == 1); + CU_ASSERT(type == ODP_EVENT_PACKET); + + num = odp_event_type_multi(&event[2], 10, &type); + CU_ASSERT(num == 2); + CU_ASSERT(type == ODP_EVENT_BUFFER); + + num = odp_event_type_multi(&event[4], 8, &type); + CU_ASSERT(num == 2); + CU_ASSERT(type == ODP_EVENT_PACKET); + + num = odp_event_type_multi(&event[6], 6, &type); + CU_ASSERT(num == 3); + CU_ASSERT(type == ODP_EVENT_BUFFER); + + num = odp_event_type_multi(&event[9], 3, &type); + CU_ASSERT(num == 3); + CU_ASSERT(type == ODP_EVENT_PACKET); + + odp_event_free_multi(buf_event, NUM_TYPE_TEST); + odp_event_free_multi(pkt_event, NUM_TYPE_TEST); + + CU_ASSERT(odp_pool_destroy(buf_pool) == 0); + CU_ASSERT(odp_pool_destroy(pkt_pool) == 0); +} + odp_testinfo_t event_suite[] = { ODP_TEST_INFO(event_test_free), ODP_TEST_INFO(event_test_free_multi), ODP_TEST_INFO(event_test_free_multi_mixed), + ODP_TEST_INFO(event_test_type_multi), ODP_TEST_INFO_NULL, };