From: Jiri Olsa <olsajiri@gmail.com>
To: Xing Guo <higuoxing@gmail.com>
Cc: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
ast@kernel.org, sveiss@meta.com, andrii@kernel.org
Subject: Re: [PATCH] selftests: arg_parsing: Ensure data is flushed to disk before reading.
Date: Tue, 14 Oct 2025 14:39:33 +0200 [thread overview]
Message-ID: <aO5EhTBn9Oq_MP2C@krava> (raw)
In-Reply-To: <20251014080323.1660391-1-higuoxing@gmail.com>
On Tue, Oct 14, 2025 at 04:03:23PM +0800, Xing Guo wrote:
> 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 | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/arg_parsing.c b/tools/testing/selftests/bpf/prog_tests/arg_parsing.c
> index bb143de68875..4f071943ffb0 100644
> --- a/tools/testing/selftests/bpf/prog_tests/arg_parsing.c
> +++ b/tools/testing/selftests/bpf/prog_tests/arg_parsing.c
> @@ -140,6 +140,7 @@ static void test_parse_test_list_file(void)
> fprintf(fp, "testA/subtest2\n");
> fprintf(fp, "testC_no_eof_newline");
> fflush(fp);
> + fsync(fd);
could we just close the fp stream instead flushing it twice?
maybe something like below, but not sure ferror will work
after the fclose call
jirka
---
diff --git a/tools/testing/selftests/bpf/prog_tests/arg_parsing.c b/tools/testing/selftests/bpf/prog_tests/arg_parsing.c
index bb143de68875..5a4c1bca2a1e 100644
--- a/tools/testing/selftests/bpf/prog_tests/arg_parsing.c
+++ b/tools/testing/selftests/bpf/prog_tests/arg_parsing.c
@@ -139,10 +139,10 @@ static void test_parse_test_list_file(void)
fprintf(fp, "testA/subtest # subtest duplicate\n");
fprintf(fp, "testA/subtest2\n");
fprintf(fp, "testC_no_eof_newline");
- fflush(fp);
+ fclose(fp);
if (!ASSERT_OK(ferror(fp), "prepare tmp"))
- goto out_fclose;
+ goto out_remove;
init_test_filter_set(&set);
@@ -160,8 +160,6 @@ static void test_parse_test_list_file(void)
free_test_filter_set(&set);
-out_fclose:
- fclose(fp);
out_remove:
remove(tmpfile);
}
next prev parent reply other threads:[~2025-10-14 12:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 8:03 [PATCH] selftests: arg_parsing: Ensure data is flushed to disk before reading Xing Guo
2025-10-14 12:39 ` Jiri Olsa [this message]
2025-10-14 20:53 ` Andrii Nakryiko
2025-10-15 2:43 ` [PATCH v2] " Xing Guo
2025-10-15 2:45 ` Alexei Starovoitov
2025-10-15 2:50 ` Xing Guo
2025-10-15 16:10 ` patchwork-bot+netdevbpf
2025-10-15 16:20 ` Andrii Nakryiko
2025-10-16 2:28 ` [PATCH v3] " Xing Guo
2025-10-16 2:32 ` [PATCH v2] " Xing Guo
2025-10-16 2:37 ` [PATCH bpf v4] " Xing Guo
2025-10-16 3:19 ` [PATCH bpf v5] " Xing Guo
2025-10-16 3:53 ` [PATCH bpf v6] " Xing Guo
2025-10-16 16:36 ` Andrii Nakryiko
2025-10-20 8:59 ` strace log before the fix, with fsync fix and with fclose fix Xing Guo
2025-10-20 16:28 ` Alexei Starovoitov
2025-10-20 20:12 ` Andrii Nakryiko
2025-10-21 22:14 ` Dominique Martinet
2025-10-16 16:40 ` [PATCH bpf v6] selftests: arg_parsing: Ensure data is flushed to disk before reading patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aO5EhTBn9Oq_MP2C@krava \
--to=olsajiri@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=higuoxing@gmail.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=sveiss@meta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox