The test_cfgfiles directory already had a line_too_long.ini file in it,
but this a) did not exceed the line length that the library could manage
and b) was not actually used in any test case.

Fix this by expanding the long line so it does trigger an error, and
adding a test case for it.

Signed-off-by: Bruce Richardson <[email protected]>
---
 app/test/test_cfgfile.c                  | 20 ++++++++++++++++++++
 app/test/test_cfgfiles/line_too_long.ini |  2 +-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/app/test/test_cfgfile.c b/app/test/test_cfgfile.c
index 12da87aa5a..f056fe2d4d 100644
--- a/app/test/test_cfgfile.c
+++ b/app/test/test_cfgfile.c
@@ -376,6 +376,25 @@ test_cfgfile_invalid_key_value_pair(void)
        return 0;
 }
 
+static int
+test_cfgfile_line_too_long(void)
+{
+       struct rte_cfgfile *cfgfile;
+       char filename[PATH_MAX];
+       int ret;
+
+       ret = make_tmp_file(filename, "line_too_long", line_too_long_ini);
+       TEST_ASSERT_SUCCESS(ret, "Failed to setup temp file");
+
+       cfgfile = rte_cfgfile_load(filename, 0);
+       TEST_ASSERT_NULL(cfgfile, "Expected failure did not occur");
+
+       ret = remove(filename);
+       TEST_ASSERT_SUCCESS(ret, "Failed to remove file");
+
+       return 0;
+}
+
 static int
 test_cfgfile_empty_key_value_pair(void)
 {
@@ -555,6 +574,7 @@ unit_test_suite test_cfgfile_suite  = {
                TEST_CASE(test_cfgfile_invalid_section_header),
                TEST_CASE(test_cfgfile_invalid_comment),
                TEST_CASE(test_cfgfile_invalid_key_value_pair),
+               TEST_CASE(test_cfgfile_line_too_long),
                TEST_CASE(test_cfgfile_empty_key_value_pair),
                TEST_CASE(test_cfgfile_missing_section),
                TEST_CASE(test_cfgfile_global_properties),
diff --git a/app/test/test_cfgfiles/line_too_long.ini 
b/app/test/test_cfgfiles/line_too_long.ini
index 1dce164838..2683cd2938 100644
--- a/app/test/test_cfgfiles/line_too_long.ini
+++ b/app/test/test_cfgfiles/line_too_long.ini
@@ -1,3 +1,3 @@
 [section1]
 ; this is section 1
-012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
+0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
-- 
2.53.0

Reply via email to