From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8620FA328D for ; Wed, 23 Oct 2019 04:55:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4B0F41BEDF; Wed, 23 Oct 2019 04:55:37 +0200 (CEST) Received: from foss.arm.com (unknown [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id A34591BEDA for ; Wed, 23 Oct 2019 04:55:33 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F3B481691; Tue, 22 Oct 2019 19:55:25 -0700 (PDT) Received: from net-arm-thunderx2-01.test.ast.arm.com (net-arm-thunderx2-01.shanghai.arm.com [10.169.40.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7F8EE3F6C4; Tue, 22 Oct 2019 19:55:22 -0700 (PDT) From: Joyce Kong To: dev@dpdk.org Cc: nd@arm.com, thomas@monjalon.net, jerinj@marvell.com, stephen@networkplumber.org, mb@smartsharesystems.com, honnappa.nagarahalli@arm.com, gavin.hu@arm.com, ravi1.kumar@amd.com, rmody@marvell.com, shshaikh@marvell.com, xuanziyang2@huawei.com, cloud.wangxiaoyun@huawei.com, zhouguoyang@huawei.com Date: Wed, 23 Oct 2019 10:54:54 +0800 Message-Id: <1571799298-18873-3-git-send-email-joyce.kong@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571799298-18873-1-git-send-email-joyce.kong@arm.com> References: <1571799298-18873-1-git-send-email-joyce.kong@arm.com> In-Reply-To: <1571125801-45773-1-git-send-email-joyce.kong@arm.com> References: <1571125801-45773-1-git-send-email-joyce.kong@arm.com> Subject: [dpdk-dev] [PATCH v2 2/6] test/iobitops: add io bit operation test case X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add test cases for set bit, clear bit, test and set bit, test and clear bit operations. Signed-off-by: Joyce Kong Reviewed-by: Gavin Hu --- app/test/Makefile | 1 + app/test/test_io_bitops.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 app/test/test_io_bitops.c diff --git a/app/test/Makefile b/app/test/Makefile index df7f77f..3e47c94 100644 --- a/app/test/Makefile +++ b/app/test/Makefile @@ -70,6 +70,7 @@ SRCS-y += test_ticketlock.c SRCS-y += test_memory.c SRCS-y += test_memzone.c SRCS-y += test_bitmap.c +SRCS-y += test_io_bitops.c SRCS-y += test_reciprocal_division.c SRCS-y += test_reciprocal_division_perf.c SRCS-y += test_fbarray.c diff --git a/app/test/test_io_bitops.c b/app/test/test_io_bitops.c new file mode 100644 index 0000000..c61bec7 --- /dev/null +++ b/app/test/test_io_bitops.c @@ -0,0 +1,86 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2019 Arm Limited + */ + +#include +#include + +#include "test.h" + +#define MAX_BITS 32 + +static int +test_io_bitops_set(unsigned long *addr) +{ + unsigned int i; + + for (i = 0; i < MAX_BITS; i++) + rte_io_set_bit(i, addr); + + for (i = 0; i < MAX_BITS; i++) + if (!rte_io_get_bit(i, addr)) { + printf("Failed to set bit.\n"); + return TEST_FAILED; + } + + return TEST_SUCCESS; +} + +static int +test_io_bitops_clear(unsigned long *addr) +{ + unsigned int i; + + for (i = 0; i < MAX_BITS; i++) + rte_io_clear_bit(i, addr); + + for (i = 0; i < MAX_BITS; i++) + if (rte_io_get_bit(i, addr)) { + printf("Failed to clear bit.\n"); + return TEST_FAILED; + } + + return TEST_SUCCESS; +} + +static int +test_io_bitops_test_set_clear(unsigned long *addr) +{ + unsigned int i; + + for (i = 0; i < MAX_BITS; i++) + rte_io_test_and_set_bit(i, addr); + + for (i = 0; i < MAX_BITS; i++) + if (!rte_io_test_and_clear_bit(i, addr)) { + printf("Failed to set and test bit.\n"); + return TEST_FAILED; + } + + for (i = 0; i < MAX_BITS; i++) + if (rte_io_get_bit(i, addr)) { + printf("Failed to test and clear bit.\n"); + return TEST_FAILED; + } + + return TEST_SUCCESS; +} + +static int +test_io_bitops(void) +{ + unsigned long *addr = rte_zmalloc(NULL, MAX_BITS, RTE_CACHE_LINE_SIZE); + + if (test_io_bitops_set(addr) < 0) + return TEST_FAILED; + + if (test_io_bitops_clear(addr) < 0) + return TEST_FAILED; + + if (test_io_bitops_test_set_clear(addr) < 0) + return TEST_FAILED; + + return TEST_SUCCESS; +} + +REGISTER_TEST_COMMAND(io_bitops_autotest, test_io_bitops); -- 2.7.4