Recently, I noticed a selftest failure in my local environment. The test_parse_test_list_file writes some data to /tmp/bpf_arg_parsing_test.XXXXXX and parse_test_list_file() will read the data back. However, after writing data to that file, we forget to call fsync() and it's causing testing failure in my laptop. This patch helps fix it by adding the missing fsync() call.
Signed-off-by: Xing Guo higuoxing@gmail.com --- tools/testing/selftests/bpf/prog_tests/arg_parsing.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/arg_parsing.c b/tools/testing/selftests/bpf/prog_tests/arg_parsing.c index bb143de68875..0f99f06116ea 100644 --- a/tools/testing/selftests/bpf/prog_tests/arg_parsing.c +++ b/tools/testing/selftests/bpf/prog_tests/arg_parsing.c @@ -140,9 +140,11 @@ static void test_parse_test_list_file(void) fprintf(fp, "testA/subtest2\n"); fprintf(fp, "testC_no_eof_newline"); fflush(fp); - - if (!ASSERT_OK(ferror(fp), "prepare tmp")) - goto out_fclose; + if (!ASSERT_OK(ferror(fp), "prepare tmp")) { + fclose(fp); + goto out_remove; + } + fclose(fp);
init_test_filter_set(&set);
@@ -160,8 +162,6 @@ static void test_parse_test_list_file(void)
free_test_filter_set(&set);
-out_fclose: - fclose(fp); out_remove: remove(tmpfile); }