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 7AFB94571C; Fri, 2 Aug 2024 17:21:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4994340E28; Fri, 2 Aug 2024 17:21:38 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by mails.dpdk.org (Postfix) with ESMTP id D9F3F40E24 for ; Fri, 2 Aug 2024 17:21:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1722612096; x=1754148096; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=aDTKTnjHftmY+PVSXogx4kmlsyHTQkcwsc/yEsMmAnA=; b=jUmMh8cSJYYu9xBRCdCdnryNh1rNOZQyVgquXBq+67PKmv2j5a7eciNv fUG+Wofc4o3oSoMYC84mpVzpKnX6W8uAeRUHI4vvsyZC9aMJvoaOGm247 wxNXoKV1jZkOtUCPASANQg6P+QAHJKjzl5WV0BZy12N7jgaxvdt9c9bpd ktykIHiezvt6IQtBdGYrLgFHT+QCSHFdgymu+E28D+ZGc1btxAXSNKQ2t YNVjA6u+CbMaZXK81uXdj7wh9OQF+GieiQJKf6iz6rSEHz+yJ560IvkKf LMlzGIYx7qsSPHUfp5IUUSldcMx3XF+zTDu/k9Zf/otUvtHUbaZ6WC3Na Q==; X-CSE-ConnectionGUID: pz88y3tFR4e8GBCYkzFUSw== X-CSE-MsgGUID: kb12zxwjRdSf4NwLKsXVnQ== X-IronPort-AV: E=McAfee;i="6700,10204,11152"; a="31786113" X-IronPort-AV: E=Sophos;i="6.09,258,1716274800"; d="scan'208";a="31786113" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2024 08:21:35 -0700 X-CSE-ConnectionGUID: BbY+0pCGRYWFDCgud+RE2w== X-CSE-MsgGUID: CgNj4vaEQ3qjYx+7mivRTA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,258,1716274800"; d="scan'208";a="55110344" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmviesa006.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 02 Aug 2024 08:21:34 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 2 Aug 2024 08:21:34 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 2 Aug 2024 08:21:33 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Fri, 2 Aug 2024 08:21:33 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.100) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 2 Aug 2024 08:21:33 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iGnzAEyVMVkRCcAJR7gn/XtUFvPFsr50kdGadfLBrIECYxQB8Ajr1LruNdHfVA9aGZXpZHuUlW58W03uIbl/9ZTF6gbeRv2j7/bHDLPpGVr6MrzYSwJRPjNCo65Dj05YQroMHiCqmnXi3hlJtGUkyUZlST/PzewqVyYGgZ8TVy+GrjtzoVyRFnsDJMM7C2bAayv1z1uZe3I08j9AxNOQN6OhfgcBNZE9Ddy9ywJXILmvjRpqC4Nm6oZaOeofoLmCVBG78AZUJHkbg7Fl/DXH1AQMdbzQlcIsCAKMnnyKeDSNEYSDDDWTdWFwYeR+gGcA7TmnDzeElOPm4vRJ6Cx0Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=roCujUaxwi2HhPxTaOEoX1zWUbULDih8f0FElg3i1ws=; b=xVbSkSmSZR1vuitYcVfRQ6A65U6rITkPcvVMdtTpWCy7mZsZP3FJjgvMgVlhM+rgSMyPznri577S24wc+51dJCwHG9L6W0qyShoVBvS4zkfFXfuFNR4Bk8Ap9a2uSstIu5bmVzkzBUlml1lzRoKIwU61wrK8S98jTSIds+8EvSjp0qMgyEwdw3s8hHqio2g8KymMAhG7Z7eTXCJWUSUX97lR2XJmpecbf/QhRuTWmC3I3KnWmHNKOapTfJs1m+EmHCLkTIRHRi3rQ7Dx1jguM06EYQ0EGEzUS2FovEwzkMzIe5bQJAbBBw88uBPh0uT9J7ibCW2rL5IuZ6Cv47KbmA== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) by PH7PR11MB6977.namprd11.prod.outlook.com (2603:10b6:510:205::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.23; Fri, 2 Aug 2024 15:21:30 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b%2]) with mapi id 15.20.7828.023; Fri, 2 Aug 2024 15:21:30 +0000 Date: Fri, 2 Aug 2024 16:21:25 +0100 From: Bruce Richardson To: Stephen Hemminger CC: Subject: Re: [PATCH v4 3/3] test: restore cfgfile tests Message-ID: References: <20240730225520.83314-1-stephen@networkplumber.org> <20240801173029.65710-1-stephen@networkplumber.org> <20240801173029.65710-4-stephen@networkplumber.org> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20240801173029.65710-4-stephen@networkplumber.org> X-ClientProxiedBy: DB9PR01CA0003.eurprd01.prod.exchangelabs.com (2603:10a6:10:1d8::8) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|PH7PR11MB6977:EE_ X-MS-Office365-Filtering-Correlation-Id: 184bf83f-72a6-45ce-bad9-08dcb306c920 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?bFZU5+J8jYFgzsxfp0RI1tZ1HInlFsk8KENB4dz+8eWxyj/spBnenJf1Ta/l?= =?us-ascii?Q?/lVLPBmOp5gojMRrH50QogAL06OkiMsgIXMhNXCSQ92Z0Zjj+7wVazy3t7Xv?= =?us-ascii?Q?hKeYLqUXc1vR6AEtvTtkupZQqvhOspXHSDHDkOWyYFFl7akHWhznIEfE2OB8?= =?us-ascii?Q?ZU3XRTT5a7m/8InyNcZci4D57BfAl94ufzSx/orUpH7GddZ0Kfoan3Yq3mq0?= =?us-ascii?Q?ZRaimZnxLbB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ascii?Q?UJU5SM6JkRHMCoMlzZqQqoaJ4Oc5ZK50T1iPyc7Tp1FQCURM7ztXrMKG5WBM?= =?us-ascii?Q?OdXmgopRE8pitlbkTSA4pl08NkicpKDckKi593UcND1VoSt8DS5hJy6vUMjv?= =?us-ascii?Q?cLEHclCim+wY1P520UDBVV9zyQArCRYz0kaBfZ1fVmAEMnrlqNNzuBU1f5lh?= =?us-ascii?Q?E3bvpsx9P0V5ZkhrR8h/WAw4dFn+kO3ScVYJcaIXmGnRQQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7309.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(376014)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?tf/hiBNJykLXDl9lMK/WcHxlpOgNQ5PxtYAd211g7QuI1ff+HEP3hATdHf7A?= =?us-ascii?Q?3fsMmU2jvG4QqvA02vOnTOxYFa6mpXtZbI13WeBCBam22diiwmzz5nrLlidt?= =?us-ascii?Q?Kjtq9+2S6Hke88e9xdOj69eXYGYhIz2K4GQM7JSQZwYWuhKHs0zO+vgXUjdd?= =?us-ascii?Q?at5HU87i8kP10WpGJwClx/FCH1nw0WBsIJUeFyzju9iDLpsIawLsRJ9+z/2u?= =?us-ascii?Q?UCRaY5YBrY+9fRCnHpUIesaU40mdTAEB9Q8SiKJtfovxPDf7N4UX9/Gz62qu?= =?us-ascii?Q?4qeheMzochDnFpc7ML2dlGIqWKyGQZiC1r3vpmwRqRKu2Tws0u6BukJqTCP9?= =?us-ascii?Q?W2RRhA7ZZ98g1ZyNIoAlka4223I7o8vea/lbK+lGubiJlmEv0/DQTNaviLqL?= =?us-ascii?Q?RoDyFUjXMs8ZUrlJxUu+R5UCoFk+QhzL1mYK3gnyhKWl/Dg/aXt8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Wag2nmIGaDIb6Gw3OqA1echa?= =?us-ascii?Q?yf13/bS3aa0bmoYIIlfLWpDbJ2r/fQM17imniF/tLacYf6Tk6zLIgMeePl3c?= =?us-ascii?Q?8bHXm6k8TlhsF9PkjLYT/0PaxJTJyqoH6fDJ0MHQM3pqZGiazMkdd9hhmkZj?= =?us-ascii?Q?5+LMwkg54NZ/+mydE19GSzawNdfAotXyPTJnu3n5l7WT0CparFPmFwLi8NIY?= =?us-ascii?Q?diU2MF/nf+GjtjRnwDcDLwkC30melqzwvJgd+GEArFzoCsV1xKjmSKmrXuyA?= =?us-ascii?Q?ww=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 184bf83f-72a6-45ce-bad9-08dcb306c920 X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2024 15:21:30.6619 (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: 2p9Dp/ux5HTyqju7QbQ7gxTbHGDS1U4NhtiJYqVZhG+r0DIFuNBsaij7o7V4oE9AQxlRrWiV2wFPzJYO3ZbWP1AWnW8bmOU8N5DJhUiXu20= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB6977 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 On Thu, Aug 01, 2024 at 10:29:10AM -0700, Stephen Hemminger wrote: > These tests were not built since the conversion to meson. > Instead of using embedded resource functions, put data in include > file and generate temporary file before the test. > > Signed-off-by: Stephen Hemminger > --- > app/meson.build | 3 +- > app/test/meson.build | 6 +- > app/test/test_cfgfile.c | 153 +++++++++++++++++++---------- > app/test/test_cfgfiles/meson.build | 19 ++++ > 4 files changed, 129 insertions(+), 52 deletions(-) > create mode 100644 app/test/test_cfgfiles/meson.build > Tested-by: Bruce Richardson Acked-by: Bruce Richardson A further cleanup that could be done with the test files is to remove the unnecessary "etc" subdirectory. > diff --git a/app/meson.build b/app/meson.build > index 5b2c80c7a1..e2db888ae1 100644 > --- a/app/meson.build > +++ b/app/meson.build > @@ -55,6 +55,7 @@ foreach app:apps > build = true > reason = '' # set if build == false to explain > sources = [] > + resources = [] > includes = [] > cflags = default_cflags > ldflags = default_ldflags > @@ -115,7 +116,7 @@ foreach app:apps > endif > > exec = executable('dpdk-' + name, > - sources, > + [ sources, resources ], > c_args: cflags, > link_args: ldflags, > link_whole: link_libs, > diff --git a/app/test/meson.build b/app/test/meson.build > index 62478c0bb6..b2bb7c36f6 100644 > --- a/app/test/meson.build > +++ b/app/test/meson.build > @@ -35,7 +35,7 @@ source_file_deps = { > 'test_bitratestats.c': ['metrics', 'bitratestats', 'ethdev'] + sample_packet_forward_deps, > 'test_bpf.c': ['bpf', 'net'], > 'test_byteorder.c': [], > -# 'test_cfgfile.c': ['cfgfile'], > + 'test_cfgfile.c': ['cfgfile'], > 'test_cksum.c': ['net'], > 'test_cksum_perf.c': ['net'], > 'test_cmdline.c': [], > @@ -261,3 +261,7 @@ if not is_windows > build_by_default: true, > install: false) > endif > + > +subdir('test_cfgfiles') > + > +resources += test_cfgfile_h > diff --git a/app/test/test_cfgfile.c b/app/test/test_cfgfile.c > index a5e3d8699c..7cfcaf348a 100644 > --- a/app/test/test_cfgfile.c > +++ b/app/test/test_cfgfile.c > @@ -5,48 +5,54 @@ > #include > #include > #include > -#include > +#include > + > +#ifdef RTE_EXEC_ENV_WINDOWS > +#include > +#endif > > #include > > #include "test.h" > -#include "resource.h" > - > - > -#define CFG_FILES_ETC "test_cfgfiles/etc" > > -REGISTER_LINKED_RESOURCE(test_cfgfiles); > +#include "test_cfgfiles.h" > > static int > -test_cfgfile_setup(void) > +make_tmp_file(char *filename, const char *prefix, const char *data) > { > - const struct resource *r; > - int ret; > + size_t len = strlen(data); > + size_t count; > + FILE *f; > > - r = resource_find("test_cfgfiles"); > - TEST_ASSERT_NOT_NULL(r, "missing resource test_cfgfiles"); > +#ifdef RTE_EXEC_ENV_WINDOWS > + char tempDirName[MAX_PATH - 14]; > > - ret = resource_untar(r); > - TEST_ASSERT_SUCCESS(ret, "failed to untar %s", r->name); > + if (GetTempPathA(sizeof(tempDirName), tempDirName) == 0) > + return -1; > > - return 0; > -} > + if (GetTempFileNameA(tempDirName, prefix, 0, filename) == 0) > + return -1; > > -static int > -test_cfgfile_cleanup(void) > -{ > - const struct resource *r; > - int ret; > + f = fopen(filename, "wt"); > +#else > + snprintf(filename, PATH_MAX, "/tmp/%s_XXXXXXX", prefix); > > - r = resource_find("test_cfgfiles"); > - TEST_ASSERT_NOT_NULL(r, "missing resource test_cfgfiles"); > + int fd = mkstemp(filename); > + if (fd < 0) > + return -1; > > - ret = resource_rm_by_tar(r); > - TEST_ASSERT_SUCCESS(ret, "Failed to delete resource %s", r->name); > + f = fdopen(fd, "w"); > +#endif > + if (f == NULL) > + return -1; > > - return 0; > + count = fwrite(data, sizeof(char), len, f); > + fclose(f); > + > + return (count == len) ? 0 : -1; > } > > + > static int > _test_cfgfile_sample(struct rte_cfgfile *cfgfile) > { > @@ -87,9 +93,13 @@ static int > test_cfgfile_sample1(void) > { > struct rte_cfgfile *cfgfile; > + char filename[PATH_MAX]; > int ret; > > - cfgfile = rte_cfgfile_load(CFG_FILES_ETC "/sample1.ini", 0); > + ret = make_tmp_file(filename, "sample1", sample1_ini); > + TEST_ASSERT_SUCCESS(ret, "Failed to setup temp file"); > + > + cfgfile = rte_cfgfile_load(filename, 0); > TEST_ASSERT_NOT_NULL(cfgfile, "Failed to load config file"); > > ret = _test_cfgfile_sample(cfgfile); > @@ -98,6 +108,8 @@ test_cfgfile_sample1(void) > ret = rte_cfgfile_close(cfgfile); > TEST_ASSERT_SUCCESS(ret, "Failed to close cfgfile"); > > + remove(filename); > + > return 0; > } > > @@ -106,15 +118,18 @@ test_cfgfile_sample2(void) > { > struct rte_cfgfile_parameters params; > struct rte_cfgfile *cfgfile; > + char filename[PATH_MAX]; > int ret; > > + ret = make_tmp_file(filename, "sample2", sample2_ini); > + TEST_ASSERT_SUCCESS(ret, "Failed to setup temp file"); > + > /* override comment character */ > memset(¶ms, 0, sizeof(params)); > params.comment_character = '#'; > > - cfgfile = rte_cfgfile_load_with_params(CFG_FILES_ETC "/sample2.ini", 0, > - ¶ms); > - TEST_ASSERT_NOT_NULL(cfgfile, "Failed to parse sample2.ini"); > + cfgfile = rte_cfgfile_load_with_params(filename, 0, ¶ms); > + TEST_ASSERT_NOT_NULL(cfgfile, "Failed to parse sample2"); > > ret = _test_cfgfile_sample(cfgfile); > TEST_ASSERT_SUCCESS(ret, "Failed to validate sample file: %d", ret); > @@ -122,6 +137,8 @@ test_cfgfile_sample2(void) > ret = rte_cfgfile_close(cfgfile); > TEST_ASSERT_SUCCESS(ret, "Failed to close cfgfile"); > > + remove(filename); > + > return 0; > } > > @@ -129,10 +146,14 @@ static int > test_cfgfile_realloc_sections(void) > { > struct rte_cfgfile *cfgfile; > + char filename[PATH_MAX]; > int ret; > const char *value; > > - cfgfile = rte_cfgfile_load(CFG_FILES_ETC "/realloc_sections.ini", 0); > + ret = make_tmp_file(filename, "realloc", realloc_sections_ini); > + TEST_ASSERT_SUCCESS(ret, "Failed to setup temp file"); > + > + cfgfile = rte_cfgfile_load(filename, 0); > TEST_ASSERT_NOT_NULL(cfgfile, "Failed to load config file"); > > ret = rte_cfgfile_num_sections(cfgfile, NULL, 0); > @@ -152,13 +173,15 @@ test_cfgfile_realloc_sections(void) > TEST_ASSERT(strcmp("value8_section9", value) == 0, > "key unexpected value: %s", value); > > - ret = rte_cfgfile_save(cfgfile, "/tmp/cfgfile_save.ini"); > + ret = rte_cfgfile_save(cfgfile, "/tmp/cfg_save.ini"); > TEST_ASSERT_SUCCESS(ret, "Failed to save *.ini file"); > - remove("/tmp/cfgfile_save.ini"); > + remove("/tmp/cfg_save.ini"); > > ret = rte_cfgfile_close(cfgfile); > TEST_ASSERT_SUCCESS(ret, "Failed to close cfgfile"); > > + remove(filename); > + > return 0; > } > > @@ -166,10 +189,16 @@ static int > test_cfgfile_invalid_section_header(void) > { > struct rte_cfgfile *cfgfile; > + char filename[PATH_MAX]; > + int ret; > + > + ret = make_tmp_file(filename, "invalid", invalid_section_ini); > + TEST_ASSERT_SUCCESS(ret, "Failed to setup temp file"); > > - cfgfile = rte_cfgfile_load(CFG_FILES_ETC "/invalid_section.ini", 0); > + cfgfile = rte_cfgfile_load(filename, 0); > TEST_ASSERT_NULL(cfgfile, "Expected failure did not occur"); > > + remove(filename); > return 0; > } > > @@ -178,15 +207,20 @@ test_cfgfile_invalid_comment(void) > { > struct rte_cfgfile_parameters params; > struct rte_cfgfile *cfgfile; > + char filename[PATH_MAX]; > + int ret; > > /* override comment character with an invalid one */ > memset(¶ms, 0, sizeof(params)); > params.comment_character = '$'; > > - cfgfile = rte_cfgfile_load_with_params(CFG_FILES_ETC "/sample2.ini", 0, > - ¶ms); > + ret = make_tmp_file(filename, "sample2", sample2_ini); > + TEST_ASSERT_SUCCESS(ret, "Failed to setup temp file"); > + > + cfgfile = rte_cfgfile_load_with_params(filename, 0, ¶ms); > TEST_ASSERT_NULL(cfgfile, "Expected failure did not occur"); > > + remove(filename); > return 0; > } > > @@ -194,10 +228,16 @@ static int > test_cfgfile_invalid_key_value_pair(void) > { > struct rte_cfgfile *cfgfile; > + char filename[PATH_MAX]; > + int ret; > + > + ret = make_tmp_file(filename, "empty_key", empty_key_value_ini); > + TEST_ASSERT_SUCCESS(ret, "Failed to setup temp file"); > > - cfgfile = rte_cfgfile_load(CFG_FILES_ETC "/empty_key_value.ini", 0); > + cfgfile = rte_cfgfile_load(filename, 0); > TEST_ASSERT_NULL(cfgfile, "Expected failure did not occur"); > > + remove(filename); > return 0; > } > > @@ -206,11 +246,14 @@ test_cfgfile_empty_key_value_pair(void) > { > struct rte_cfgfile *cfgfile; > const char *value; > + char filename[PATH_MAX]; > int ret; > > - cfgfile = rte_cfgfile_load(CFG_FILES_ETC "/empty_key_value.ini", > - CFG_FLAG_EMPTY_VALUES); > - TEST_ASSERT_NOT_NULL(cfgfile, "Failed to parse empty_key_value.ini"); > + ret = make_tmp_file(filename, "empty_key_value", empty_key_value_ini); > + TEST_ASSERT_SUCCESS(ret, "Failed to setup temp file"); > + > + cfgfile = rte_cfgfile_load(filename, CFG_FLAG_EMPTY_VALUES); > + TEST_ASSERT_NOT_NULL(cfgfile, "Failed to parse empty_key_value"); > > ret = rte_cfgfile_num_sections(cfgfile, NULL, 0); > TEST_ASSERT(ret == 1, "Unexpected number of sections: %d", ret); > @@ -227,6 +270,7 @@ test_cfgfile_empty_key_value_pair(void) > ret = rte_cfgfile_close(cfgfile); > TEST_ASSERT_SUCCESS(ret, "Failed to close cfgfile"); > > + remove(filename); > return 0; > } > > @@ -234,10 +278,16 @@ static int > test_cfgfile_missing_section(void) > { > struct rte_cfgfile *cfgfile; > + char filename[PATH_MAX]; > + int ret; > + > + ret = make_tmp_file(filename, "missing_section", missing_section_ini); > + TEST_ASSERT_SUCCESS(ret, "Failed to setup temp file"); > > - cfgfile = rte_cfgfile_load(CFG_FILES_ETC "/missing_section.ini", 0); > + cfgfile = rte_cfgfile_load(filename, 0); > TEST_ASSERT_NULL(cfgfile, "Expected failure did not occur"); > > + remove(filename); > return 0; > } > > @@ -246,10 +296,13 @@ test_cfgfile_global_properties(void) > { > struct rte_cfgfile *cfgfile; > const char *value; > + char filename[PATH_MAX]; > int ret; > > - cfgfile = rte_cfgfile_load(CFG_FILES_ETC "/missing_section.ini", > - CFG_FLAG_GLOBAL_SECTION); > + ret = make_tmp_file(filename, "missing_section", missing_section_ini); > + TEST_ASSERT_SUCCESS(ret, "Failed to setup temp file"); > + > + cfgfile = rte_cfgfile_load(filename, CFG_FLAG_GLOBAL_SECTION); > TEST_ASSERT_NOT_NULL(cfgfile, "Failed to load config file"); > > ret = rte_cfgfile_num_sections(cfgfile, NULL, 0); > @@ -268,6 +321,7 @@ test_cfgfile_global_properties(void) > ret = rte_cfgfile_close(cfgfile); > TEST_ASSERT_SUCCESS(ret, "Failed to close cfgfile"); > > + remove(filename); > return 0; > } > > @@ -275,9 +329,13 @@ static int > test_cfgfile_empty_file(void) > { > struct rte_cfgfile *cfgfile; > + char filename[PATH_MAX]; > int ret; > > - cfgfile = rte_cfgfile_load(CFG_FILES_ETC "/empty.ini", 0); > + ret = make_tmp_file(filename, "empty", empty_ini); > + TEST_ASSERT_SUCCESS(ret, "Failed to setup temp file"); > + > + cfgfile = rte_cfgfile_load(filename, 0); > TEST_ASSERT_NOT_NULL(cfgfile, "Failed to load config file"); > > ret = rte_cfgfile_num_sections(cfgfile, NULL, 0); > @@ -286,15 +344,13 @@ test_cfgfile_empty_file(void) > ret = rte_cfgfile_close(cfgfile); > TEST_ASSERT_SUCCESS(ret, "Failed to close cfgfile"); > > + remove(filename); > return 0; > } > > static int > test_cfgfile(void) > { > - if (test_cfgfile_setup()) > - return -1; > - > if (test_cfgfile_sample1()) > return -1; > > @@ -325,10 +381,7 @@ test_cfgfile(void) > if (test_cfgfile_empty_file()) > return -1; > > - if (test_cfgfile_cleanup()) > - return -1; > - > return 0; > } > > -REGISTER_TEST_COMMAND(cfgfile_autotest, test_cfgfile); > +REGISTER_FAST_TEST(cfgfile_autotest, true, true, test_cfgfile); > diff --git a/app/test/test_cfgfiles/meson.build b/app/test/test_cfgfiles/meson.build > new file mode 100644 > index 0000000000..068b61044a > --- /dev/null > +++ b/app/test/test_cfgfiles/meson.build > @@ -0,0 +1,19 @@ > +# SPDX-License-Identifier: BSD-3-Clause > + > +test_cfgfiles = files( > + 'etc/empty.ini', > + 'etc/empty_key_value.ini', > + 'etc/invalid_section.ini', > + 'etc/line_too_long.ini', > + 'etc/missing_section.ini', > + 'etc/realloc_sections.ini', > + 'etc/sample1.ini', > + 'etc/sample2.ini', > +) > + > +# generate the header file used in cfgfile test > +test_cfgfile_h = custom_target('test_cfgfile', > + output: 'test_cfgfiles.h', > + input: test_cfgfiles, > + capture: true, > + command: [ header_gen_cmd, '@INPUT@']) > -- > 2.43.0 >