Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Xing Guo <higuoxing@gmail.com>
To: alexei.starovoitov@gmail.com
Cc: andrii.nakryiko@gmail.com, andrii@kernel.org, ast@kernel.org,
	bpf@vger.kernel.org, higuoxing@gmail.com,
	linux-kselftest@vger.kernel.org, olsajiri@gmail.com,
	sveiss@meta.com
Subject: [PATCH v2] selftests: arg_parsing: Ensure data is flushed to disk before reading.
Date: Wed, 15 Oct 2025 10:50:49 +0800	[thread overview]
Message-ID: <20251015025049.9492-1-higuoxing@gmail.com> (raw)
In-Reply-To: <CAADnVQL8PWAqzfdaSYwn0JyX4_TBPWZmCunMn8ZRKJYwgb2KAQ@mail.gmail.com>

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);
 }
-- 
2.51.0


  reply	other threads:[~2025-10-15  2:50 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
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 [this message]
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=20251015025049.9492-1-higuoxing@gmail.com \
    --to=higuoxing@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=olsajiri@gmail.com \
    --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