From patchwork Fri Dec 1 14:59:58 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: 120337 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1248132qgn; Fri, 1 Dec 2017 07:02:14 -0800 (PST) X-Google-Smtp-Source: AGs4zMYtpIRefNvJcqQ6wSZ+obTSW6F9sgD3FBMlIHh7PAqn7IX31yFSMD+oyC8EUGpzNcFww4Br X-Received: by 10.55.79.15 with SMTP id d15mr7713361qkb.5.1512140534548; Fri, 01 Dec 2017 07:02:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512140534; cv=none; d=google.com; s=arc-20160816; b=JZi33miVtDxI51/3h3dwjGlmFGlD2a+l3jUC5rOM8KB0ciuVhKA1ulhfz2bY3uF1ZV e2VvxqJaFXJqfRBEi8a/q3c7G3Cb8u+UZ9FyocwNTl1lBet6fN84gjPh7qmT8eNVm0PB +vgcBUghdeU8DfCFFNymxn5ASiCSC4QamFYkKocYzESJtM7oHtsGA63xCrIPB+FJgM9r mkrZq4CiDWEanUDvsfa3Dwa4/KMO9/j/lQgxfeJa9pHx+ojW1WXWFDBZLZnakGZHPn/Y HV8uYltEJh8Croh6lQzp3VX1QY6iKnfz8KZQzo/9Wh+nui2qpQZqMV/CW7lW6J8pAJ5t Rouw== 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=IXMZrhYNdt0WHl5gyXnt7Wr+yeX40pzMzxpooNv0pXY=; b=q2PVzvLZFdWdNzZgjno9Bi0egSKtn7vnElgVO52hST4h9B/0qwTzAmOE2X5VZA7mZo /2SDLBNzLhxJOD5a35yAC3ZSuKL6AZSRo9MPLpYG0qUHfJYlsqf4tsHpeCeIDIg/YXyP znsnO88Seddgk13UjHf8QnaCdThJkZctO6SHS73w2T5lyyeGJYKIcDfMzP+xYaDzmMl+ SRX60mkVbBqSBpZNkc9EDZo58Ee4DJw3eEtiwhD8ST31g5qbbJisGNxxvgmqjQB7e7Gh sv1GTeLvfMXymaVh3k85U7qA/AzLUWBQPbYUT1fhITGfX1jmQ+yu2HqCin4w0TKq9o/a sXcg== 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 v90si1392074qkv.258.2017.12.01.07.02.14; Fri, 01 Dec 2017 07:02:14 -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 E0CEC609F8; Fri, 1 Dec 2017 15:02:13 +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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, 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 9913F6086F; Fri, 1 Dec 2017 15:00:36 +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 D54996097A; Fri, 1 Dec 2017 15:00:19 +0000 (UTC) Received: from forward106j.mail.yandex.net (forward106j.mail.yandex.net [5.45.198.249]) by lists.linaro.org (Postfix) with ESMTPS id B6B6560750 for ; Fri, 1 Dec 2017 15:00:17 +0000 (UTC) Received: from mxback4o.mail.yandex.net (mxback4o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1e]) by forward106j.mail.yandex.net (Yandex) with ESMTP id 486471805D28 for ; Fri, 1 Dec 2017 18:00:16 +0300 (MSK) Received: from smtp1j.mail.yandex.net (smtp1j.mail.yandex.net [2a02:6b8:0:801::ab]) by mxback4o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id SUINj2NHIF-0GvCgGME; Fri, 01 Dec 2017 18:00:16 +0300 Received: by smtp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id I6qrBsStkX-0FeefUgk; Fri, 01 Dec 2017 18:00:15 +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 17:59:58 +0300 Message-Id: <1512140407-13534-4-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 3/12] validation: event: add event 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 Added suite for event API tests. Test event types, free and free multiple event functions. 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/m4/configure.m4 | 1 + test/validation/api/Makefile.am | 2 + test/validation/api/event/.gitignore | 1 + test/validation/api/event/Makefile.am | 5 + test/validation/api/event/event.c | 274 +++++++++++++++++++++++++++++++++ test/validation/api/event/event.h | 12 ++ test/validation/api/event/event_main.c | 13 ++ 7 files changed, 308 insertions(+) create mode 100644 test/validation/api/event/.gitignore create mode 100644 test/validation/api/event/Makefile.am create mode 100644 test/validation/api/event/event.c create mode 100644 test/validation/api/event/event.h create mode 100644 test/validation/api/event/event_main.c diff --git a/test/m4/configure.m4 b/test/m4/configure.m4 index ef6096e87..dd07839ff 100644 --- a/test/m4/configure.m4 +++ b/test/m4/configure.m4 @@ -15,6 +15,7 @@ AC_CONFIG_FILES([test/Makefile test/validation/api/cpumask/Makefile test/validation/api/crypto/Makefile test/validation/api/errno/Makefile + test/validation/api/event/Makefile test/validation/api/hash/Makefile test/validation/api/init/Makefile test/validation/api/ipsec/Makefile diff --git a/test/validation/api/Makefile.am b/test/validation/api/Makefile.am index be3fb63e4..0503e092e 100644 --- a/test/validation/api/Makefile.am +++ b/test/validation/api/Makefile.am @@ -6,6 +6,7 @@ ODP_MODULES = atomic \ cpumask \ crypto \ errno \ + event \ hash \ init \ ipsec \ @@ -38,6 +39,7 @@ TESTS = \ cpumask/cpumask_main$(EXEEXT) \ crypto/crypto_main$(EXEEXT) \ errno/errno_main$(EXEEXT) \ + event/event_main$(EXEEXT) \ hash/hash_main$(EXEEXT) \ init/init_main_ok$(EXEEXT) \ init/init_main_abort$(EXEEXT) \ diff --git a/test/validation/api/event/.gitignore b/test/validation/api/event/.gitignore new file mode 100644 index 000000000..05d34d7c8 --- /dev/null +++ b/test/validation/api/event/.gitignore @@ -0,0 +1 @@ +event_main diff --git a/test/validation/api/event/Makefile.am b/test/validation/api/event/Makefile.am new file mode 100644 index 000000000..be4764b58 --- /dev/null +++ b/test/validation/api/event/Makefile.am @@ -0,0 +1,5 @@ +include ../Makefile.inc + +test_PROGRAMS = event_main +event_main_SOURCES = event_main.c event.c event.h +event_main_LDADD = $(LIBCUNIT_COMMON) $(LIBODP) diff --git a/test/validation/api/event/event.c b/test/validation/api/event/event.c new file mode 100644 index 000000000..fc048c1d4 --- /dev/null +++ b/test/validation/api/event/event.c @@ -0,0 +1,274 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "config.h" +#include +#include +#include "event.h" + +#define NUM_EVENTS 100 +#define EVENT_SIZE 100 +#define EVENT_BURST 10 + +static void event_test_free(void) +{ + odp_pool_t pool; + odp_pool_param_t pool_param; + int i; + odp_buffer_t buf; + odp_packet_t pkt; + odp_timeout_t tmo; + odp_event_subtype_t subtype; + odp_event_t event[EVENT_BURST]; + + /* 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; + + pool = odp_pool_create("event_free", &pool_param); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + for (i = 0; i < EVENT_BURST; i++) { + buf = odp_buffer_alloc(pool); + CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID); + event[i] = odp_buffer_to_event(buf); + CU_ASSERT(odp_event_type(event[i]) == ODP_EVENT_BUFFER); + CU_ASSERT(odp_event_subtype(event[i]) == ODP_EVENT_NO_SUBTYPE); + CU_ASSERT(odp_event_types(event[i], &subtype) == + ODP_EVENT_BUFFER); + CU_ASSERT(subtype == ODP_EVENT_NO_SUBTYPE); + } + + for (i = 0; i < EVENT_BURST; i++) + odp_event_free(event[i]); + + CU_ASSERT(odp_pool_destroy(pool) == 0); + + /* 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; + + pool = odp_pool_create("event_free", &pool_param); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + for (i = 0; i < EVENT_BURST; i++) { + pkt = odp_packet_alloc(pool, EVENT_SIZE); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + event[i] = odp_packet_to_event(pkt); + CU_ASSERT(odp_event_type(event[i]) == ODP_EVENT_PACKET); + CU_ASSERT(odp_event_subtype(event[i]) == + ODP_EVENT_PACKET_BASIC); + CU_ASSERT(odp_event_types(event[i], &subtype) == + ODP_EVENT_PACKET); + CU_ASSERT(subtype == ODP_EVENT_PACKET_BASIC); + } + + for (i = 0; i < EVENT_BURST; i++) + odp_event_free(event[i]); + + CU_ASSERT(odp_pool_destroy(pool) == 0); + + /* Timeout events */ + odp_pool_param_init(&pool_param); + pool_param.tmo.num = NUM_EVENTS; + pool_param.type = ODP_POOL_TIMEOUT; + + pool = odp_pool_create("event_free", &pool_param); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + for (i = 0; i < EVENT_BURST; i++) { + tmo = odp_timeout_alloc(pool); + CU_ASSERT_FATAL(tmo != ODP_TIMEOUT_INVALID); + event[i] = odp_timeout_to_event(tmo); + CU_ASSERT(odp_event_type(event[i]) == ODP_EVENT_TIMEOUT); + CU_ASSERT(odp_event_subtype(event[i]) == ODP_EVENT_NO_SUBTYPE); + CU_ASSERT(odp_event_types(event[i], &subtype) == + ODP_EVENT_TIMEOUT); + CU_ASSERT(subtype == ODP_EVENT_NO_SUBTYPE); + } + + for (i = 0; i < EVENT_BURST; i++) + odp_event_free(event[i]); + + CU_ASSERT(odp_pool_destroy(pool) == 0); +} + +static void event_test_free_multi(void) +{ + odp_pool_t pool; + odp_pool_param_t pool_param; + int i, j; + odp_buffer_t buf; + odp_packet_t pkt; + odp_timeout_t tmo; + odp_event_t event[EVENT_BURST]; + + /* 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; + + pool = odp_pool_create("event_free", &pool_param); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + for (j = 0; j < 2; j++) { + for (i = 0; i < EVENT_BURST; i++) { + buf = odp_buffer_alloc(pool); + CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID); + event[i] = odp_buffer_to_event(buf); + } + + if (j == 0) + odp_event_free_multi(event, EVENT_BURST); + else + odp_event_free_sp(event, EVENT_BURST); + } + + CU_ASSERT(odp_pool_destroy(pool) == 0); + + /* 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; + + pool = odp_pool_create("event_free", &pool_param); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + for (j = 0; j < 2; j++) { + for (i = 0; i < EVENT_BURST; i++) { + pkt = odp_packet_alloc(pool, EVENT_SIZE); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + event[i] = odp_packet_to_event(pkt); + } + + if (j == 0) + odp_event_free_multi(event, EVENT_BURST); + else + odp_event_free_sp(event, EVENT_BURST); + } + + CU_ASSERT(odp_pool_destroy(pool) == 0); + + /* Timeout events */ + odp_pool_param_init(&pool_param); + pool_param.tmo.num = NUM_EVENTS; + pool_param.type = ODP_POOL_TIMEOUT; + + pool = odp_pool_create("event_free", &pool_param); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + for (j = 0; j < 2; j++) { + for (i = 0; i < EVENT_BURST; i++) { + tmo = odp_timeout_alloc(pool); + CU_ASSERT_FATAL(tmo != ODP_TIMEOUT_INVALID); + event[i] = odp_timeout_to_event(tmo); + } + + if (j == 0) + odp_event_free_multi(event, EVENT_BURST); + else + odp_event_free_sp(event, EVENT_BURST); + } + + CU_ASSERT(odp_pool_destroy(pool) == 0); +} + +static void event_test_free_multi_mixed(void) +{ + odp_pool_t pool1, pool2, pool3; + odp_pool_param_t pool_param; + int i, j; + odp_buffer_t buf; + odp_packet_t pkt; + odp_timeout_t tmo; + odp_event_t event[3 * EVENT_BURST]; + + /* 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_free1", &pool_param); + CU_ASSERT_FATAL(pool1 != ODP_POOL_INVALID); + + /* 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_free2", &pool_param); + CU_ASSERT_FATAL(pool2 != ODP_POOL_INVALID); + + /* Timeout events */ + odp_pool_param_init(&pool_param); + pool_param.tmo.num = NUM_EVENTS; + pool_param.type = ODP_POOL_TIMEOUT; + + pool3 = odp_pool_create("event_free3", &pool_param); + CU_ASSERT_FATAL(pool3 != ODP_POOL_INVALID); + + for (j = 0; j < 2; j++) { + for (i = 0; i < 3 * EVENT_BURST;) { + buf = odp_buffer_alloc(pool1); + CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID); + event[i] = odp_buffer_to_event(buf); + i++; + pkt = odp_packet_alloc(pool2, EVENT_SIZE); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + event[i] = odp_packet_to_event(pkt); + i++; + tmo = odp_timeout_alloc(pool3); + CU_ASSERT_FATAL(tmo != ODP_TIMEOUT_INVALID); + event[i] = odp_timeout_to_event(tmo); + i++; + } + + if (j == 0) + odp_event_free_multi(event, 3 * EVENT_BURST); + else + odp_event_free_sp(event, 3 * EVENT_BURST); + } + + CU_ASSERT(odp_pool_destroy(pool1) == 0); + CU_ASSERT(odp_pool_destroy(pool2) == 0); + CU_ASSERT(odp_pool_destroy(pool3) == 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_NULL, +}; + +odp_suiteinfo_t event_suites[] = { + {"Event", NULL, NULL, event_suite}, + ODP_SUITE_INFO_NULL, +}; + +int event_main(int argc, char *argv[]) +{ + int ret; + + /* parse common options: */ + if (odp_cunit_parse_options(argc, argv)) + return -1; + + ret = odp_cunit_register(event_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; +} diff --git a/test/validation/api/event/event.h b/test/validation/api/event/event.h new file mode 100644 index 000000000..1d2b6e695 --- /dev/null +++ b/test/validation/api/event/event.h @@ -0,0 +1,12 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef _ODP_TEST_EVENT_H_ +#define _ODP_TEST_EVENT_H_ + +int event_main(int argc, char *argv[]); + +#endif diff --git a/test/validation/api/event/event_main.c b/test/validation/api/event/event_main.c new file mode 100644 index 000000000..3fbefdb81 --- /dev/null +++ b/test/validation/api/event/event_main.c @@ -0,0 +1,13 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "config.h" +#include "event.h" + +int main(int argc, char *argv[]) +{ + return event_main(argc, argv); +}