[dpdk-dev,v4,5/5] test/cfgfile: add new unit test

Message ID 1499690657-81150-6-git-send-email-jacekx.piasecki@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Jacek Piasecki July 10, 2017, 12:44 p.m. UTC
  Load huge realloc_sections.ini file to check malloc/realloc
ability of cfgfile library.

Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
---
 test/test/test_cfgfile.c                         |  40 +++++++
 test/test/test_cfgfiles/etc/realloc_sections.ini | 128 +++++++++++++++++++++++
 2 files changed, 168 insertions(+)
 create mode 100644 test/test/test_cfgfiles/etc/realloc_sections.ini
  

Comments

Bruce Richardson Aug. 30, 2017, 8:25 p.m. UTC | #1
On Mon, Jul 10, 2017 at 02:44:17PM +0200, Jacek Piasecki wrote:
> Load huge realloc_sections.ini file to check malloc/realloc
> ability of cfgfile library.
> 
> Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
> ---

This may need some work still. The cfgfile tests fail for me when I run
them:

RTE>>cfgfile_autotest
TestCase test_cfgfile_realloc_sections() line 165 failed: Failed to load config file
Test Failed
RTE>>
  
Bruce Richardson Sept. 4, 2017, 9:21 a.m. UTC | #2
On Wed, Aug 30, 2017 at 09:25:51PM +0100, Bruce Richardson wrote:
> On Mon, Jul 10, 2017 at 02:44:17PM +0200, Jacek Piasecki wrote:
> > Load huge realloc_sections.ini file to check malloc/realloc
> > ability of cfgfile library.
> > 
> > Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
> > ---
> 
> This may need some work still. The cfgfile tests fail for me when I run
> them:
> 
> RTE>>cfgfile_autotest
> TestCase test_cfgfile_realloc_sections() line 165 failed: Failed to load config file
> Test Failed
> RTE>>
> 
Deleting the build directory and recreating it allows these tests to
pass. Following up with Jacek offline, it appears that the test data
used here is not copied over each time on build, which is what causes
the error - using old data/resources with the new tests. Therefore, it
appears the tests themselves are not at fault.

Acked-by: Bruce Richardson <bruce.richardson@intel.com>
  
Bruce Richardson Sept. 4, 2017, 9:30 a.m. UTC | #3
On Mon, Jul 10, 2017 at 02:44:17PM +0200, Jacek Piasecki wrote:
> Load huge realloc_sections.ini file to check malloc/realloc
> ability of cfgfile library.
> 
> Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
> ---
>  test/test/test_cfgfile.c                         |  40 +++++++
>  test/test/test_cfgfiles/etc/realloc_sections.ini | 128 +++++++++++++++++++++++
>  2 files changed, 168 insertions(+)
>  create mode 100644 test/test/test_cfgfiles/etc/realloc_sections.ini
> 
> diff --git a/test/test/test_cfgfile.c b/test/test/test_cfgfile.c
> index 4cc9b14..2278618 100644
> --- a/test/test/test_cfgfile.c
> +++ b/test/test/test_cfgfile.c
> @@ -111,6 +111,7 @@ _test_cfgfile_sample(struct rte_cfgfile *cfgfile)
>  	return 0;
>  }
>  
> +
>  static int
>  test_cfgfile_sample1(void)
>  {
> @@ -154,6 +155,42 @@ test_cfgfile_sample2(void)
>  }
>  
>  static int
> +test_cfgfile_realloc_sections(void)
> +{
> +	struct rte_cfgfile *cfgfile;
> +	int ret;
> +	const char *value;
> +
> +	cfgfile = rte_cfgfile_load(CFG_FILES_ETC "/realloc_sections.ini", 0);
> +	TEST_ASSERT_NOT_NULL(cfgfile, "Failed to load config file");
> +
> +	ret = rte_cfgfile_num_sections(cfgfile, NULL, 0);
> +	TEST_ASSERT(ret == 9, "Unexpected number of sections: %d", ret);
> +
> +	ret = rte_cfgfile_has_section(cfgfile, "section9");
> +	TEST_ASSERT(ret, "section9 missing");
> +
> +	ret = rte_cfgfile_section_num_entries(cfgfile, "section3");
> +	TEST_ASSERT(ret == 21,
> +			"section3 unexpected number of entries: %d", ret);
> +
> +	ret = rte_cfgfile_section_num_entries(cfgfile, "section9");
> +	TEST_ASSERT(ret == 8, "section9 unexpected number of entries: %d", ret);
> +
> +	value = rte_cfgfile_get_entry(cfgfile, "section9", "key8");
> +	TEST_ASSERT(strcmp("value8_section9", value) == 0,
> +		    "key unexpected value: %s", value);
> +
> +	ret = rte_cfgfile_save(cfgfile, "cfgfile_save.ini");
> +	TEST_ASSERT_SUCCESS(ret, "Failed to save *.ini file");

This file is a temporary one, so:
a) should be placed in /tmp
b) should be removed at the end of the test.
  
Thomas Monjalon Sept. 15, 2017, 1:56 p.m. UTC | #4
04/09/2017 11:30, Bruce Richardson:
> This file is a temporary one, so:
> a) should be placed in /tmp
> b) should be removed at the end of the test.

Jacek, do you plan to update this series in 17.11 timeframe?
  
Michal Jastrzebski Sept. 18, 2017, 1:49 p.m. UTC | #5
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Friday, September 15, 2017 3:56 PM
> To: Piasecki, JacekX <jacekx.piasecki@intel.com>
> Cc: dev@dpdk.org; Richardson, Bruce <bruce.richardson@intel.com>; Jain,
> Deepak K <deepak.k.jain@intel.com>; Kozak, KubaX
> <kubax.kozak@intel.com>; Jastrzebski, MichalX K
> <michalx.k.jastrzebski@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v4 5/5] test/cfgfile: add new unit test
> 
> 04/09/2017 11:30, Bruce Richardson:
> > This file is a temporary one, so:
> > a) should be placed in /tmp
> > b) should be removed at the end of the test.
> 
> Jacek, do you plan to update this series in 17.11 timeframe?

Hi Thomas, yes we plan to update the series.
V5 should be sent tomorrow.
  

Patch

diff --git a/test/test/test_cfgfile.c b/test/test/test_cfgfile.c
index 4cc9b14..2278618 100644
--- a/test/test/test_cfgfile.c
+++ b/test/test/test_cfgfile.c
@@ -111,6 +111,7 @@  _test_cfgfile_sample(struct rte_cfgfile *cfgfile)
 	return 0;
 }
 
+
 static int
 test_cfgfile_sample1(void)
 {
@@ -154,6 +155,42 @@  test_cfgfile_sample2(void)
 }
 
 static int
+test_cfgfile_realloc_sections(void)
+{
+	struct rte_cfgfile *cfgfile;
+	int ret;
+	const char *value;
+
+	cfgfile = rte_cfgfile_load(CFG_FILES_ETC "/realloc_sections.ini", 0);
+	TEST_ASSERT_NOT_NULL(cfgfile, "Failed to load config file");
+
+	ret = rte_cfgfile_num_sections(cfgfile, NULL, 0);
+	TEST_ASSERT(ret == 9, "Unexpected number of sections: %d", ret);
+
+	ret = rte_cfgfile_has_section(cfgfile, "section9");
+	TEST_ASSERT(ret, "section9 missing");
+
+	ret = rte_cfgfile_section_num_entries(cfgfile, "section3");
+	TEST_ASSERT(ret == 21,
+			"section3 unexpected number of entries: %d", ret);
+
+	ret = rte_cfgfile_section_num_entries(cfgfile, "section9");
+	TEST_ASSERT(ret == 8, "section9 unexpected number of entries: %d", ret);
+
+	value = rte_cfgfile_get_entry(cfgfile, "section9", "key8");
+	TEST_ASSERT(strcmp("value8_section9", value) == 0,
+		    "key unexpected value: %s", value);
+
+	ret = rte_cfgfile_save(cfgfile, "cfgfile_save.ini");
+	TEST_ASSERT_SUCCESS(ret, "Failed to save *.ini file");
+
+	ret = rte_cfgfile_close(cfgfile);
+	TEST_ASSERT_SUCCESS(ret, "Failed to close cfgfile");
+
+	return 0;
+}
+
+static int
 test_cfgfile_invalid_section_header(void)
 {
 	struct rte_cfgfile *cfgfile;
@@ -292,6 +329,9 @@  test_cfgfile(void)
 	if (test_cfgfile_sample2())
 		return -1;
 
+	if (test_cfgfile_realloc_sections())
+		return -1;
+
 	if (test_cfgfile_invalid_section_header())
 		return -1;
 
diff --git a/test/test/test_cfgfiles/etc/realloc_sections.ini b/test/test/test_cfgfiles/etc/realloc_sections.ini
new file mode 100644
index 0000000..e653e40
--- /dev/null
+++ b/test/test/test_cfgfiles/etc/realloc_sections.ini
@@ -0,0 +1,128 @@ 
+[section1]
+key1=value1_section1
+key2=value2_section1
+key3=value3_section1
+key4=value4_section1
+key5=value5_section1
+key6=value6_section1
+key7=value7_section1
+key8=value8_section1
+key9=value9_section1
+key10=value10_section1
+key11=value11_section1
+key12=value12_section1
+key13=value13_section1
+key14=value14_section1
+key15=value15_section1
+key16=value16_section1
+key17=value17_section1
+key18=value18_section1
+key19=value19_section1
+key20=value20_section1
+key21=value21_section1
+
+[section2]
+key1=value1_section2
+key2=value2_section2
+key3=value3_section2
+key4=value4_section2
+key5=value5_section2
+key6=value6_section2
+key7=value7_section2
+key8=value8_section2
+key9=value9_section2
+key10=value10_section2
+key11=value11_section2
+key12=value12_section2
+key13=value13_section2
+key14=value14_section2
+key15=value15_section2
+key16=value16_section2
+key17=value17_section2
+key18=value18_section2
+key19=value19_section2
+key20=value20_section2
+key21=value21_section2
+
+[section3]
+key1=value1_section3
+key2=value2_section3
+key3=value3_section3
+key4=value4_section3
+key5=value5_section3
+key6=value6_section3
+key7=value7_section3
+key8=value8_section3
+key9=value9_section3
+key10=value10_section3
+key11=value11_section3
+key12=value12_section3
+key13=value13_section3
+key14=value14_section3
+key15=value15_section3
+key16=value16_section3
+key17=value17_section3
+key18=value18_section3
+key19=value19_section3
+key20=value20_section3
+key21=value21_section3
+
+[section4]
+key1=value1_section4
+key2=value2_section4
+key3=value3_section4
+key4=value4_section4
+key5=value5_section4
+key6=value6_section4
+key7=value7_section4
+key8=value8_section4
+
+[section5]
+key1=value1_section5
+key2=value2_section5
+key3=value3_section5
+key4=value4_section5
+key5=value5_section5
+key6=value6_section5
+key7=value7_section5
+key8=value8_section5
+
+[section6]
+key1=value1_section6
+key2=value2_section6
+key3=value3_section6
+key4=value4_section6
+key5=value5_section6
+key6=value6_section6
+key7=value7_section6
+key8=value8_section6
+
+[section7]
+key1=value1_section7
+key2=value2_section7
+key3=value3_section7
+key4=value4_section7
+key5=value5_section7
+key6=value6_section7
+key7=value7_section7
+key8=value8_section7
+
+[section8]
+key1=value1_section8
+key2=value2_section8
+key3=value3_section8
+key4=value4_section8
+key5=value5_section8
+key6=value6_section8
+key7=value7_section8
+key8=value8_section8
+
+[section9]
+key1=value1_section9
+key2=value2_section9
+key3=value3_section9
+key4=value4_section9
+key5=value5_section9
+key6=value6_section9
+key7=value7_section9
+key8=value8_section9