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 E2298A04C0; Thu, 17 Sep 2020 18:26:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 450181D6BA; Thu, 17 Sep 2020 18:26:37 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id A914F1D6B8 for ; Thu, 17 Sep 2020 18:26:34 +0200 (CEST) IronPort-SDR: T4gt2lA8ImYp2StRYB0vNPO/p/J1YHMQBVCilw8nEVGKVrCvEHhXrK9zi1Ow+acdVAly4bwLcQ y6jJSvRS4QjA== X-IronPort-AV: E=McAfee;i="6000,8403,9747"; a="244571188" X-IronPort-AV: E=Sophos;i="5.77,271,1596524400"; d="scan'208";a="244571188" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2020 09:26:30 -0700 IronPort-SDR: /00WTFnjspL8NnCRbxPobUZaMQxypV68NHSBv0ZuTe7uCvOLrsSlZNFMcF01BCyFQ+yR1vr7ZY XTe9rvqL3FzQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,271,1596524400"; d="scan'208";a="287639967" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmsmga007.fm.intel.com with ESMTP; 17 Sep 2020 09:26:30 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 17 Sep 2020 09:26:29 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 17 Sep 2020 09:26:29 -0700 Received: from NAM04-BN3-obe.outbound.protection.outlook.com (104.47.46.58) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Thu, 17 Sep 2020 09:26:24 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n/49BgK7Sapfq3hR0z99xwRdk8tlqFfrIu5ezv8OEYkXhOpWCaPawiUaaZNf38zc6TT6vlvPGNN5ZV29A9X5T4TG0CuGUTJNbN82LsOp1LT5SZy9J250VhX1oGtrDmKhnE77o1bjmryB4yOpb/Zw1XSnJ0tz9lOnzcXvLVoJWNz4ucFeeFPJp+llKS3SjbWVfcokDKWzQ+b9Gg2kxrnKZUXo+Bcaa/AVnqU8iRkBc6JxGlmK/v+preslIHk6Vdk54PlOedKxgXN7n6tCX2+u/EXzxl1f8pTKuYRtmam86r4S45ejTtLHiS6Sl6fiapNg1TrrK8zWwKadDoFj616ZGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=//YGz7OHzkeWfqj9ZGJeWZCv9O8/bACZZl16RHfa2iw=; b=XiNNnExTtSnIzgf1iJu7QyKvjGkGUJYHx4ATa4LzYQDKRRpEvde/haZtDZ7q3xgvB02Xl4Nj78j85Niv4obB0ZJpEXXpEtcqP9dkvVRhGlA9dIHYifyO+eko1O/I8aFfAZWiu1ccsPQWMLXRtQqxvB2EFNNgYVFZBLXyDUc4Xk1Z1Z8NYEE76caCVYKYy5g7OMuZcaFm7T1sEtn3LmHEOYVwskc71sA3p54IqR4CZvmn6FpcW8PAbSpkvL9fZVFRgGLFN/JSGLGR7J93CLzfPx7AipIbg0kF+8LuGCbytw77GEcWrzNYPnAgbpt2mF/DznosRtBD+tTJSmJKAH5A6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=//YGz7OHzkeWfqj9ZGJeWZCv9O8/bACZZl16RHfa2iw=; b=I7HtXPm3E0ACrpFHawTeVQIsDhyNfGhYV9/Nov9j9wpGbMcKZ6dnDhf3VvNgXXBPZEIOgFgrM9Gllx7sEynU1cvenBEOtvmd/Cp98GrYc1VrnQlsT+xAeWTNhwWn0JlLUdigcYywp7exC9ajp+yex6StBdvX+7yueUmZtkG6+iY= Received: from BYAPR11MB3301.namprd11.prod.outlook.com (2603:10b6:a03:7f::26) by BYAPR11MB2597.namprd11.prod.outlook.com (2603:10b6:a02:c0::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Thu, 17 Sep 2020 16:26:23 +0000 Received: from BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::f43b:a137:dab8:8b0b]) by BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::f43b:a137:dab8:8b0b%6]) with mapi id 15.20.3391.011; Thu, 17 Sep 2020 16:26:23 +0000 From: "Ananyev, Konstantin" To: Feifei Wang , Honnappa Nagarahalli CC: "dev@dpdk.org" , "nd@arm.com" Thread-Topic: [PATCH v5 7/7] test/ring: improve the application of macro Thread-Index: AQHWiylzjuN2EGrcrka7wICPFBcVH6ltBh0w Date: Thu, 17 Sep 2020 16:26:22 +0000 Message-ID: References: <20200729063105.11299-1-feifei.wang2@arm.com> <20200915062749.21374-1-feifei.wang2@arm.com> <20200915062749.21374-8-feifei.wang2@arm.com> In-Reply-To: <20200915062749.21374-8-feifei.wang2@arm.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [46.7.39.127] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9aca5d14-b445-4f10-93f9-08d85b266ac0 x-ms-traffictypediagnostic: BYAPR11MB2597: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1227; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: fHLsWJUD3ZZNjhSHNa1VYS8dKBF8dyv9WsejFEEWMFYW3DTHWWXwMqAHL9DsduSIlf4tm0Ybe6Jz7mRIF/BPWTqs1w3tKijPrCNxiqBhf9cmZYWVuvXR+WB5pa41e7BjIZjrjxWx/YIRr2JlOx6TimoOv5RPaMdK2Zb8yvbOeGS4FLxTWGGYci4zGn6UJ7a5Nvdm9BvK6n2Y4FtTQvY552iuFwGH3TXoJkDbw/3YEStlbQMiluG1K6kqSXcnrMfyAToKr2JLmnDFcpg511WPZBDnY72/JnWtC/gnxFGkdT2IxMDAB1SuMpxinJn+Rt21paOaMjSvipSnbrNSKNDqMUrSdwIZiUDIpj9uhNgSXNoIUrRPhv7u9ZTX3OLB8t5r x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB3301.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(346002)(376002)(39860400002)(396003)(366004)(86362001)(6506007)(8936002)(316002)(64756008)(66446008)(66556008)(54906003)(83380400001)(30864003)(2906002)(7696005)(8676002)(33656002)(52536014)(478600001)(110136005)(5660300002)(76116006)(26005)(186003)(9686003)(66946007)(71200400001)(66476007)(4326008)(55016002)(579004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: yF7m3u4MvJ8qU4+i+yhb6nbxqoAFzUVaMaocaJSNCJvu+S8R1hO3QVegmzylfxB4UyVsYRqdvOFt2EtbvA64JX/WQwOt7bn/t8ceLDfAzGtEbB+0wqc1HMOGLPF+QqIm8MCHZ38z/F6xmQpds9SElUQZVPG5s1OqSlq5XkgkoWm1CAjAxEkvviQ24CWrGvzjfK1iA8uEsDn9CQW+q3ZTio4ED0DmO37eHitAhe9kJvbRQhNrRXi8paXHiAORbONUcvOxJPKCiRK1v1Ws/s6dH2ZM9HUQcLhTHupCIhfMfBwhTSrdqATu0ZMrg82tbpek7r28Dvue1QKVYhgrAnGYYWeOe+g5W0cn0EYR4ZJ54BVNyGzh+hb2sjM+vZcIEb0AEFT3/3P90wSYfllWmVvZcY987ahZDyDPZnUIJRRwEZYvkE7KBqEUspy3XYg7RRY5sm1k5p1mp0A/p/x8SBYrhroYgqn4SAQNU2oR2Bwm2awzrB7mWVUgHEiUfowlm96ac655AgAaytSjUGJJVds5drFY320eqrruV4/b99G/9OO7beau2aHDZHUS/yer4k+vCKGqQDyt3Z5we1D/zOewb9Fs+mlyDO1jmVT+yAq4MROpzDE124GAABA4aHXgj2zagKRbOWv81Ru1YZKdNf7NTg== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3301.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9aca5d14-b445-4f10-93f9-08d85b266ac0 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2020 16:26:22.8646 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 3KpDf9gYlbFOXk6rJz2dtTQdYhbuexJvf0T51HEnuPuhsBaCCw+n1ezNGkzvN1piWxXkujo4jl8g2GR8fpavVzUZBMG322Ht/yfYmVihLS8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB2597 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v5 7/7] test/ring: improve the application of macro 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 more parameters into the macro TEST_RING_VERIFY and expand the scope > of application for it. Then replace all ring APIs check with > TEST_RING_VERIFY to facilitate debugging. >=20 > Furthermore, correct a spelling mistakes of the macro > TEST_RING_FULL_EMTPY_ITER. >=20 > Suggested-by: Honnappa Nagarahalli > Signed-off-by: Feifei Wang > Reviewed-by: Phil Yang > Reviewed-by: Dharmik Thakkar > Reviewed-by: Honnappa Nagarahalli > --- > app/test/test_ring.c | 266 ++++++++++++++++--------------------------- > 1 file changed, 99 insertions(+), 167 deletions(-) >=20 > diff --git a/app/test/test_ring.c b/app/test/test_ring.c > index fb46614f8..605b620ce 100644 > --- a/app/test/test_ring.c > +++ b/app/test/test_ring.c > @@ -46,15 +46,25 @@ > #define RING_SIZE 4096 > #define MAX_BULK 32 >=20 > -#define TEST_RING_VERIFY(exp) \ > +/* > + * Validate the return value of test cases and print details of the > + * ring if validation fails > + * > + * @param exp > + * Expression to validate return value. > + * @param r > + * A pointer to the ring structure. > + */ > +#define TEST_RING_VERIFY(exp, r) do { \ > if (!(exp)) { \ > printf("error at %s:%d\tcondition " #exp " failed\n", \ > __func__, __LINE__); \ > - rte_ring_dump(stdout, r); \ > - return -1; \ > - } > + rte_ring_dump(stdout, (r)); \ > + goto fail; \ > + } \ > +} while (0) LGTM, just one suggestion for the macro above: Instead of arrange the whole code with the same label, why not to simply add control transfer statement as extra parameter to the macro: #define TEST_RING_VERIFY(exp, r, errst) do { \ if (!(exp)) { \ printf("error at %s:%d\tcondition " #exp " failed\n", \ __func__, __LINE__); \ rte_ring_dump(stdout, r); \ errst; \ } \ } while (0) Ans then just: TEST_RING_VERIFY(rte_ring_free_count(r) =3D=3D 0, r, return -1); or=20 TEST_RING_VERIFY(rte_ring_free_count(r) =3D=3D 0, r, goto fail); or whatever is appropriate.=20 With that said: Series acked-by: Konstantin Ananyev >=20 > -#define TEST_RING_FULL_EMTPY_ITER 8 > +#define TEST_RING_FULL_EMPTY_ITER 8 >=20 > static const int esize[] =3D {-1, 4, 8, 16, 20}; >=20 > @@ -316,7 +326,7 @@ test_ring_negative_tests(void) > RING_SIZE + 1, SOCKET_ID_ANY, 0); > if (rp !=3D NULL) { > printf("Test failed to detect invalid element size\n"); > - goto test_fail; > + goto fail; > } >=20 >=20 > @@ -326,7 +336,7 @@ test_ring_negative_tests(void) > RING_SIZE + 1, SOCKET_ID_ANY, 0); > if (rp !=3D NULL) { > printf("Test failed to detect odd count\n"); > - goto test_fail; > + goto fail; > } >=20 > /* Test if ring size is exceeding the limit */ > @@ -334,14 +344,14 @@ test_ring_negative_tests(void) > RTE_RING_SZ_MASK + 1, SOCKET_ID_ANY, 0); > if (rp !=3D NULL) { > printf("Test failed to detect limits\n"); > - goto test_fail; > + goto fail; > } >=20 > /* Tests if lookup returns NULL on non-existing ring */ > rp =3D rte_ring_lookup("ring_not_found"); > if (rp !=3D NULL && rte_errno !=3D ENOENT) { > printf("Test failed to detect NULL ring lookup\n"); > - goto test_fail; > + goto fail; > } >=20 > /* Test to if a non-power of 2 count causes the create > @@ -350,23 +360,19 @@ test_ring_negative_tests(void) > rp =3D test_ring_create("test_ring_count", esize[i], 4097, > SOCKET_ID_ANY, 0); > if (rp !=3D NULL) > - goto test_fail; > + goto fail; >=20 > rp =3D test_ring_create("test_ring_negative", esize[i], RING_SIZE, > SOCKET_ID_ANY, > RING_F_SP_ENQ | RING_F_SC_DEQ); > if (rp =3D=3D NULL) { > printf("test_ring_negative fail to create ring\n"); > - goto test_fail; > + goto fail; > } >=20 > - if (rte_ring_lookup("test_ring_negative") !=3D rp) > - goto test_fail; > + TEST_RING_VERIFY(rte_ring_lookup("test_ring_negative") =3D=3D rp, rp); >=20 > - if (rte_ring_empty(rp) !=3D 1) { > - printf("test_ring_nagative ring is not empty but it should be\n"); > - goto test_fail; > - } > + TEST_RING_VERIFY(rte_ring_empty(rp) =3D=3D 1, rp); >=20 > /* Tests if it would always fail to create ring with an used > * ring name. > @@ -374,7 +380,7 @@ test_ring_negative_tests(void) > rt =3D test_ring_create("test_ring_negative", esize[i], RING_SIZE, > SOCKET_ID_ANY, 0); > if (rt !=3D NULL) > - goto test_fail; > + goto fail; >=20 > rte_ring_free(rp); > rp =3D NULL; > @@ -382,7 +388,7 @@ test_ring_negative_tests(void) >=20 > return 0; >=20 > -test_fail: > +fail: >=20 > rte_ring_free(rp); > return -1; > @@ -426,44 +432,45 @@ test_ring_burst_bulk_tests1(unsigned int test_idx) >=20 > printf("Random full/empty test\n"); >=20 > - for (j =3D 0; j !=3D TEST_RING_FULL_EMTPY_ITER; j++) { > + for (j =3D 0; j !=3D TEST_RING_FULL_EMPTY_ITER; j++) { > /* random shift in the ring */ > rand =3D RTE_MAX(rte_rand() % RING_SIZE, 1UL); > printf("%s: iteration %u, random shift: %u;\n", > __func__, i, rand); > ret =3D test_ring_enq_impl(r, cur_src, esize[i], rand, > test_idx); > - TEST_RING_VERIFY(ret !=3D 0); > + TEST_RING_VERIFY(ret !=3D 0, r); >=20 > ret =3D test_ring_deq_impl(r, cur_dst, esize[i], rand, > test_idx); > - TEST_RING_VERIFY(ret =3D=3D rand); > + TEST_RING_VERIFY(ret =3D=3D rand, r); >=20 > /* fill the ring */ > ret =3D test_ring_enq_impl(r, cur_src, esize[i], rsz, > test_idx); > - TEST_RING_VERIFY(ret !=3D 0); > + TEST_RING_VERIFY(ret !=3D 0, r); >=20 > - TEST_RING_VERIFY(rte_ring_free_count(r) =3D=3D 0); > - TEST_RING_VERIFY(rsz =3D=3D rte_ring_count(r)); > - TEST_RING_VERIFY(rte_ring_full(r)); > - TEST_RING_VERIFY(rte_ring_empty(r) =3D=3D 0); > + TEST_RING_VERIFY(rte_ring_free_count(r) =3D=3D 0, r); > + TEST_RING_VERIFY(rsz =3D=3D rte_ring_count(r), r); > + TEST_RING_VERIFY(rte_ring_full(r), r); > + TEST_RING_VERIFY(rte_ring_empty(r) =3D=3D 0, r); >=20 > /* empty the ring */ > ret =3D test_ring_deq_impl(r, cur_dst, esize[i], rsz, > test_idx); > - TEST_RING_VERIFY(ret =3D=3D (int)rsz); > - TEST_RING_VERIFY(rsz =3D=3D rte_ring_free_count(r)); > - TEST_RING_VERIFY(rte_ring_count(r) =3D=3D 0); > - TEST_RING_VERIFY(rte_ring_full(r) =3D=3D 0); > - TEST_RING_VERIFY(rte_ring_empty(r)); > + TEST_RING_VERIFY(ret =3D=3D (int)rsz, r); > + > + TEST_RING_VERIFY(rsz =3D=3D rte_ring_free_count(r), r); > + TEST_RING_VERIFY(rte_ring_count(r) =3D=3D 0, r); > + TEST_RING_VERIFY(rte_ring_full(r) =3D=3D 0, r); > + TEST_RING_VERIFY(rte_ring_empty(r), r); >=20 > /* check data */ > temp_sz =3D rsz * sizeof(void *); > if (esize[i] !=3D -1) > temp_sz =3D rsz * esize[i]; > TEST_RING_VERIFY(test_ring_mem_cmp(src, dst, > - temp_sz) =3D=3D 0); > + temp_sz) =3D=3D 0, r); > } >=20 > /* Free memory before test completed */ > @@ -520,45 +527,39 @@ test_ring_burst_bulk_tests2(unsigned int test_idx) >=20 > printf("enqueue 1 obj\n"); > ret =3D test_ring_enq_impl(r, cur_src, esize[i], 1, test_idx); > - if (ret !=3D 1) > - goto fail; > + TEST_RING_VERIFY(ret =3D=3D 1, r); > cur_src =3D test_ring_inc_ptr(cur_src, esize[i], 1); >=20 > printf("enqueue 2 objs\n"); > ret =3D test_ring_enq_impl(r, cur_src, esize[i], 2, test_idx); > - if (ret !=3D 2) > - goto fail; > + TEST_RING_VERIFY(ret =3D=3D 2, r); > cur_src =3D test_ring_inc_ptr(cur_src, esize[i], 2); >=20 > printf("enqueue MAX_BULK objs\n"); > ret =3D test_ring_enq_impl(r, cur_src, esize[i], MAX_BULK, > test_idx); > - if (ret !=3D MAX_BULK) > - goto fail; > + TEST_RING_VERIFY(ret =3D=3D MAX_BULK, r); > cur_src =3D test_ring_inc_ptr(cur_src, esize[i], MAX_BULK); >=20 > printf("dequeue 1 obj\n"); > ret =3D test_ring_deq_impl(r, cur_dst, esize[i], 1, test_idx); > - if (ret !=3D 1) > - goto fail; > + TEST_RING_VERIFY(ret =3D=3D 1, r); > cur_dst =3D test_ring_inc_ptr(cur_dst, esize[i], 1); >=20 > printf("dequeue 2 objs\n"); > ret =3D test_ring_deq_impl(r, cur_dst, esize[i], 2, test_idx); > - if (ret !=3D 2) > - goto fail; > + TEST_RING_VERIFY(ret =3D=3D 2, r); > cur_dst =3D test_ring_inc_ptr(cur_dst, esize[i], 2); >=20 > printf("dequeue MAX_BULK objs\n"); > ret =3D test_ring_deq_impl(r, cur_dst, esize[i], MAX_BULK, > test_idx); > - if (ret !=3D MAX_BULK) > - goto fail; > + TEST_RING_VERIFY(ret =3D=3D MAX_BULK, r); > cur_dst =3D test_ring_inc_ptr(cur_dst, esize[i], MAX_BULK); >=20 > /* check data */ > - if (test_ring_mem_cmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) > - goto fail; > + TEST_RING_VERIFY(test_ring_mem_cmp(src, dst, > + RTE_PTR_DIFF(cur_dst, dst)) =3D=3D 0, r); >=20 > /* Free memory before test completed */ > rte_ring_free(r); > @@ -615,22 +616,20 @@ test_ring_burst_bulk_tests3(unsigned int test_idx) > for (j =3D 0; j < RING_SIZE / MAX_BULK; j++) { > ret =3D test_ring_enq_impl(r, cur_src, esize[i], MAX_BULK, > test_idx); > - if (ret !=3D MAX_BULK) > - goto fail; > + TEST_RING_VERIFY(ret =3D=3D MAX_BULK, r); > cur_src =3D test_ring_inc_ptr(cur_src, esize[i], > MAX_BULK); >=20 > ret =3D test_ring_deq_impl(r, cur_dst, esize[i], MAX_BULK, > test_idx); > - if (ret !=3D MAX_BULK) > - goto fail; > + TEST_RING_VERIFY(ret =3D=3D MAX_BULK, r); > cur_dst =3D test_ring_inc_ptr(cur_dst, esize[i], > MAX_BULK); > } >=20 > /* check data */ > - if (test_ring_mem_cmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) > - goto fail; > + TEST_RING_VERIFY(test_ring_mem_cmp(src, dst, > + RTE_PTR_DIFF(cur_dst, dst)) =3D=3D 0, r); >=20 > /* Free memory before test completed */ > rte_ring_free(r); > @@ -690,16 +689,14 @@ test_ring_burst_bulk_tests4(unsigned int test_idx) > for (j =3D 0; j < (RING_SIZE/MAX_BULK - 1); j++) { > ret =3D test_ring_enq_impl(r, cur_src, esize[i], MAX_BULK, > test_idx); > - if (ret !=3D MAX_BULK) > - goto fail; > + TEST_RING_VERIFY(ret =3D=3D MAX_BULK, r); > cur_src =3D test_ring_inc_ptr(cur_src, esize[i], > MAX_BULK); > } >=20 > printf("Enqueue 2 objects, free entries =3D MAX_BULK - 2\n"); > ret =3D test_ring_enq_impl(r, cur_src, esize[i], 2, test_idx); > - if (ret !=3D 2) > - goto fail; > + TEST_RING_VERIFY(ret =3D=3D 2, r); > cur_src =3D test_ring_inc_ptr(cur_src, esize[i], 2); >=20 > printf("Enqueue the remaining entries =3D MAX_BULK - 3\n"); > @@ -711,34 +708,29 @@ test_ring_burst_bulk_tests4(unsigned int test_idx) > /* Always one free entry left */ > ret =3D test_ring_enq_impl(r, cur_src, esize[i], num_elems, > test_idx); > - if (ret !=3D MAX_BULK - 3) > - goto fail; > + TEST_RING_VERIFY(ret =3D=3D MAX_BULK - 3, r); > cur_src =3D test_ring_inc_ptr(cur_src, esize[i], MAX_BULK - 3); >=20 > printf("Test if ring is full\n"); > - if (rte_ring_full(r) !=3D 1) > - goto fail; > + TEST_RING_VERIFY(rte_ring_full(r) =3D=3D 1, r); >=20 > printf("Test enqueue for a full entry\n"); > ret =3D test_ring_enq_impl(r, cur_src, esize[i], MAX_BULK, > test_idx); > - if (ret !=3D 0) > - goto fail; > + TEST_RING_VERIFY(ret =3D=3D 0, r); >=20 > printf("Test dequeue without enough objects\n"); > for (j =3D 0; j < RING_SIZE / MAX_BULK - 1; j++) { > ret =3D test_ring_deq_impl(r, cur_dst, esize[i], MAX_BULK, > test_idx); > - if (ret !=3D MAX_BULK) > - goto fail; > + TEST_RING_VERIFY(ret =3D=3D MAX_BULK, r); > cur_dst =3D test_ring_inc_ptr(cur_dst, esize[i], > MAX_BULK); > } >=20 > /* Available memory space for the exact MAX_BULK entries */ > ret =3D test_ring_deq_impl(r, cur_dst, esize[i], 2, test_idx); > - if (ret !=3D 2) > - goto fail; > + TEST_RING_VERIFY(ret =3D=3D 2, r); > cur_dst =3D test_ring_inc_ptr(cur_dst, esize[i], 2); >=20 > /* Bulk APIs enqueue exact number of elements */ > @@ -748,18 +740,16 @@ test_ring_burst_bulk_tests4(unsigned int test_idx) > num_elems =3D MAX_BULK; > ret =3D test_ring_deq_impl(r, cur_dst, esize[i], num_elems, > test_idx); > - if (ret !=3D MAX_BULK - 3) > - goto fail; > + TEST_RING_VERIFY(ret =3D=3D MAX_BULK - 3, r); > cur_dst =3D test_ring_inc_ptr(cur_dst, esize[i], MAX_BULK - 3); >=20 > printf("Test if ring is empty\n"); > /* Check if ring is empty */ > - if (rte_ring_empty(r) !=3D 1) > - goto fail; > + TEST_RING_VERIFY(rte_ring_empty(r) =3D=3D 1, r); >=20 > /* check data */ > - if (test_ring_mem_cmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) > - goto fail; > + TEST_RING_VERIFY(test_ring_mem_cmp(src, dst, > + RTE_PTR_DIFF(cur_dst, dst)) =3D=3D 0, r); >=20 > /* Free memory before test completed */ > rte_ring_free(r); > @@ -795,14 +785,14 @@ test_ring_basic_ex(void) > RING_F_SP_ENQ | RING_F_SC_DEQ); > if (rp =3D=3D NULL) { > printf("%s: failed to create ring\n", __func__); > - goto fail_test; > + goto fail; > } >=20 > /* alloc dummy object pointers */ > src =3D test_ring_calloc(RING_SIZE, esize[i]); > if (src =3D=3D NULL) { > printf("%s: failed to alloc src memory\n", __func__); > - goto fail_test; > + goto fail; > } > test_ring_mem_init(src, RING_SIZE, esize[i]); > cur_src =3D src; > @@ -811,20 +801,13 @@ test_ring_basic_ex(void) > dst =3D test_ring_calloc(RING_SIZE, esize[i]); > if (dst =3D=3D NULL) { > printf("%s: failed to alloc dst memory\n", __func__); > - goto fail_test; > + goto fail; > } > cur_dst =3D dst; >=20 > - if (rte_ring_lookup("test_ring_basic_ex") !=3D rp) { > - printf("%s: failed to find ring\n", __func__); > - goto fail_test; > - } > + TEST_RING_VERIFY(rte_ring_lookup("test_ring_basic_ex") =3D=3D rp, rp); >=20 > - if (rte_ring_empty(rp) !=3D 1) { > - printf("%s: ring is not empty but it should be\n", > - __func__); > - goto fail_test; > - } > + TEST_RING_VERIFY(rte_ring_empty(rp) =3D=3D 1, rp); >=20 > printf("%u ring entries are now free\n", > rte_ring_free_count(rp)); > @@ -832,40 +815,24 @@ test_ring_basic_ex(void) > for (j =3D 0; j < RING_SIZE - 1; j++) { > ret =3D test_ring_enqueue(rp, cur_src, esize[i], 1, > TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE); > - if (ret !=3D 0) { > - printf("%s: rte_ring_enqueue fails\n", > - __func__); > - goto fail_test; > - } > + TEST_RING_VERIFY(ret =3D=3D 0, rp); > cur_src =3D test_ring_inc_ptr(cur_src, esize[i], 1); > } >=20 > - if (rte_ring_full(rp) !=3D 1) { > - printf("%s: ring is not full but it should be\n", > - __func__); > - goto fail_test; > - } > + TEST_RING_VERIFY(rte_ring_full(rp) =3D=3D 1, rp); >=20 > for (j =3D 0; j < RING_SIZE - 1; j++) { > ret =3D test_ring_dequeue(rp, cur_dst, esize[i], 1, > TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE); > - if (ret !=3D 0) { > - printf("%s: rte_ring_dequeue fails\n", > - __func__); > - goto fail_test; > - } > + TEST_RING_VERIFY(ret =3D=3D 0, rp); > cur_dst =3D test_ring_inc_ptr(cur_dst, esize[i], 1); > } >=20 > - if (rte_ring_empty(rp) !=3D 1) { > - printf("%s: ring is not empty but it should be\n", > - __func__); > - goto fail_test; > - } > + TEST_RING_VERIFY(rte_ring_empty(rp) =3D=3D 1, rp); >=20 > /* check data */ > - if (test_ring_mem_cmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) > - goto fail_test; > + TEST_RING_VERIFY(test_ring_mem_cmp(src, dst, > + RTE_PTR_DIFF(cur_dst, dst)) =3D=3D 0, rp); >=20 > /* Following tests use the configured flags to decide > * SP/SC or MP/MC. > @@ -880,40 +847,28 @@ test_ring_basic_ex(void) > /* Covering the ring burst operation */ > ret =3D test_ring_enqueue(rp, cur_src, esize[i], 2, > TEST_RING_THREAD_DEF | TEST_RING_ELEM_BURST); > - if (ret !=3D 2) { > - printf("%s: rte_ring_enqueue_burst fails\n", __func__); > - goto fail_test; > - } > + TEST_RING_VERIFY(ret =3D=3D 2, rp); > cur_src =3D test_ring_inc_ptr(cur_src, esize[i], 2); >=20 > ret =3D test_ring_dequeue(rp, cur_dst, esize[i], 2, > TEST_RING_THREAD_DEF | TEST_RING_ELEM_BURST); > - if (ret !=3D 2) { > - printf("%s: rte_ring_dequeue_burst fails\n", __func__); > - goto fail_test; > - } > + TEST_RING_VERIFY(ret =3D=3D 2, rp); > cur_dst =3D test_ring_inc_ptr(cur_dst, esize[i], 2); >=20 > /* Covering the ring bulk operation */ > ret =3D test_ring_enqueue(rp, cur_src, esize[i], 2, > TEST_RING_THREAD_DEF | TEST_RING_ELEM_BULK); > - if (ret !=3D 2) { > - printf("%s: rte_ring_enqueue_bulk fails\n", __func__); > - goto fail_test; > - } > + TEST_RING_VERIFY(ret =3D=3D 2, rp); > cur_src =3D test_ring_inc_ptr(cur_src, esize[i], 2); >=20 > ret =3D test_ring_dequeue(rp, cur_dst, esize[i], 2, > TEST_RING_THREAD_DEF | TEST_RING_ELEM_BULK); > - if (ret !=3D 2) { > - printf("%s: rte_ring_dequeue_bulk fails\n", __func__); > - goto fail_test; > - } > + TEST_RING_VERIFY(ret =3D=3D 2, rp); > cur_dst =3D test_ring_inc_ptr(cur_dst, esize[i], 2); >=20 > /* check data */ > - if (test_ring_mem_cmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) > - goto fail_test; > + TEST_RING_VERIFY(test_ring_mem_cmp(src, dst, > + RTE_PTR_DIFF(cur_dst, dst)) =3D=3D 0, rp); >=20 > rte_ring_free(rp); > rte_free(src); > @@ -925,7 +880,7 @@ test_ring_basic_ex(void) >=20 > return 0; >=20 > -fail_test: > +fail: > rte_ring_free(rp); > rte_free(src); > rte_free(dst); > @@ -955,7 +910,7 @@ test_ring_with_exact_size(void) > RING_F_SP_ENQ | RING_F_SC_DEQ); > if (std_r =3D=3D NULL) { > printf("%s: error, can't create std ring\n", __func__); > - goto test_fail; > + goto fail; > } > exact_sz_r =3D test_ring_create("exact sz", esize[i], ring_sz, > rte_socket_id(), > @@ -964,7 +919,7 @@ test_ring_with_exact_size(void) > if (exact_sz_r =3D=3D NULL) { > printf("%s: error, can't create exact size ring\n", > __func__); > - goto test_fail; > + goto fail; > } >=20 > /* alloc object pointers. Allocate one extra object > @@ -972,14 +927,14 @@ test_ring_with_exact_size(void) > */ > src_orig =3D test_ring_calloc(17, esize[i]); > if (src_orig =3D=3D NULL) > - goto test_fail; > + goto fail; > test_ring_mem_init(src_orig, 17, esize[i]); > src =3D (void **)((uintptr_t)src_orig + 1); > cur_src =3D src; >=20 > dst_orig =3D test_ring_calloc(17, esize[i]); > if (dst_orig =3D=3D NULL) > - goto test_fail; > + goto fail; > dst =3D (void **)((uintptr_t)dst_orig + 1); > cur_dst =3D dst; >=20 > @@ -987,13 +942,9 @@ test_ring_with_exact_size(void) > * Check that the exact size ring is bigger than the > * standard ring > */ > - if (rte_ring_get_size(std_r) >=3D rte_ring_get_size(exact_sz_r)) { > - printf("%s: error, std ring (size: %u) is not smaller than exact size= one (size %u)\n", > - __func__, > - rte_ring_get_size(std_r), > - rte_ring_get_size(exact_sz_r)); > - goto test_fail; > - } > + TEST_RING_VERIFY(rte_ring_get_size(std_r) <=3D > + rte_ring_get_size(exact_sz_r), std_r); > + > /* > * check that the exact_sz_ring can hold one more element > * than the standard ring. (16 vs 15 elements) > @@ -1001,53 +952,34 @@ test_ring_with_exact_size(void) > for (j =3D 0; j < ring_sz - 1; j++) { > ret =3D test_ring_enqueue(std_r, cur_src, esize[i], 1, > TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE); > - if (ret !=3D 0) { > - printf("%s: error, enqueue failed\n", __func__); > - goto test_fail; > - } > + TEST_RING_VERIFY(ret =3D=3D 0, std_r); > ret =3D test_ring_enqueue(exact_sz_r, cur_src, esize[i], 1, > TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE); > - if (ret !=3D 0) { > - printf("%s: error, enqueue failed\n", __func__); > - goto test_fail; > - } > + TEST_RING_VERIFY(ret =3D=3D 0, exact_sz_r); > cur_src =3D test_ring_inc_ptr(cur_src, esize[i], 1); > } > ret =3D test_ring_enqueue(std_r, cur_src, esize[i], 1, > TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE); > - if (ret !=3D -ENOBUFS) { > - printf("%s: error, unexpected successful enqueue\n", > - __func__); > - goto test_fail; > - } > + TEST_RING_VERIFY(ret =3D=3D -ENOBUFS, std_r); > ret =3D test_ring_enqueue(exact_sz_r, cur_src, esize[i], 1, > TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE); > - if (ret =3D=3D -ENOBUFS) { > - printf("%s: error, enqueue failed\n", __func__); > - goto test_fail; > - } > + TEST_RING_VERIFY(ret !=3D -ENOBUFS, exact_sz_r); > cur_src =3D test_ring_inc_ptr(cur_src, esize[i], 1); >=20 > /* check that dequeue returns the expected number of elements */ > ret =3D test_ring_dequeue(exact_sz_r, cur_dst, esize[i], ring_sz, > TEST_RING_THREAD_DEF | TEST_RING_ELEM_BURST); > - if (ret !=3D (int)ring_sz) { > - printf("%s: error, failed to dequeue expected nb of elements\n", > - __func__); > - goto test_fail; > - } > + TEST_RING_VERIFY(ret =3D=3D (int)ring_sz, exact_sz_r); > cur_dst =3D test_ring_inc_ptr(cur_dst, esize[i], ring_sz); >=20 > /* check that the capacity function returns expected value */ > - if (rte_ring_get_capacity(exact_sz_r) !=3D ring_sz) { > - printf("%s: error, incorrect ring capacity reported\n", > - __func__); > - goto test_fail; > - } > + TEST_RING_VERIFY(rte_ring_get_capacity(exact_sz_r) =3D=3D ring_sz, > + exact_sz_r); >=20 > /* check data */ > - if (test_ring_mem_cmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) > - goto test_fail; > + TEST_RING_VERIFY(test_ring_mem_cmp(src, dst, > + RTE_PTR_DIFF(cur_dst, dst)) =3D=3D 0, > + exact_sz_r); >=20 > rte_free(src_orig); > rte_free(dst_orig); > @@ -1061,7 +993,7 @@ test_ring_with_exact_size(void) >=20 > return 0; >=20 > -test_fail: > +fail: > rte_free(src_orig); > rte_free(dst_orig); > rte_ring_free(std_r); > -- > 2.17.1