From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0067.outbound.protection.outlook.com [104.47.33.67]) by dpdk.org (Postfix) with ESMTP id 295DA1B38B for ; Mon, 25 Dec 2017 20:18:28 +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=gvYFadTDXKEhXFocgDgqzWcoFpQuharGyJkyzpFGxHk=; b=gd5vTpBtp4Ai17YJvRSmQu9s/g0L9ro7W0f8fxR4lKCjh2GDBzNkDddZKvt0aIzPhvYgB2GWB19mEbFOQ34lG4VH3oZ4tbjsPBYgbJi3eQISJnjRpz4BeHZScsP8nHKWkaqkukHOO+n5muOPTil2CcMl0Yp5FLTQS9sSwzSa5CE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from localhost.localdomain (111.93.218.67) by DM5PR07MB3466.namprd07.prod.outlook.com (10.164.153.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.14; Mon, 25 Dec 2017 19:18:24 +0000 From: Pavan Nikhilesh To: jerin.jacob@caviumnetworks.com, harry.van.haaren@intel.com, gage.eads@intel.com, liang.j.ma@intel.com Cc: dev@dpdk.org, Pavan Nikhilesh Date: Tue, 26 Dec 2017 00:47:28 +0530 Message-Id: <20171225191738.17151-1-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171212192713.17620-1-pbhagavatula@caviumnetworks.com> References: <20171212192713.17620-1-pbhagavatula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: SG2PR0601CA0004.apcprd06.prod.outlook.com (10.170.128.14) To DM5PR07MB3466.namprd07.prod.outlook.com (10.164.153.21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b77daef5-5a41-4311-fdf8-08d54bcc4612 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:DM5PR07MB3466; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3466; 3:AJPjdoxO1ASqlrCFilZ93j5pChyo+73EAMGtH9EdZUQ+Cp2Z4AcZIfDVIfOSLRWve5Px09nOHC8VuVD7kXfHdPuLh08egmjHaekMTC6+vY6HBJynW4JzIMdjPiy0j94nVO2gSU/Pj0jN6pf0baWeOacPUf838ZYQgfDggbtwwGdtaf+Bd7S2XElys9Pbux9lT7oUUYzq1UM3F0ta/8Psn0lQU6CuAPk5jWMGToI4NsjfoVj6n7kzPg0heE35fYZM; 25:emRxiKSrwdlcv5a7RYslRRNCnaNd9ghCxWwCTpIkqEOPrerXwAfxHBNcurTacsoJBkvAC2+VBSBAhqXmFQE5HGvr3+Uq60I51Yb1qEuQ4QJ2j3vHZtfPsMKuQt0LbGyjn+6YiQniw2dPJCg5iBchzSEyNY1d9SZNbL86eRR11B2nZfavTHLWN034Y5tHMKD5LOL0rcqOnIIw+dGvAAJ04nUY/c9b/L5fOselpIYPoi5CqzE8o4qDMgqEJp2xh3GfkzujQIQqoOCNJjIH4lQMLLdkSTq4DuHZhDuRdUZOWOI6oml6AWGaRN9fF0/iwNDDyYVVc730k1CIjVkIuCNUmQ==; 31:ivsmGAI0YRFaOvekSOUqUwNmKdYJ4t1cLXew91N9D1HvTcoQGldA/4aataRl/vYrko4eFnWFe9ujlNyUqmjYjDkgf/D1vamhoGXSObCWro6FF6AmlwxGfGTYEqdQPKbgKC59rYTRYFzXHM5spwwEeJgQgAqMJqW2k4FyEpZWMvYJfnbTu6KjkOg2IAi8ytC+r7U983yrCe/m8zUWvw6XE0GbufLi2kFW8u6xhj4fH1U= X-MS-TrafficTypeDiagnostic: DM5PR07MB3466: X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3466; 20:jEqsk+9ivnfFw4lVk8RuA2+8qLnsOGjFYrf3h97SaSyJce08UIFOnZofFXgqutHFP+3DPSzFjgU9/M56mufwgonIabjOUuidhy8ZqJHbuKc1qz1UJAirdY8rmUCO7cj5Z9QWVdrnFlWYDrHXXebng62TSfF/qD2erZ4uuTFI+liFFGMk8p8UeS5HCAK6+7O4wFzTF4C7UjkNOw590hIbGJV42/KKUyS/yT62+8iXXsqbdU9JUYWJYgBYfY20BwYNm0usVGzfLkL4/ZfRPIzVaJP5vz46APVxHKXJhsC7Gd6J4eseLg4oBI0goHEM8mnzIlgmu39CMaJ33wzgszxi2uPh7q1XAx5aellh8dYYAtX1VXEY7m6xRNnMm2+XcVQXA2IWR0p1lA5xQ2HWii14uIQgFPbjtosBpHiWmebJeic7BY95N8X3zeuNw1Z16aTrGp/SJnCOnwoaNGQKpkkmI32IQnxyCNnNahHX9+KXKYa4g1OnfBekUR1LdO0IEXj6bOlAdXeNv2YgXPFYktMDjhPdwRAYrM9AyaiPD2QhmIQ24GwkMPcpLe3+GC4f1lXTwOICG1WCr7NPcv+jWxCd2vGN1fnm6Vw/euJyQdwpvsE=; 4:3zkPkOwRt8Ey73eQB53qLK/Nyga6Usku0XgblnJlkVZQUHSbGjKRt3SXoiQPNSkFmatQTCZQvySy1JZlgXRZQaU2mKSdabzY+vUKWrXA54Zcgp+AWotMcy1sYWrGWrvg+FC0vf8oXx018MhkdB9DoBaA6OR9DDbC8pLZFcqKSST03YDAT2FefWNdi7vcNqaUL7TL6DrlsfXcBlZkAsO7yqTSWFP2FVqsqSEI0ioXU5ZvgwWFqtbkZe51tnyyL1/HEBzJC4jQgF9VOwVz4tfQgg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(3231023)(944501075)(10201501046)(3002001)(93006095)(6041268)(20161123564045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011); SRVR:DM5PR07MB3466; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:DM5PR07MB3466; X-Forefront-PRVS: 0532BF6DC2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(366004)(396003)(376002)(39380400002)(346002)(39850400004)(199004)(189003)(36756003)(68736007)(5009440100003)(7736002)(66066001)(81166006)(478600001)(81156014)(305945005)(47776003)(16526018)(8676002)(59450400001)(6506007)(386003)(316002)(97736004)(16586007)(5660300001)(52116002)(106356001)(25786009)(53936002)(48376002)(2906002)(105586002)(76176011)(51416003)(1076002)(3846002)(107886003)(6486002)(4326008)(50226002)(72206003)(8936002)(6512007)(6116002)(42882006)(2950100002)(50466002)(575784001)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB3466; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; DM5PR07MB3466; 23:WIqrjR23uLTRU/Wk2renY5VmWKVB4z9dOJmkJsx/7?= =?us-ascii?Q?i+ITr4yT/O3MfmbczqyIH/Q5taxjvU3tuMpONjHZ6sSCEfy9skAt10+dw38V?= =?us-ascii?Q?OaCjbH5uyCFSaMZThERG0lNM+8R9r/dRTXCq/ONifN2Sp/9lverOTe8Svkre?= =?us-ascii?Q?Y4kwikLH8FO0AVC1L/gabjNYu4pxNC8EmbVoyeTZKS1dHnmVfG78KuF7zbF7?= =?us-ascii?Q?I6hMiwN70myUyk0WXS2gdH2aXH2kzQhfeQRktwr0fNZVOnhznGJPBJAnxCdQ?= =?us-ascii?Q?MhKAKw5RNxZkFD3tOJn7E9B1ipqd5wbnOUf+cTfYTfbcI+1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CdvPAvRl5ffCICk7jznyyOFPU7/56A=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3466; 6:xP/Nj98dV316H5HewmnMzxug5yqio4k/3vRT98QafdyD8D2gNpsyMLEfFdEWGjf10Yva6KKBfSSwiKxTNXMH+sDCu0a7F4nOQ6VQJEGCkTNllWf695cTp4fXAJA/WfoWZsgYObBr1jLfmZJtuh23lAcM5HPGYT3FGeDwxEpecAncZKpU7jw5rnCeN9HAzB5ERxgAtanZgJBog9+t4uCQ+RRhrwBhg8J/KwDlIrDMieEbOIhgFoIdZZtd6DR2iGieTGkNcNyyksi5+04kWISy0sv9PcW+vhkYZmkzwsEs0f24/f9hNYPpXaSLtcYBAQ1h7/ZaSa7AG3Dk/354OGYYcUJ2jpGKCJ56YpvSr/Hvngc=; 5:l74Jn2FQawRje1Ki6IO1Tg7G00UKA+244J/lGZV8oPxudkYq+Iwaabro/oJjDGkaLzTq8UG19kdn6fKg9KUJCl5cM9kHQAbrHP8hS3UWlL97c2yREvJjJomXfNFFPYZu7e4cOUEiPl3XFBPAUPu4EAhdvVlhqGhSuNsqgA/yQ90=; 24:CzexlcBn1OdsGAcFMdUisVF7QrC/AZpsk1h4BMySrKI4HfAuKofSrhE2aaP19FfUZe7z5Oqnv47WMDOmk8+USSBRfS+rqe3gWrePjbZWF48=; 7:lqpFgYaueYY0eHVcnZ6l8I65ZZvB+2BIEZ/tDlS8E98as9l0nA2iKvtLdVHY15Hdz5vZXuZJwEOahMca1NtaCHN/BT+B0ddPzBYhJ2BOqdnpT33i01wlEHMfiv1raloNDIKYje7oLZ0wUSIZ46hkVCifo6ZdfCJ+TC72MDfAzj3jXvmE6dUdwoD1Wwfgugnk6rdwdm7tnqXEp53HP8InCYm3fwNP1WnNYsazn7Fm1hKFy0TihVh6EeB0UHZ1+aPW SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2017 19:18:24.1041 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b77daef5-5a41-4311-fdf8-08d54bcc4612 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3466 Subject: [dpdk-dev] [PATCH v3 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: Mon, 25 Dec 2017 19:18:28 -0000 Adding common test assertion macros for unit testing. Taken from test/test.h. Signed-off-by: Pavan Nikhilesh --- v3 Changes: - add eventdev driver specific selftest to test/test v2 Changes: - remove duplications of test macros. - add selftest to test/test. - remove selftest devargs from sw eventdev. 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