test/cfgfile: add check for file removal
PATCH 1/1 test/cfgfile: add check for file removal
The test makes temporary files for parsing and then cleans up. It was not checking the return value from the remove step which makes Coverity unhappy.
Coverity ID: 451207
Coverity ID: 451209
Coverity ID: 451212
Coverity ID: 451213
Coverity ID: 451215
Coverity ID: 451217
Coverity ID: 451222
Coverity ID: 451225
--- app/test/test_cfgfile.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-)
app/test/test_cfgfile.c +30 -11
@@ -108,7 +108,8 @@ test_cfgfile_sample1(void) ret =rte_cfgfile_close (cfgfile);TEST_ASSERT_SUCCESS (ret,"Failed to close cfgfile" ); -remove (filename); + ret =remove (filename); +TEST_ASSERT_SUCCESS (ret,"Failed to remove file" );return 0 ; }
@@ -137,7 +138,8 @@ test_cfgfile_sample2(void) ret =rte_cfgfile_close (cfgfile);TEST_ASSERT_SUCCESS (ret,"Failed to close cfgfile" ); -remove (filename); + ret =remove (filename); +TEST_ASSERT_SUCCESS (ret,"Failed to remove file" );return 0 ; }
@@ -173,7 +175,8 @@ test_cfgfile_realloc_sections(void)TEST_ASSERT (strcmp ("value8_section9" , value) ==0 ,"key unexpected value: %s" , value); -remove (filename); + ret =remove (filename); +TEST_ASSERT_SUCCESS (ret,"Failed to remove file" );char tmp[PATH_MAX ] ="/tmp/" ;#ifdef RTE_EXEC_ENV_WINDOWS
@@ -184,7 +187,9 @@ test_cfgfile_realloc_sections(void) ret =rte_cfgfile_save (cfgfile, filename);TEST_ASSERT_SUCCESS (ret,"Failed to save to %s" , filename); -remove (filename); + + ret =remove (filename); +TEST_ASSERT_SUCCESS (ret,"Failed to remove file" ); ret =rte_cfgfile_close (cfgfile);TEST_ASSERT_SUCCESS (ret,"Failed to close cfgfile" );
@@ -205,7 +210,9 @@ test_cfgfile_invalid_section_header(void) cfgfile =rte_cfgfile_load (filename,0 );TEST_ASSERT_NULL (cfgfile,"Expected failure did not occur" ); -remove (filename); + ret =remove (filename); +TEST_ASSERT_SUCCESS (ret,"Failed to remove file" ); +return 0 ; }
@@ -227,7 +234,9 @@ test_cfgfile_invalid_comment(void) cfgfile =rte_cfgfile_load_with_params (filename,0 , ¶ms);TEST_ASSERT_NULL (cfgfile,"Expected failure did not occur" ); -remove (filename); + ret =remove (filename); +TEST_ASSERT_SUCCESS (ret,"Failed to remove file" ); +return 0 ; }
@@ -244,7 +253,9 @@ test_cfgfile_invalid_key_value_pair(void) cfgfile =rte_cfgfile_load (filename,0 );TEST_ASSERT_NULL (cfgfile,"Expected failure did not occur" ); -remove (filename); + ret =remove (filename); +TEST_ASSERT_SUCCESS (ret,"Failed to remove file" ); +return 0 ; }
@@ -277,7 +288,9 @@ test_cfgfile_empty_key_value_pair(void) ret =rte_cfgfile_close (cfgfile);TEST_ASSERT_SUCCESS (ret,"Failed to close cfgfile" ); -remove (filename); + ret =remove (filename); +TEST_ASSERT_SUCCESS (ret,"Failed to remove file" ); +return 0 ; }
@@ -294,7 +307,9 @@ test_cfgfile_missing_section(void) cfgfile =rte_cfgfile_load (filename,0 );TEST_ASSERT_NULL (cfgfile,"Expected failure did not occur" ); -remove (filename); + ret =remove (filename); +TEST_ASSERT_SUCCESS (ret,"Failed to remove file" ); +return 0 ; }
@@ -328,7 +343,9 @@ test_cfgfile_global_properties(void) ret =rte_cfgfile_close (cfgfile);TEST_ASSERT_SUCCESS (ret,"Failed to close cfgfile" ); -remove (filename); + ret =remove (filename); +TEST_ASSERT_SUCCESS (ret,"Failed to remove file" ); +return 0 ; }
@@ -351,7 +368,9 @@ test_cfgfile_empty_file(void) ret =rte_cfgfile_close (cfgfile);TEST_ASSERT_SUCCESS (ret,"Failed to close cfgfile" ); -remove (filename); + ret =remove (filename); +TEST_ASSERT_SUCCESS (ret,"Failed to remove file" ); +return 0 ; }
Signature · 1 line
2.45.2
Thomas Monjalon
Applied20/11/2024 17:50, Stephen Hemminger:
Quoted 4 lines
The test makes temporary files for parsing and then cleans up. It was not checking the return value from the remove step which makes Coverity unhappy.
Quoted 8 lines
Coverity ID: 451207
Coverity ID: 451209
Coverity ID: 451212
Coverity ID: 451213
Coverity ID: 451215
Coverity ID: 451217
Coverity ID: 451222
Coverity ID: 451225
We use the tag "Coverity issue" and allow for a list with commas.
Quoted 4 lines
Fixes be22019a58c4 ("test: restore cfgfile tests")Signed-off-by Stephen Hemminger <[email protected]>
Applied, thanks