[dpdk-dev] [PATCH v4 5/5] test/cfgfile: add new unit test
Bruce Richardson
bruce.richardson at intel.com
Mon Sep 4 11:30:54 CEST 2017
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 at 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.
More information about the dev
mailing list