From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0063.outbound.protection.outlook.com [104.47.32.63]) by dpdk.org (Postfix) with ESMTP id 01EA531FC for ; Thu, 11 Jan 2018 11:23:10 +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=ZOgJtwGqqMtAt4vQFhkOKbZPZ6+UqP/vWOOAE7ZGz3k=; b=FZGDQ8uKoPnPaxnjLyaj6yweLvDOHv/YAT7ogyDBMUAyTuA7TYePe5/uXaJ+FzS9+Y57ueCJnH5zkbjs3AE6forZbzykjX+NLv6ZzKgR4HELwUNMSzPQxKdxxMbrZZE/Ovos1H6By7NwLes/0JZiFUMIaZqrJumiMEM5p5+Vu0M= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from Pavan-LT.caveonetworks.com (111.93.218.67) by CY4PR07MB3464.namprd07.prod.outlook.com (10.171.252.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Thu, 11 Jan 2018 10:22:21 +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: Thu, 11 Jan 2018 15:51:46 +0530 Message-Id: <20180111102156.12726-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: MWHPR2001CA0023.namprd20.prod.outlook.com (10.172.58.161) To CY4PR07MB3464.namprd07.prod.outlook.com (10.171.252.145) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: db77410f-e162-4217-ff49-08d558dd3447 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:CY4PR07MB3464; X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3464; 3:9oZr9S1JrFCrWLEScVLtQ64daWY/9VQFTWMY/v1gtCdJIWkld79/3DBNELrXZIrAbLHD5O9S9v4liMD2xa9VGD48nX8Yy76ujDUcIUCpiuhmlzxr+mJg5K1e46mmRxS0f/UrMtOorPCVWNwajzM1dT2lDnWDjTzUaQBPlNU/umi8bE5Q6Xu/GnOZoTndkk4P9JGvSUE8czywfMEtrw/EFM7Xe94yxPkMAcRPscw5zMGKvqp2xNSWY3Op0gcN1nbJ; 25:bILJOLhpb4+heHDN2d8Quqb2AeTy73O3JPDkQtULkLnJ1H7/MIJXjoVHD0DxkaVPyfFGYS0sDTCoV1XVN99ljsQmCpRGdSdHQbfcmh7DoidjO2Sjsd8gDVledYW0lfVZf/St/WsGjLUKNXSqLOql73cgYT1w4cLIFASpVyGBYqiwJ1gdMQnLvntoI3iU9MYiHUyPwHqENco0FKCU5z4EJsetjdg44ImbARMwpDtk1lgGO5i44JkCrMjjlIXg+1lY5uoyBTdRNE0XONYVaqGIoe9ctz6I2J6gpJrF4uyoGYNXW2QArzRoNAJuR68K1Ez1Wv2sxPrhuMh5yEJJgRDBtQ==; 31:PzShXymU7bljS5QYisYu+WdU+h9TXEW1ALigCzkF1pTK3aLpWQFpjtQWFl5ggI4SDDykidhP7037sMg9oBAbsTcPy0BEfqsBzR/yzlou5P2jQEtzQsy6IrjW+LF40kErIkdcSKEZoAVotx2PBg0b6KeN5hYLudYNVpBfhIf7stEvRBa7UAMSdFndnhcXoYB41jOb5HKC/tDPHh2IKbwLVP4XUpsxUtM/CTCv/6MoCho= X-MS-TrafficTypeDiagnostic: CY4PR07MB3464: X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3464; 20:YXBygSxZEJe0v0paS1b6k2yh9D5+PHpkVT3omSJ+c86EfVqa2dW5tczciIP4oHy0myR+sVbC10MvZzMmIU0gEvU0JMqDvVsC4LYAXORhZSK0+8xOfXN3tGB6M/Xlo4aRTbafUyNRWVD7C9+huDNxwWfj1dwcH1DxZHIsdpFSiX2xsgWr/IY+1Gj0LS2g2Be7eYwEFFwNzeRIV47donl4Xx4V7psWDhDwjQvFJ2Av2nPF52KtN7GA5JotG5tXPbyvyK6xu1PWTfY/Df35NoEYoD/yF7FtP5gkbtLuuDZPCSw1xwlUg6MevWtJH4/T1nfdBqfcLrGoRLbA2llO00Lz6Ti+yYiLTmQqEXlIPqs4SCroANUxrvYPPxpp8X1acimnMD4cCb7rojdB/YzRpiTSo6W10QHF3fPCrA511PwfGqNHZo5rzxoTnWKfxidDD/G9OFPd8zPZsxUk6fwCP/bmaxU2mWx7KFvze0MHrLdona2GKO1pXGWJMNVR3uT3lRVMpb7lL+dolhidWS9u1j4jL1JMWk0tKBbZ6NXHWp2aaaUnkOVKUcJ0gF+0alBnDEDNuaOVhBL/Ur3mWPdCW5ThzcKE7onEatoYvchfBfjWRSY=; 4:dgVgIx0as9AwM5KoRPQsoZoI/WCe9P5eEEo0sW1rZm86pBf+2TmT3NHimJh9q0kkc4a2nFqSZ28epeMXXmbeWlIICmBO/2xLPKa7Xr7x2Dk8ECQdrIrWTW/qEb2jkIIzGor+C5ksD4eEwHSfDJ0se8a8PsvCjJyNXQ2Tj7Sgk4IUHshVXgpIDlkjvPfKcQoz1O1IUeYAiYNsInNU3miTiLSNRmGqVTUHDN7ps0JVkcMd0eUUmLFddNaDdI5HiQ6/Uktvhzd3WcEkcfCv/Aaydw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3002001)(10201501046)(3231023)(944501075)(93006095)(6041268)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(6072148)(201708071742011); SRVR:CY4PR07MB3464; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CY4PR07MB3464; X-Forefront-PRVS: 0549E6FD50 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(39860400002)(39380400002)(366004)(376002)(396003)(189003)(199004)(6116002)(2906002)(8676002)(6506007)(47776003)(97736004)(53936002)(5009440100003)(72206003)(1076002)(16526018)(53416004)(51416003)(66066001)(59450400001)(50226002)(16586007)(386003)(76176011)(25786009)(6486002)(316002)(69596002)(48376002)(42882006)(106356001)(52116002)(8936002)(6666003)(7736002)(6512007)(3846002)(81166006)(2950100002)(575784001)(4326008)(478600001)(107886003)(5660300001)(81156014)(68736007)(105586002)(50466002)(305945005)(36756003)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR07MB3464; 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; CY4PR07MB3464; 23:ZcS7eRoS9yujSA2+ZZbBh66S3OvapuADC+Qn1OfpD?= =?us-ascii?Q?1g7jaiT1e7kKs+9WZdNXg20IVT7pJXsaeM25XbLMSL86tSzuR0UAQL2hlZpo?= =?us-ascii?Q?uPJHUiCIKjKvdMGmQQxiFzT+JdfhwpSqY8k4ify/YXlZcEK0JDUEFj8u85K6?= =?us-ascii?Q?6CjIHV79j38BXAELc2Sy1GaHFidBtN3+/gvC/odX+6Fp5cssASuJzBx2PG13?= =?us-ascii?Q?ALeU5Xsw0pgGPrSxUANuI7SdS6mmWQvT5tvFyfjkQrxUkWCrsSSw9uxiGzQc?= =?us-ascii?Q?eyWlTarhzVNOeMxtimygcTD4nScdT70tHqlg4kjc9co7KtPc6mHiUE2ldoRh?= =?us-ascii?Q?0WI6cehtyPKUo+nb0gAVEkcocFyj7q/pqWsd1UP/RdJvUNMhmM3nPu7mSgmg?= =?us-ascii?Q?klhdeyrfcUQdrFyn7xjlwfYNGgE7MNH64udUX64SU/iFBCMME/pLxoYeY/hW?= =?us-ascii?Q?veHrgbG0T+c0qHrN5MEGXJmYq/gNLckqJLTtLcGa3tUewlZT/JZd/w74vpah?= =?us-ascii?Q?s/lwfd1JeVktYIDb5EHm9lf9/bxqJxFK8AM2ZeVW1KjMu/f5iAl+/xFSQoKy?= =?us-ascii?Q?JGjl2cnvIDiNSLB8Eky9ovH7c4C7LSMEwfjtvP+UdPx58LJoaktKzNe8rWvL?= =?us-ascii?Q?thhe9F+A/3+d2Wat09+z105P0Aczcaa3vTOsc83fkojB/3f+F2vViONs/cxW?= =?us-ascii?Q?vw2oQu1NBQY2+3eI0qNmyWc179T8SxEOuC64bf9aPXIcj72jywmfg5HAhOqG?= =?us-ascii?Q?p3bj3Tibyb/Rhv6F0SPMq8QI39M2tqkKp3pcjBqpzunft+OUife/rB7NUTuW?= =?us-ascii?Q?Ltzj85/KoBzzRCm6i6mAkQaKr6V8z7rn4bntncHeDkm7YAod0tPaOJ2/4iaa?= =?us-ascii?Q?5AFSA47bBPIMV7zBpiEuO6IakroRJFukIJF7JX0Q2dXCOIpDUqMviQj2VExe?= =?us-ascii?Q?/RAzVpyGWXVapKdca7TYLe75JrLVSTK+HCXziHcunPHph9JMMtxVylTgYP1f?= =?us-ascii?Q?N6TI8uOoeCXtoFZOt5ww064gigW+WJ9FuE2QFnmknqVf9qRP4SxKNnepoC/8?= =?us-ascii?Q?Rbs9V57N3vrM7zt1kCyrEB2lPvrefDQkpARRRFSYjAvH/YmHA43jUqW7G9a4?= =?us-ascii?Q?PLAlHuDPdrijE/f0zS08cN6beZeg5RMKmu24CDohPKg9DYMW1ObuChqFtgsf?= =?us-asc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SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2018 10:22:21.1724 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db77410f-e162-4217-ff49-08d558dd3447 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR07MB3464 Subject: [dpdk-dev] [PATCH v5 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, 11 Jan 2018 10:23:11 -0000 Adding common test assertion macros for unit testing. Replaced common macros in test/test.h with new RTE_TEST_ASSERT_* macros. Signed-off-by: Pavan Nikhilesh Acked-by: Jerin Jacob --- v5 Changes: - rebase patchset - remove duplication between test/test/test.h and rte_test.h by mapping RTE_TEST_ASSERT* macros to test.h v4 Changes: - add SPDX licence tags. - change octeontx selftest name to 'ssovf_evdev_selftest' 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 | 46 +++++++++++++++++++++ test/test/test.h | 70 +++++--------------------------- 3 files changed, 58 insertions(+), 60 deletions(-) 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..89e47f47a --- /dev/null +++ b/lib/librte_eal/common/include/rte_test.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2015 Cavium, Inc + */ + +#ifndef _RTE_TEST_H_ +#define _RTE_TEST_H_ + +#include + +/* Before including rte_test.h file you can define + * RTE_TEST_TRACE_FAILURE(_file, _line, _func) macro to better trace/debug test + * failures. Mostly useful in development phase. + */ +#ifndef RTE_TEST_TRACE_FAILURE +#define RTE_TEST_TRACE_FAILURE(_file, _line, _func) +#endif + + +#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__); \ + RTE_TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \ + return -1; \ + } \ +} while (0) + +#define RTE_TEST_ASSERT_EQUAL(a, b, msg, ...) \ + RTE_TEST_ASSERT(a == b, msg, ##__VA_ARGS__) + +#define RTE_TEST_ASSERT_NOT_EQUAL(a, b, msg, ...) \ + RTE_TEST_ASSERT(a != b, msg, ##__VA_ARGS__) + +#define RTE_TEST_ASSERT_SUCCESS(val, msg, ...) \ + RTE_TEST_ASSERT(val == 0, msg, ##__VA_ARGS__) + +#define RTE_TEST_ASSERT_FAIL(val, msg, ...) \ + RTE_TEST_ASSERT(val != 0, msg, ##__VA_ARGS__) + +#define RTE_TEST_ASSERT_NULL(val, msg, ...) \ + RTE_TEST_ASSERT(val == NULL, msg, ##__VA_ARGS__) + +#define RTE_TEST_ASSERT_NOT_NULL(val, msg, ...) \ + RTE_TEST_ASSERT(val != NULL, msg, ##__VA_ARGS__) + +#endif /* _RTE_TEST_H_ */ diff --git a/test/test/test.h b/test/test/test.h index 08ffe949c..0ea18586c 100644 --- a/test/test/test.h +++ b/test/test/test.h @@ -38,7 +38,6 @@ #include #include -#include #define TEST_SUCCESS (0) #define TEST_FAILED (-1) @@ -50,23 +49,13 @@ # define TEST_TRACE_FAILURE(_file, _line, _func) #endif -#define TEST_ASSERT(cond, msg, ...) do { \ - if (!(cond)) { \ - printf("TestCase %s() line %d failed: " \ - msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ - TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \ - return TEST_FAILED; \ - } \ -} while (0) +#define RTE_TEST_TRACE_FAILURE TEST_TRACE_FAILURE -#define TEST_ASSERT_EQUAL(a, b, msg, ...) do { \ - if (!(a == b)) { \ - printf("TestCase %s() line %d failed: " \ - msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ - TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \ - return TEST_FAILED; \ - } \ -} while (0) +#include + +#define TEST_ASSERT RTE_TEST_ASSERT + +#define TEST_ASSERT_EQUAL RTE_TEST_ASSERT_EQUAL /* Compare two buffers (length in bytes) */ #define TEST_ASSERT_BUFFERS_ARE_EQUAL(a, b, len, msg, ...) do { \ @@ -134,52 +123,15 @@ } \ } while (0) -#define TEST_ASSERT_NOT_EQUAL(a, b, msg, ...) do { \ - if (!(a != b)) { \ - printf("TestCase %s() line %d failed: " \ - msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ - TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \ - return TEST_FAILED; \ - } \ -} while (0) +#define TEST_ASSERT_NOT_EQUAL RTE_TEST_ASSERT_NOT_EQUAL -#define TEST_ASSERT_SUCCESS(val, msg, ...) do { \ - typeof(val) _val = (val); \ - if (!(_val == 0)) { \ - printf("TestCase %s() line %d failed (err %d): " \ - msg "\n", __func__, __LINE__, _val, \ - ##__VA_ARGS__); \ - TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \ - return TEST_FAILED; \ - } \ -} while (0) +#define TEST_ASSERT_SUCCESS RTE_TEST_ASSERT_SUCCESS -#define TEST_ASSERT_FAIL(val, msg, ...) do { \ - if (!(val != 0)) { \ - printf("TestCase %s() line %d failed: " \ - msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ - TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \ - return TEST_FAILED; \ - } \ -} while (0) +#define TEST_ASSERT_FAIL RTE_TEST_ASSERT_FAIL -#define TEST_ASSERT_NULL(val, msg, ...) do { \ - if (!(val == NULL)) { \ - printf("TestCase %s() line %d failed: " \ - msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ - TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \ - return TEST_FAILED; \ - } \ -} while (0) +#define TEST_ASSERT_NULL RTE_TEST_ASSERT_NULL -#define TEST_ASSERT_NOT_NULL(val, msg, ...) do { \ - if (!(val != NULL)) { \ - printf("TestCase %s() line %d failed: " \ - msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ - TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \ - return TEST_FAILED; \ - } \ -} while (0) +#define TEST_ASSERT_NOT_NULL RTE_TEST_ASSERT_NOT_NULL struct unit_test_case { int (*setup)(void); -- 2.15.1