From patchwork Wed Jul 5 14:00:18 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: 107077 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp878468obb; Wed, 5 Jul 2017 07:02:13 -0700 (PDT) X-Received: by 10.200.4.7 with SMTP id v7mr50697426qtg.166.1499263333670; Wed, 05 Jul 2017 07:02:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499263333; cv=none; d=google.com; s=arc-20160816; b=pi/RxC1dFmAi9CnLYMzJhMvPQbomCAkOeVaiaCLMaQ/c5y3QvKPui3Mv5gfiXNX5+S a+8ltYpSHlCU9Z5NiZ/h02xkkLE+QqH82wnjIq4FxXaEjWQYRWNlxL7V0jQ9On3uFY3z nNtpa35WN32prL0vbDGugBINQIMwZ+GabtBDF55pASuhQ4QE7Rw5XyBvN/4A9kbD5JLY OB0WzaoKBh8y+BKPAxhHB1QWumNSw99IVuDwOU7xc10bSbV+IC288+S/b1OWQyBXqsd7 cxwEd6zcVNfdkwKxrzE7IaIg+Lz3PVAcK1xCnUUCJ9JfXg66UDJWRgpAN518DXkLFx+P stuw== 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=Yt4yLC5epFZkJTk8mtRf78s5nHUuOPSLE3cRlWlP238=; b=lUk8lU0bNDI2xc6CzRI4EY+N/3xWGOrRZ6pRg/q2ECFtRQM5CrGVjUffDwOY/cuFfa LTwNJQw4a/Qaje+r5mwdnJ3P0Ksh0ZYdrfLLMY7aH477Vvu0y4OGDpy5agHobEiYyVeT AEmHWH7/umQJ3KxpeHNcI/i7OWZMZoTH6Fu93JBzvKPejYzXNGGX75xK83U0KxhKVzHD sehSq7HFoplA7WZtOH9iQCtQWG9Nqdlz4t2+F5Uf56Dmr2zx52amnUGNllAJKDVTDBKs cJbBo1+NW4EZJmuSYBija18S5l5jwoFM0H2ljpAIb5WChz4QpG4R1rDGmGvZIhRP8J0Z 5eBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id k22si9751894qtc.368.2017.07.05.07.02.13; Wed, 05 Jul 2017 07:02:13 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 365E160D92; Wed, 5 Jul 2017 14: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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,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 B491F60816; Wed, 5 Jul 2017 14:01:16 +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 413CE60D3C; Wed, 5 Jul 2017 14:01:03 +0000 (UTC) Received: from forward1m.cmail.yandex.net (forward1m.cmail.yandex.net [5.255.216.2]) by lists.linaro.org (Postfix) with ESMTPS id 377C160C3E for ; Wed, 5 Jul 2017 14:00:41 +0000 (UTC) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [IPv6:2a02:6b8:0:1619::15:6]) by forward1m.cmail.yandex.net (Yandex) with ESMTP id 7FEA4210A0 for ; Wed, 5 Jul 2017 17:00:39 +0300 (MSK) Received: from smtp4j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp4j.mail.yandex.net (Yandex) with ESMTP id D7EDB3241103 for ; Wed, 5 Jul 2017 17:00:35 +0300 (MSK) Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id SKW8niBPOU-0YEaZpa1; Wed, 05 Jul 2017 17:00:34 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Wed, 5 Jul 2017 17:00:18 +0300 Message-Id: <1499263226-5288-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> References: <1499263226-5288-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 64 Subject: [lng-odp] [PATCH API-NEXT v8 2/10] validation: test correctness of events subtype implementation 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: Dmitry Eremin-Solenikov Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 64 (lumag:crypto-packet) ** https://github.com/Linaro/odp/pull/64 ** Patch: https://github.com/Linaro/odp/pull/64.patch ** Base sha: 00a21c6dce65a30c8250db59a42a43c658e8ca1b ** Merge commit sha: ac9b299a7f3bee72dd9343bbfaa826217d243ea6 **/ test/common_plat/validation/api/buffer/buffer.c | 50 ++++++++++++++++------ .../validation/api/crypto/odp_crypto_test_inp.c | 14 ++++++ test/common_plat/validation/api/packet/packet.c | 21 ++++++++- test/common_plat/validation/api/timer/timer.c | 32 ++++++++++++-- 4 files changed, 99 insertions(+), 18 deletions(-) diff --git a/test/common_plat/validation/api/buffer/buffer.c b/test/common_plat/validation/api/buffer/buffer.c index 7c723d4f..66d00ab7 100644 --- a/test/common_plat/validation/api/buffer/buffer.c +++ b/test/common_plat/validation/api/buffer/buffer.c @@ -48,7 +48,8 @@ void buffer_test_pool_alloc(void) odp_buffer_t buffer[num]; odp_event_t ev; int index; - char wrong_type = 0, wrong_size = 0, wrong_align = 0; + odp_bool_t wrong_type = false, wrong_subtype = false; + odp_bool_t wrong_size = false, wrong_align = false; odp_pool_param_t params; odp_pool_param_init(¶ms); @@ -63,6 +64,7 @@ void buffer_test_pool_alloc(void) /* Try to allocate num items from the pool */ for (index = 0; index < num; index++) { uintptr_t addr; + odp_event_subtype_t subtype; buffer[index] = odp_buffer_alloc(pool); @@ -71,14 +73,20 @@ void buffer_test_pool_alloc(void) ev = odp_buffer_to_event(buffer[index]); if (odp_event_type(ev) != ODP_EVENT_BUFFER) - wrong_type = 1; + wrong_type = true; + if (odp_event_subtype(ev) != ODP_EVENT_NO_SUBTYPE) + wrong_subtype = true; + if (odp_event_types(ev, &subtype) != ODP_EVENT_BUFFER) + wrong_type = true; + if (subtype != ODP_EVENT_NO_SUBTYPE) + wrong_subtype = true; if (odp_buffer_size(buffer[index]) < BUF_SIZE) - wrong_size = 1; + wrong_size = true; addr = (uintptr_t)odp_buffer_addr(buffer[index]); if ((addr % BUF_ALIGN) != 0) - wrong_align = 1; + wrong_align = true; if (wrong_type || wrong_size || wrong_align) odp_buffer_print(buffer[index]); @@ -90,9 +98,10 @@ void buffer_test_pool_alloc(void) index--; /* Check that the pool had correct buffers */ - CU_ASSERT(wrong_type == 0); - CU_ASSERT(wrong_size == 0); - CU_ASSERT(wrong_align == 0); + CU_ASSERT(!wrong_type); + CU_ASSERT(!wrong_subtype); + CU_ASSERT(!wrong_size); + CU_ASSERT(!wrong_align); for (; index >= 0; index--) odp_buffer_free(buffer[index]); @@ -123,7 +132,8 @@ void buffer_test_pool_alloc_multi(void) odp_buffer_t buffer[num + 1]; odp_event_t ev; int index; - char wrong_type = 0, wrong_size = 0, wrong_align = 0; + odp_bool_t wrong_type = false, wrong_subtype = false; + odp_bool_t wrong_size = false, wrong_align = false; odp_pool_param_t params; odp_pool_param_init(¶ms); @@ -140,20 +150,27 @@ void buffer_test_pool_alloc_multi(void) for (index = 0; index < num; index++) { uintptr_t addr; + odp_event_subtype_t subtype; if (buffer[index] == ODP_BUFFER_INVALID) break; ev = odp_buffer_to_event(buffer[index]); if (odp_event_type(ev) != ODP_EVENT_BUFFER) - wrong_type = 1; + wrong_type = true; + if (odp_event_subtype(ev) != ODP_EVENT_NO_SUBTYPE) + wrong_subtype = true; + if (odp_event_types(ev, &subtype) != ODP_EVENT_BUFFER) + wrong_type = true; + if (subtype != ODP_EVENT_NO_SUBTYPE) + wrong_subtype = true; if (odp_buffer_size(buffer[index]) < BUF_SIZE) - wrong_size = 1; + wrong_size = true; addr = (uintptr_t)odp_buffer_addr(buffer[index]); if ((addr % BUF_ALIGN) != 0) - wrong_align = 1; + wrong_align = true; if (wrong_type || wrong_size || wrong_align) odp_buffer_print(buffer[index]); @@ -163,9 +180,10 @@ void buffer_test_pool_alloc_multi(void) CU_ASSERT(index == num); /* Check that the pool had correct buffers */ - CU_ASSERT(wrong_type == 0); - CU_ASSERT(wrong_size == 0); - CU_ASSERT(wrong_align == 0); + CU_ASSERT(!wrong_type); + CU_ASSERT(!wrong_subtype); + CU_ASSERT(!wrong_size); + CU_ASSERT(!wrong_align); odp_buffer_free_multi(buffer, num); @@ -244,10 +262,14 @@ void buffer_test_pool_free_multi(void) void buffer_test_management_basic(void) { odp_event_t ev = odp_buffer_to_event(raw_buffer); + odp_event_subtype_t subtype; CU_ASSERT(odp_buffer_is_valid(raw_buffer) == 1); CU_ASSERT(odp_buffer_pool(raw_buffer) != ODP_POOL_INVALID); CU_ASSERT(odp_event_type(ev) == ODP_EVENT_BUFFER); + CU_ASSERT(odp_event_subtype(ev) == ODP_EVENT_NO_SUBTYPE); + CU_ASSERT(odp_event_types(ev, &subtype) == ODP_EVENT_BUFFER); + CU_ASSERT(subtype == ODP_EVENT_NO_SUBTYPE); CU_ASSERT(odp_buffer_size(raw_buffer) >= BUF_SIZE); CU_ASSERT(odp_buffer_addr(raw_buffer) != NULL); odp_buffer_print(raw_buffer); diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c index ae600e23..1d7d49a2 100644 --- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c @@ -103,6 +103,7 @@ static void alg_test(odp_crypto_op_t op, odp_crypto_auth_capability_t auth_capa[MAX_ALG_CAPA]; int num, i; int found; + odp_event_subtype_t subtype; rc = odp_crypto_capability(&capa); CU_ASSERT(!rc); @@ -263,6 +264,12 @@ static void alg_test(odp_crypto_op_t op, event = odp_queue_deq(suite_context.queue); } while (event == ODP_EVENT_INVALID); + CU_ASSERT(ODP_EVENT_CRYPTO_COMPL == odp_event_type(event)); + CU_ASSERT(ODP_EVENT_NO_SUBTYPE == odp_event_subtype(event)); + CU_ASSERT(ODP_EVENT_CRYPTO_COMPL == + odp_event_types(event, &subtype)); + CU_ASSERT(ODP_EVENT_NO_SUBTYPE == subtype); + compl_event = odp_crypto_compl_from_event(event); CU_ASSERT(odp_crypto_compl_to_u64(compl_event) == odp_crypto_compl_to_u64(odp_crypto_compl_from_event(event))); @@ -272,6 +279,13 @@ static void alg_test(odp_crypto_op_t op, CU_ASSERT(result.pkt == pkt); CU_ASSERT(result.ctx == (void *)0xdeadbeef); + CU_ASSERT(ODP_EVENT_PACKET == + odp_event_type(odp_packet_to_event(result.pkt))); + CU_ASSERT(ODP_EVENT_PACKET_BASIC == + odp_event_subtype(odp_packet_to_event(result.pkt))); + CU_ASSERT(ODP_EVENT_PACKET == + odp_event_types(odp_packet_to_event(result.pkt), &subtype)); + CU_ASSERT(ODP_EVENT_PACKET_BASIC == subtype); if (should_fail) { CU_ASSERT(!result.ok); diff --git a/test/common_plat/validation/api/packet/packet.c b/test/common_plat/validation/api/packet/packet.c index 284aaeb5..fa6f4afd 100644 --- a/test/common_plat/validation/api/packet/packet.c +++ b/test/common_plat/validation/api/packet/packet.c @@ -241,6 +241,7 @@ void packet_test_alloc_free(void) odp_packet_t packet; odp_pool_param_t params; odp_pool_capability_t capa; + odp_event_subtype_t subtype; CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0); @@ -259,7 +260,12 @@ void packet_test_alloc_free(void) CU_ASSERT_FATAL(packet != ODP_PACKET_INVALID); CU_ASSERT(odp_packet_len(packet) == packet_len); CU_ASSERT(odp_event_type(odp_packet_to_event(packet)) == - ODP_EVENT_PACKET); + ODP_EVENT_PACKET); + CU_ASSERT(odp_event_subtype(odp_packet_to_event(packet)) == + ODP_EVENT_PACKET_BASIC); + CU_ASSERT(odp_event_types(odp_packet_to_event(packet), &subtype) == + ODP_EVENT_PACKET); + CU_ASSERT(subtype == ODP_EVENT_PACKET_BASIC); CU_ASSERT(odp_packet_to_u64(packet) != odp_packet_to_u64(ODP_PACKET_INVALID)); @@ -329,9 +335,17 @@ void packet_test_alloc_free_multi(void) CU_ASSERT_FATAL(ret == num_pkt); for (i = 0; i < 2 * num_pkt; ++i) { + odp_event_subtype_t subtype; + CU_ASSERT(odp_packet_len(packet[i]) == packet_len); CU_ASSERT(odp_event_type(odp_packet_to_event(packet[i])) == ODP_EVENT_PACKET); + CU_ASSERT(odp_event_subtype(odp_packet_to_event(packet[i])) == + ODP_EVENT_PACKET_BASIC); + CU_ASSERT(odp_event_types(odp_packet_to_event(packet[i]), + &subtype) == + ODP_EVENT_PACKET); + CU_ASSERT(subtype == ODP_EVENT_PACKET_BASIC); CU_ASSERT(odp_packet_to_u64(packet[i]) != odp_packet_to_u64(ODP_PACKET_INVALID)); } @@ -449,10 +463,15 @@ void packet_test_event_conversion(void) odp_packet_t pkt = test_packet; odp_packet_t tmp_pkt; odp_event_t ev; + odp_event_subtype_t subtype; ev = odp_packet_to_event(pkt); CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID); CU_ASSERT(odp_event_type(ev) == ODP_EVENT_PACKET); + CU_ASSERT(odp_event_subtype(ev) == ODP_EVENT_PACKET_BASIC); + CU_ASSERT(odp_event_types(ev, &subtype) == + ODP_EVENT_PACKET); + CU_ASSERT(subtype == ODP_EVENT_PACKET_BASIC); tmp_pkt = odp_packet_from_event(ev); CU_ASSERT_FATAL(tmp_pkt != ODP_PACKET_INVALID); diff --git a/test/common_plat/validation/api/timer/timer.c b/test/common_plat/validation/api/timer/timer.c index b7d84c64..88135160 100644 --- a/test/common_plat/validation/api/timer/timer.c +++ b/test/common_plat/validation/api/timer/timer.c @@ -59,7 +59,7 @@ void timer_test_timeout_pool_alloc(void) odp_timeout_t tmo[num]; odp_event_t ev; int index; - char wrong_type = 0; + odp_bool_t wrong_type = false, wrong_subtype = false; odp_pool_param_t params; odp_pool_param_init(¶ms); @@ -73,6 +73,8 @@ void timer_test_timeout_pool_alloc(void) /* Try to allocate num items from the pool */ for (index = 0; index < num; index++) { + odp_event_subtype_t subtype; + tmo[index] = odp_timeout_alloc(pool); if (tmo[index] == ODP_TIMEOUT_INVALID) @@ -80,7 +82,13 @@ void timer_test_timeout_pool_alloc(void) ev = odp_timeout_to_event(tmo[index]); if (odp_event_type(ev) != ODP_EVENT_TIMEOUT) - wrong_type = 1; + wrong_type = true; + if (odp_event_subtype(ev) != ODP_EVENT_NO_SUBTYPE) + wrong_subtype = true; + if (odp_event_types(ev, &subtype) != ODP_EVENT_TIMEOUT) + wrong_type = true; + if (subtype != ODP_EVENT_NO_SUBTYPE) + wrong_subtype = true; } /* Check that the pool had at least num items */ @@ -89,7 +97,8 @@ void timer_test_timeout_pool_alloc(void) index--; /* Check that the pool had correct buffers */ - CU_ASSERT(wrong_type == 0); + CU_ASSERT(!wrong_type); + CU_ASSERT(!wrong_subtype); for (; index >= 0; index--) odp_timeout_free(tmo[index]); @@ -219,12 +228,29 @@ void timer_test_odp_timer_cancel(void) /* @private Handle a received (timeout) event */ static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick) { + odp_event_subtype_t subtype; + CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID); /* Internal error */ if (odp_event_type(ev) != ODP_EVENT_TIMEOUT) { /* Not a timeout event */ CU_FAIL("Unexpected event type received"); return; } + if (odp_event_subtype(ev) != ODP_EVENT_NO_SUBTYPE) { + /* Not a timeout event */ + CU_FAIL("Unexpected event subtype received"); + return; + } + if (odp_event_types(ev, &subtype) != ODP_EVENT_TIMEOUT) { + /* Not a timeout event */ + CU_FAIL("Unexpected event type received"); + return; + } + if (subtype != ODP_EVENT_NO_SUBTYPE) { + /* Not a timeout event */ + CU_FAIL("Unexpected event subtype received"); + return; + } /* Read the metadata from the timeout */ odp_timeout_t tmo = odp_timeout_from_event(ev); odp_timer_t tim = odp_timeout_timer(tmo);