From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0063.outbound.protection.outlook.com [104.47.33.63]) by dpdk.org (Postfix) with ESMTP id 93417239 for ; Thu, 14 Dec 2017 16:02:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=NocfiBPj6GCpinBFX2Fd1jfooahzBkKlcp2O7mg2oK0=; b=ETOXqNaSYhpN3gaH08FsyVmPpcqvQ06f7LqRixDQcEyemaZIEMACUfxBFIPDMJ1b4NlFrRX4kKH9tAKy6fylXUO/hpOmrGXHNnT2xBBX4/sZmlUHdg8OpFHhxCGSlumETXDXmLEHignL9GW1GUlOof0ZefdIV+DNlIwpfsMJmhc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from Pavan-LT.caveonetworks.com (111.93.218.67) by BN6PR07MB3460.namprd07.prod.outlook.com (10.161.153.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.302.9; Thu, 14 Dec 2017 15:02:12 +0000 From: Pavan Nikhilesh To: jerin.jacob@caviumnetworks.com, santosh.shukla@caviumnetworks.com, bruce.richardson@intel.com, harry.van.haaren@intel.com, gage.eads@intel.com, hemant.agrawal@nxp.com, nipun.gupta@nxp.com, liang.j.ma@intel.com Cc: dev@dpdk.org, Pavan Nikhilesh Date: Thu, 14 Dec 2017 20:31:28 +0530 Message-Id: <20171214150138.25667-2-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171214150138.25667-1-pbhagavatula@caviumnetworks.com> References: <20171212192713.17620-1-pbhagavatula@caviumnetworks.com> <20171214150138.25667-1-pbhagavatula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: MWHPR17CA0079.namprd17.prod.outlook.com (10.173.237.145) To BN6PR07MB3460.namprd07.prod.outlook.com (10.161.153.23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 338ac2db-a8f6-4fcc-bdff-08d54303aa12 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603307); SRVR:BN6PR07MB3460; X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3460; 3:gLP5quszY0WtMJ4H5O5H648fuy0AmHARELeP4dtyblNT56DnuITfd+DsYaA8s/7htasCHhOSglytCMrXSBgQqa8eWUuk3mb2qi9a98WQSNE7f45+xu0YuwzGrS0I2NtcrSmcYjJxyVtfRJzgkR94cbHl4nzHA4YOx4KfyQ3FQQA7MPXn5DBnErEBQzb2bnSO8WsnqYhVNB1Z+vttzTIxU0JoxfW+541yPhnl3c8fVXdAdcvQVpqi9egbkOvrtPzQ; 25:gVrd/UuA1qsjdJC33chOKCaoBLzb74RNYIeZtyHF5SUB1leacG4NQoVFIHZOxpD8ktazg4tALtmfjNDVm2aennOYtWHKCtUcsZRvsqRc3z8zPyfxm4Q2k9OVsRTsxg4mfe2a/N+a6+NIeyrniNrR6GuLHKX6T60vkiuYRGA9LRqI2c+ShKMmGrGr5v9qJmNSt1Sk9WBg1aAd2xFQDz/2m1fgstYCq6ucro7yjTLiWU20yRVqOVOUgqnUVPAFgullK66vhdA805i7jdRyroBc1xet5Ms42tk7MBygK+RPoxdr2ifnzVq2QC4OR6S44D2q/Z6dTQYH6i2f/B7gug/hXg==; 31:mXaSH64w8i7dWyEkHompbh4H20qZmaZB82CFoukGaS8HVi68kSxWEIlSDfORu74m1Zncx/20W489ZICEmIQpmCCYpLGF7+7T1avkGIkxgwZ5vZKXH8TbhJuLcqwkKak2xH0m9nxpnAgsAINtO/ItEQwgivqnAoQB/dUc7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Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(8121501046)(5005006)(3002001)(3231023)(93006095)(10201501046)(6041248)(20161123560025)(20161123564025)(20161123555025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148)(201708071742011); SRVR:BN6PR07MB3460; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:BN6PR07MB3460; X-Forefront-PRVS: 05214FD68E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(366004)(39860400002)(346002)(376002)(189003)(199004)(66066001)(42882006)(6666003)(2950100002)(305945005)(97736004)(72206003)(478600001)(2906002)(6486002)(47776003)(69596002)(107886003)(6512007)(575784001)(4326008)(25786009)(53936002)(48376002)(105586002)(36756003)(106356001)(50466002)(5660300001)(53416004)(5009440100003)(6116002)(3846002)(1076002)(16586007)(59450400001)(68736007)(6506007)(386003)(16526018)(316002)(52116002)(50226002)(76176011)(8656006)(7736002)(8936002)(8676002)(81156014)(51416003)(81166006)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR07MB3460; H:Pavan-LT.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR07MB3460; 23:QbQ85o8xQm/Du2NVy6ZOttSeSfLegNV/wuj0CD1Nm?= =?us-ascii?Q?1ZXRoy9ik8KirAwHm2ZyrcjHE+5/gUx+cInVOY7IJBJBCeWOY7epbV5rKPzU?= =?us-ascii?Q?2QgwgYykUOmdXx60HhuKcg7SKr5A2IUQog7yo7hYKKzOu9eaK79d/9nsVnyk?= =?us-ascii?Q?/k5fQ+Yl+kQ9bV25lPH021JJbcSV93c2nonynoft7biwSH9plz0uWZURtRxy?= =?us-ascii?Q?QIZMK5JKZATqw1Belvyxr303SbMzPEpl454XIGK7atfqMiC8addAEMSif1n5?= =?us-ascii?Q?dQHX85DZb88J7KgJ3YbyIWq+nZ93qiBligp3d19WUiZiHq9KybO5nLsjxtze?= =?us-ascii?Q?pbIjtYlOtjxdk1nPrth/Kg80RuA5lf3xxVafgehSbcugl8hsRY+UubHA/Gve?= =?us-ascii?Q?frz0YiBM37Ioqjd5WcnIpnLqkDmhfD+uEOxSPXOBior0BmBUzHDXApdiEt49?= =?us-ascii?Q?y2pavwtZ/ZAcJLm3YWDQb+agl/pIwwcqfLroiW5xOuScPQlZRzk3ND3eVgqu?= =?us-ascii?Q?NFqA66lwUerh5UTQcZf1k10yLoIwkOjH8B+i41Abclfpk/4bhxThQI6+2d45?= =?us-ascii?Q?f3lac6tSo4ILr7U99P2kUzLRpAr7IonLu1o/lVv8Qpmxuq9aTNnhVxeJBCqW?= =?us-ascii?Q?WwGKevwwDWrHSIT7lfJxgUMd9AsG2TEict9/z21p8Q31tzugQwmmWNpoQCnq?= =?us-ascii?Q?BxfdxwRV6MP6HKzAbPTFvCm2SzJ5rUrpHAWh+NNYPvxjVoZywj8eo5befWVZ?= =?us-ascii?Q?Y67/tr84HrLYJFGZJVkbRvS2yOuUNrLcV+s7CqvxKgGuJA1gKUH8Khk5kzn0?= =?us-ascii?Q?2dtxcjTjn/ya9WBMEHD62nhbXTq+wS2WmoBE/bvbJkPo2cBeC3u7CnNvy6qa?= =?us-ascii?Q?8tI50RVsipgRalU1xorQQb4BszQwL3gnSnkYFZNwIh+5znfUe1dZZIp1hLew?= =?us-ascii?Q?y+nT1HpjAmyIMfiVFvbkI1RttvSTZP314mrxaGdWZZnJ4+SB4LoVhHTmEYFz?= =?us-ascii?Q?558LQox6Qx2/wyhD+fLfjFjTvib8prROLiSMhKIAI6UHxVfpkzEYwm9jTNK3?= =?us-ascii?Q?RMaeV7XjBXRcI99ecgWLwiZQl1OWy6VHDBZHrnf/wvR7gD7EauDgfN5FeNEC?= =?us-ascii?Q?MApjFFesY1phbWsMgobafZ82k20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JTPqyJ3xdjqP98PQGYe SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2017 15:02:12.5266 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 338ac2db-a8f6-4fcc-bdff-08d54303aa12 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB3460 Subject: [dpdk-dev] [PATCH v2 01/11] eal: add common test assert macros 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: , X-List-Received-Date: Thu, 14 Dec 2017 15:02:18 -0000 Adding common test assertion macros for unit testing. Taken from test/test.h. Signed-off-by: Pavan Nikhilesh --- lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/include/rte_test.h | 97 ++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 lib/librte_eal/common/include/rte_test.h diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile index 9effd0d45..eba1059f2 100644 --- a/lib/librte_eal/common/Makefile +++ b/lib/librte_eal/common/Makefile @@ -43,7 +43,7 @@ INC += rte_hexdump.h rte_devargs.h rte_bus.h rte_dev.h INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h INC += rte_malloc.h rte_keepalive.h rte_time.h INC += rte_service.h rte_service_component.h -INC += rte_bitmap.h rte_vfio.h +INC += rte_bitmap.h rte_vfio.h rte_test.h GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h GENERIC_INC += rte_spinlock.h rte_memcpy.h rte_cpuflags.h rte_rwlock.h diff --git a/lib/librte_eal/common/include/rte_test.h b/lib/librte_eal/common/include/rte_test.h new file mode 100644 index 000000000..256117f79 --- /dev/null +++ b/lib/librte_eal/common/include/rte_test.h @@ -0,0 +1,97 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2017 Cavium, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Cavium, Inc nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _RTE_TEST_H_ +#define _RTE_TEST_H_ + +#include + +#define RTE_TEST_ASSERT(cond, msg, ...) do { \ + if (!(cond)) { \ + RTE_LOG(DEBUG, EAL, "Test assert %s line %d failed: " \ + msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ + return -1; \ + } \ +} while (0) + +#define RTE_TEST_ASSERT_EQUAL(a, b, msg, ...) do { \ + if (!(a == b)) { \ + RTE_LOG(DEBUG, EAL, "Test assert %s line %d failed: " \ + msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ + return -1; \ + } \ +} while (0) + +#define RTE_TEST_ASSERT_NOT_EQUAL(a, b, msg, ...) do { \ + if (!(a != b)) { \ + RTE_LOG(DEBUG, EAL, "Test assert %s line %d failed: " \ + msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ + return -1; \ + } \ +} while (0) + +#define RTE_TEST_ASSERT_SUCCESS(val, msg, ...) do { \ + typeof(val) _val = (val); \ + if (!(_val == 0)) { \ + RTE_LOG(DEBUG, EAL, \ + "Test assert %s line %d failed (err %d): " \ + msg "\n", __func__, __LINE__, _val, \ + ##__VA_ARGS__); \ + return -1; \ + } \ +} while (0) + +#define RTE_TEST_ASSERT_FAIL(val, msg, ...) do { \ + if (!(val != 0)) { \ + RTE_LOG(DEBUG, EAL, "Test assert %s line %d failed: " \ + msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ + return -1; \ + } \ +} while (0) + +#define RTE_TEST_ASSERT_NULL(val, msg, ...) do { \ + if (!(val == NULL)) { \ + RTE_LOG(DEBUG, EAL, "Test assert %s line %d failed: " \ + msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ + return -1; \ + } \ +} while (0) + +#define RTE_TEST_ASSERT_NOT_NULL(val, msg, ...) do { \ + if (!(val != NULL)) { \ + RTE_LOG(DEBUG, EAL, "Test assert %s line %d failed: " \ + msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ + return -1; \ + } \ +} while (0) + +#endif /* _RTE_TEST_H_ */ -- 2.14.1