Skip to content

Commit 27aab47

Browse files
higuoxinganakryiko
authored andcommitted
selftests: arg_parsing: Ensure data is flushed to disk before reading.
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 <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 48a97ff commit 27aab47

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tools/testing/selftests/bpf/prog_tests/arg_parsing.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,11 @@ static void test_parse_test_list_file(void)
140140
fprintf(fp, "testA/subtest2\n");
141141
fprintf(fp, "testC_no_eof_newline");
142142
fflush(fp);
143-
144-
if (!ASSERT_OK(ferror(fp), "prepare tmp"))
145-
goto out_fclose;
143+
if (!ASSERT_OK(ferror(fp), "prepare tmp")) {
144+
fclose(fp);
145+
goto out_remove;
146+
}
147+
fclose(fp);
146148

147149
init_test_filter_set(&set);
148150

@@ -160,8 +162,6 @@ static void test_parse_test_list_file(void)
160162

161163
free_test_filter_set(&set);
162164

163-
out_fclose:
164-
fclose(fp);
165165
out_remove:
166166
remove(tmpfile);
167167
}

0 commit comments

Comments
 (0)