On Tue, Oct 14, 2025 at 7:50 PM Xing Guo <[email protected]> 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 <[email protected]>
> ---
>  tools/testing/selftests/bpf/prog_tests/arg_parsing.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>

I accidentally applied it to bpf-next tree and had to drop it from there.

It actually doesn't apply to bpf tree cleanly, so please rebase and resend.

But first, did you validate that fclose() actually fixes the issue for
you? Because I don't think fclose() will call fsync(), will it?
fclose() will basically do the same thing as should be done with
fflush() anyways, so I have my doubts.

Furthermore, your commit message doesn't correspond to your patch.
There is no fsync() call here, please fix that as well.

> 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 via email to