From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 45700A0093; Tue, 23 Aug 2022 14:38:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2DCAE40DDE; Tue, 23 Aug 2022 14:38:07 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 268C340DDA for ; Tue, 23 Aug 2022 14:38:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661258285; x=1692794285; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=eyC7oHjaj1VfNm7v+I6u91ZdFopPyWyzKArJeDIPg9A=; b=K55PsZaqtkoid7iMss3VnTWuNHF01mNAY+E/Iosk1H3Pkkwcl+m1MpEN lueGDE4F+URebTGt4wKtIQLltfPAaH1CT05sMz6K6HBkYK4Q0NEbxkXVq avwMNsnvQIeRmAq7MAVnBcMBVKNofIDmKU4qm+KLAAuH2PmpMEMJUCzkG rDYA2ofjDQz/SVolWXMZqdawjV6BrBu3OAeehc7++/oyBcl+tmDUJoyQF WAOitPLTpP1d8wEfv+15NAiOTm62hCTJAy9P/g6eFkZ8TYZ33ar5W49M5 N9hjUquOztQ/8QgPgzoRniYCGbxu2zpFZz8b96Mb1x0guPRvWpnK9vr2m w==; X-IronPort-AV: E=McAfee;i="6500,9779,10447"; a="355404597" X-IronPort-AV: E=Sophos;i="5.93,257,1654585200"; d="scan'208";a="355404597" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2022 05:33:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,257,1654585200"; d="scan'208";a="712590001" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga002.fm.intel.com with ESMTP; 23 Aug 2022 05:33:50 -0700 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 23 Aug 2022 05:33:50 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Tue, 23 Aug 2022 05:33:50 -0700 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.49) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Tue, 23 Aug 2022 05:33:50 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LpipxKC7SSeSXltnNeLoKO9Bai6/ZAOaFbYGQrTTBeRQW97qIz2k784GyhoLRgn8HTZEjzyVmzCASE/TA9Ircj/3zwCEzq+NWpuKgF+sYZqAEdlKLKryFgJAktg5NUOl2lSUCqm/9oGDNE6oXFEGvbmMqKp0EenLADErIZdGnFctexSnJ3dfW6xcEaA8a96I338CdfmaSkSdrmKqoITVA4ssNfx3TW+/ILP3GZK3addCmWFCklSZrvb8pg6EPtR8wjvGNuywKfT2fF94yEQGkPQunOhLj/viA+wNOdbC4k5flXXkuLgWKUwU9OkuDekOPojmNru/O3TI/4nauZk8Ow== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4ixBxhXSi81oaueQBx1qA0LEpHuI6VCyPBTDgPfRHXc=; b=FtozYPXyz/ukD32W69NXau65LW1+AadQJRwVGVGwuvcwU421X/XId8c7Pa4wRYXgOKu28SmLOBE6SIyqH/sYVxfvWwt+prM/decU9RVpCuGi528V/ZWfQFLMiYo0LrVtkbXBcEi8HvCBuuItx5APWEaJeEDiWWkOlheGKQFETP/brsxMpae1XlnMUrVQ3Gqd06/y7jnXvKQYaovPuVSrO40uNyTpaUU0fRWts6+swkdxi+ZFdCVQZsicdzCqu/HHxG1OiTXYC4Mc8HEZ0U/mfvrebMRe0qKd2SztrEgSFgQdY1pWMpzvkXvDQK0ysSFGDCfUOuLNhO2i2tyqsY/2cw== 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 Received: from MN2PR11MB3821.namprd11.prod.outlook.com (2603:10b6:208:f7::24) by BN6PR11MB2002.namprd11.prod.outlook.com (2603:10b6:404:4a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.22; Tue, 23 Aug 2022 12:33:48 +0000 Received: from MN2PR11MB3821.namprd11.prod.outlook.com ([fe80::348b:463a:1ef:b74a]) by MN2PR11MB3821.namprd11.prod.outlook.com ([fe80::348b:463a:1ef:b74a%7]) with mapi id 15.20.5546.022; Tue, 23 Aug 2022 12:33:48 +0000 From: "Power, Ciara" To: "Richardson, Bruce" , "dev@dpdk.org" Subject: RE: [PATCH v2 10/13] test/telemetry_data: refactor for maintainability Thread-Topic: [PATCH v2 10/13] test/telemetry_data: refactor for maintainability Thread-Index: AQHYoES82DJcwYn+ykmm+HZe6JN8tq28mDcg Date: Tue, 23 Aug 2022 12:33:48 +0000 Message-ID: References: <20220623164245.561371-1-bruce.richardson@intel.com> <20220725163543.875775-1-bruce.richardson@intel.com> <20220725163543.875775-11-bruce.richardson@intel.com> In-Reply-To: <20220725163543.875775-11-bruce.richardson@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.6.500.17 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 70458bc1-818a-48b8-2b0d-08da8503ba58 x-ms-traffictypediagnostic: BN6PR11MB2002:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: WiAMAj2GTqQR1NqW3Un7y3Gtusl7zDzE3pR9s4XY5VEozSpVQ2wmwyVIE+hlIpfpyLjhkWx3x6pzPGdrGVBU8/MUvAi0TPbl+ck0qgdU+U8bd3VBr9WDRcJieWMyKZRKeYpZpYSwXEo5EwL+bDHFkMEqNuTUTPsvzarwFVrO1oV3eNK+qFcrUtV6vnK+wMRl8pQF+5sq6V2AG+ArWOpQbCQzEPRALcUZQ/HkJJd075nJIvU2S4IOuuaE+WDk6u5IWibrBriZc1As101NWx2yzN5+97Eu5Kxg49cvEgZP1HUeEW6NlU+66rilsRX+sa+XRwDcy9vCay9Veb7cz+QwX+xqx4CuTn6FpJAb2fPJbhVqMxEvPs/tmNJpq2gbL9eu2dUw5Vl50YftCZGmX4ICq2N6n6JEqqj5qiDrXjcK13Ujn1c9tYMhJGk6RcrPA4O0YX2H+gUVXwdTgSc3YrMLtMYgdm5nYzyLoJor4J7Vj6Xxqm6+aRAZXdoDuwmh1GMvBV2RZYr8DMlqncVlYWiq9/BS2Gz3wv1Pz1R7ALSdOgkcQW21n35sq38ifW1jr+M/XO2EhuS2q+mtQ0BfsEjWRdCp54F7XIRaKghLrgcPWJ+V6pxFuf2Yt2hgk0yaSDCRHSO1Zg7PJVeZSr34CQWAjG1b5SJTjfGfrlrTnOE0n/IUfeMncZr8oPixnokPOrKgIdNNRE1tzr5ZWm7sv64H5aiAbv1Xas1D3RvBtX4pRv28D2eE8SskctjLLQvWkSerdzKX6Zx5RS54JDbiyJVgmg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR11MB3821.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(366004)(396003)(136003)(39860400002)(376002)(346002)(110136005)(122000001)(186003)(86362001)(38100700002)(83380400001)(478600001)(316002)(71200400001)(33656002)(8676002)(66476007)(64756008)(66446008)(41300700001)(38070700005)(66556008)(82960400001)(66946007)(76116006)(8936002)(2906002)(9686003)(53546011)(6506007)(7696005)(52536014)(55016003)(26005)(5660300002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?bn365n0yVr2U44ATHfiepcfxudN5B4J6nQOk4SOnsUV9zJIDuU8OpMG8F0Qq?= =?us-ascii?Q?qGJ4OazILxOkLFUYh36izc4hEwuKqU/YoRVXS+MVQshh9k3B7ra61IK8KqRF?= =?us-ascii?Q?yulutCnbUgG8RAPh3QHuTeVZKjDD8bL2RXgor8vhaVkWbKwvJh9VFMoMJ4EF?= =?us-ascii?Q?1nlnL8HZr3WIVaRC9h9e2bhgbOZ44YZArHHqa9EMEmcY9blJ3m3pGijJY1AD?= =?us-ascii?Q?8GlxQBxeUxMAp8HaSSHJ9tOlt0eKAT8wIlUzWYRWmTZ2j5r7Dd3X+TCCwcF/?= =?us-ascii?Q?ysSiOX3bbUHFX+MsLGvHvECYsFDSJkHY3gpfWEZAjyJjGdgYOGORPAGJvMKs?= =?us-ascii?Q?CbQQBXpWIuKhV2v+8DKlQE/qlbKIamG5zf2unpAO8kbkJlh6mYLlQreP5FS1?= =?us-ascii?Q?DDGeyG8eBSdiPfh0NI967KGWeCubf/bf+Ni6ICyB3at/NoaT+NI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4fP/UaWZxDSdaZrhfgI9xKJdY6KQpn4Ybd?= =?us-ascii?Q?tJA933ndT+Bo75lJ3jMM40d4oY722Nkb9FI6qW69gR2j9U9tzzcMZUqtTF24?= =?us-ascii?Q?RFZSij+kxgAsfeahM5OQcw3WTiNCp0mGozDHytEfDxioKfGMQU+Fu96zulXz?= =?us-ascii?Q?A8Co10wOlcuIyt3V0+RNCq96qRHpMTldnb9wn0IywvZ4hqRv6yz78wneM1PK?= =?us-ascii?Q?le5cXw2uj+/OFIgrMlJJT//K7MSdZC7kMVGGIDEi?= 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: MN2PR11MB3821.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 70458bc1-818a-48b8-2b0d-08da8503ba58 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Aug 2022 12:33:48.3614 (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: EdoKP2ViESeD6EGWi/hGiddBd+khu8eknk0XTLMTEZPPTPs01rcsc9bS77zDuuUFj9WIFu8s5gbRY/VzdlRnFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB2002 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > -----Original Message----- > From: Richardson, Bruce > Sent: Monday 25 July 2022 17:36 > To: dev@dpdk.org > Cc: Richardson, Bruce ; Power, Ciara > > Subject: [PATCH v2 10/13] test/telemetry_data: refactor for maintainabili= ty >=20 > To help with the writing and maintaining of test cases in this file we ca= n make > the following changes to it: >=20 > - rename non-test-case functions i.e. the infrastructure functions, to > not start with "test_", so that each sub-test case can be identified > by starting with that prefix. > - add a comment at the start of the file explaining how tests are to be > written and managed, so as to keep consistency. > - add a trivial test-case for returning a simple string value to use as > a reference example for those wanting to add test cases. > - improve the key macro used for validating the output from each > function, so that the standard json preamble can be skipped for each > function. This hides more of the infrastructure implementation from > the user i.e. they don't need to worry what the actual command used is > called, and also shortens the output strings so we can avoid line > splitting in most cases. > - add clearing the "response_data" structure to the loop calling each > test to avoid each test function having to do so individually. >=20 > Signed-off-by: Bruce Richardson > --- > app/test/test_telemetry_data.c | 101 ++++++++++++++++++++------------- > 1 file changed, 60 insertions(+), 41 deletions(-) >=20 > diff --git a/app/test/test_telemetry_data.c > b/app/test/test_telemetry_data.c index 73eee293a1..5a85e790d3 100644 > --- a/app/test/test_telemetry_data.c > +++ b/app/test/test_telemetry_data.c > @@ -21,18 +21,45 @@ > #define TELEMETRY_VERSION "v2" > #define REQUEST_CMD "/test" > #define BUF_SIZE 1024 > -#define TEST_OUTPUT(exp) test_output(__func__, exp) > +#define CHECK_OUTPUT(exp) check_output(__func__, "{\"" > REQUEST_CMD > +"\":" exp "}") > + > +/* > + * Runs a series of test cases, checking the output of telemetry for > +various different types of > + * responses. On init, a single connection to DPDK telemetry is made, > +and a single telemetry > + * callback "/test" is registered. That callback always returns the > +value of the static global > + * variable "response_data", so each test case builds up that > +structure, and then calls the > + * "check_output" function to ensure the response received over the > +socket for "/test" matches > + * that expected for the response_data value populated. > + * > + * NOTE: > + * - each test case function in this file should be added to the "test_c= ases" > array in > + * test_telemetry_data function at the bottom of the file. > + * - each test case function should populate the "response_data" global > variable (below) > + * with the appropriate values which would be returned from a simulate= d > telemetry function. > + * Then the test case function should have "return > TEST_OUTPUT();" as it's [CP] nit: I think this should be CHECK_OUTPUT based on the macro rename abo= ve. > + * last line. The test infrastructure will then validate that the outp= ut when > returning > + * "response_data" structure matches that in "". > + * - the response_data structure will be zeroed on entry to each test > function, so each function > + * can begin with a call to "rte_tel_data_string/start_array/start_dic= t" as so > desired. > + * - the expected_output for each function can be just the actual json d= ata > from the > + * "response_data" value. The CHECK_OUTPUT macro will include the > appropriate "{\"/test\": ... }" > + * structure around the json output. > + * > + * See test_simple_string(), or test_case_array_int() for a basic examp= les > of test cases. > + */