* [PATCH] test/cfgfile: add check for file removal
@ 2024-11-20 16:50 Stephen Hemminger
2024-11-26 22:43 ` Thomas Monjalon
0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2024-11-20 16:50 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
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
Fixes: be22019a58c4 ("test: restore cfgfile tests")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test/test_cfgfile.c | 41 ++++++++++++++++++++++++++++++-----------
1 file changed, 30 insertions(+), 11 deletions(-)
diff --git a/app/test/test_cfgfile.c b/app/test/test_cfgfile.c
index 8146435033..b189d9d7a5 100644
--- a/app/test/test_cfgfile.c
+++ b/app/test/test_cfgfile.c
@@ -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;
}
--
2.45.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] test/cfgfile: add check for file removal
2024-11-20 16:50 [PATCH] test/cfgfile: add check for file removal Stephen Hemminger
@ 2024-11-26 22:43 ` Thomas Monjalon
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2024-11-26 22:43 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev
20/11/2024 17:50, Stephen Hemminger:
> 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
We use the tag "Coverity issue" and allow for a list with commas.
>
> Fixes: be22019a58c4 ("test: restore cfgfile tests")
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Applied, thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-26 22:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-20 16:50 [PATCH] test/cfgfile: add check for file removal Stephen Hemminger
2024-11-26 22:43 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).