]> www.infradead.org Git - users/hch/misc.git/commitdiff
selftests: arg_parsing: Ensure data is flushed to disk before reading.
authorXing Guo <higuoxing@gmail.com>
Thu, 16 Oct 2025 03:53:30 +0000 (11:53 +0800)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 16 Oct 2025 16:34:39 +0000 (09:34 -0700)
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.

Fixes: 64276f01dce8 ("selftests/bpf: Test_progs can read test lists from file")
Signed-off-by: Xing Guo <higuoxing@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20251016035330.3217145-1-higuoxing@gmail.com
tools/testing/selftests/bpf/prog_tests/arg_parsing.c

index fbf0d9c2f58b3f1bc360c250da195d0505776c67..e27d66b75fb1fc0b5d8980f6768e48e1f79f69f6 100644 (file)
@@ -144,6 +144,9 @@ static void test_parse_test_list_file(void)
        if (!ASSERT_OK(ferror(fp), "prepare tmp"))
                goto out_fclose;
 
+       if (!ASSERT_OK(fsync(fileno(fp)), "fsync tmp"))
+               goto out_fclose;
+
        init_test_filter_set(&set);
 
        if (!ASSERT_OK(parse_test_list_file(tmpfile, &set, true), "parse file"))