All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Manu Bretelle <chantr4@gmail.com>
Cc: bpf@vger.kernel.org, andrii@kernel.org, daniel@iogearbox.net,
	ast@kernel.org, martin.lau@linux.dev, song@kernel.org,
	yonghong.song@linux.dev, john.fastabend@gmail.com,
	kpsingh@kernel.org, sdf@google.com, haoluo@google.com,
	mykolal@fb.com, shuah@kernel.org
Subject: Re: [PATCH bpf-next v2] selftests/bpf: fix test_bpffs
Date: Wed, 1 Nov 2023 15:40:37 +0100	[thread overview]
Message-ID: <ZUJjZR6AHRdNYVHu@krava> (raw)
In-Reply-To: <20231031223606.2927976-1-chantr4@gmail.com>

On Tue, Oct 31, 2023 at 03:36:06PM -0700, Manu Bretelle wrote:

SNIP

> After this change:
> 
>     $ vmtest -k $(make image_name) 'cd tools/testing/selftests/bpf && ./test_progs -vv -a test_bpffs'
>     => bzImage
>     ===> Booting
>     ===> Setting up VM
>     ===> Running command
>     [    2.295696] bpf_testmod: loading out-of-tree module taints kernel.
>     [    2.296468] bpf_testmod: module verification failed: signature and/or required key missing - tainting kernel
>     bpf_testmod.ko is already unloaded.
>     Loading bpf_testmod.ko...
>     Successfully loaded bpf_testmod.ko.
>     test_test_bpffs:PASS:clone 0 nsec
>     fn:PASS:unshare 0 nsec
>     fn:PASS:mount / 0 nsec
>     fn:PASS:mount tmpfs 0 nsec
>     fn:PASS:mkdir /tmp/test_bpffs_testdir/fs1 0 nsec
>     fn:PASS:mkdir /tmp/test_bpffs_testdir/fs2 0 nsec
>     fn:PASS:mount bpffs /tmp/test_bpffs_testdir/fs1 0 nsec
>     fn:PASS:mount bpffs /tmp/test_bpffs_testdir/fs2 0 nsec
>     fn:PASS:reading /tmp/test_bpffs_testdir/fs1/maps.debug 0 nsec
>     fn:PASS:reading /tmp/test_bpffs_testdir/fs2/progs.debug 0 nsec
>     fn:PASS:creating /tmp/test_bpffs_testdir/fs1/a 0 nsec
>     fn:PASS:creating /tmp/test_bpffs_testdir/fs1/a/1 0 nsec
>     fn:PASS:creating /tmp/test_bpffs_testdir/fs1/b 0 nsec
>     fn:PASS:create_map(ARRAY) 0 nsec
>     fn:PASS:pin map 0 nsec
>     fn:PASS:stat(/tmp/test_bpffs_testdir/fs1/a) 0 nsec
>     fn:PASS:renameat2(/fs1/a, /fs1/b, RENAME_EXCHANGE) 0 nsec
>     fn:PASS:stat(/tmp/test_bpffs_testdir/fs1/b) 0 nsec
>     fn:PASS:b should have a's inode 0 nsec
>     fn:PASS:access(/tmp/test_bpffs_testdir/fs1/b/1) 0 nsec
>     fn:PASS:stat(/tmp/test_bpffs_testdir/fs1/map) 0 nsec
>     fn:PASS:renameat2(/fs1/c, /fs1/b, RENAME_EXCHANGE) 0 nsec
>     fn:PASS:stat(/tmp/test_bpffs_testdir/fs1/b) 0 nsec
>     fn:PASS:b should have c's inode 0 nsec
>     fn:PASS:access(/tmp/test_bpffs_testdir/fs1/c/1) 0 nsec
>     fn:PASS:renameat2(RENAME_NOREPLACE) 0 nsec
>     fn:PASS:access(/tmp/test_bpffs_testdir/fs1/b) 0 nsec
>     bpf_testmod.ko is already unloaded.
>     Loading bpf_testmod.ko...
>     Successfully loaded bpf_testmod.ko.
>     test_test_bpffs:PASS:clone 0 nsec
>     test_test_bpffs:PASS:waitpid 0 nsec
>     test_test_bpffs:PASS:bpffs test  0 nsec
>     #282     test_bpffs:OK
>     Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED
>     Successfully unloaded bpf_testmod.ko.
> 
> [0] https://github.com/danobi/vmtest
> 
> This is a follow-up of https://lore.kernel.org/bpf/20231024201852.1512720-1-chantr4@gmail.com/T/
> 
> v1 -> v2:
>   - use a TDIR name that is related to test
>   - use C-style comments

Acked-by: Jiri Olsa <jolsa@kernel.org>

jirka

> 
> Signed-off-by: Manu Bretelle <chantr4@gmail.com>
> ---
>  tools/testing/selftests/bpf/prog_tests/test_bpffs.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/test_bpffs.c b/tools/testing/selftests/bpf/prog_tests/test_bpffs.c
> index 214d9f4a94a5..ea933fd151c3 100644
> --- a/tools/testing/selftests/bpf/prog_tests/test_bpffs.c
> +++ b/tools/testing/selftests/bpf/prog_tests/test_bpffs.c
> @@ -8,7 +8,8 @@
>  #include <sys/types.h>
>  #include <test_progs.h>
>  
> -#define TDIR "/sys/kernel/debug"
> +/* TDIR must be in a location we can create a directory in. */
> +#define TDIR "/tmp/test_bpffs_testdir"
>  
>  static int read_iter(char *file)
>  {
> @@ -43,8 +44,11 @@ static int fn(void)
>  	if (!ASSERT_OK(err, "mount /"))
>  		goto out;
>  
> -	err = umount(TDIR);
> -	if (!ASSERT_OK(err, "umount " TDIR))
> +	err =  mkdir(TDIR, 0777);
> +	/* If the directory already exists we can carry on. It may be left over
> +	 * from a previous run.
> +	 */
> +	if ((err && errno != EEXIST) && !ASSERT_OK(err, "mkdir " TDIR))
>  		goto out;
>  
>  	err = mount("none", TDIR, "tmpfs", 0, NULL);
> @@ -138,6 +142,7 @@ static int fn(void)
>  	rmdir(TDIR "/fs1");
>  	rmdir(TDIR "/fs2");
>  	umount(TDIR);
> +	rmdir(TDIR);
>  	exit(err);
>  }
>  
> -- 
> 2.40.1
> 

  reply	other threads:[~2023-11-01 14:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31 22:36 [PATCH bpf-next v2] selftests/bpf: fix test_bpffs Manu Bretelle
2023-11-01 14:40 ` Jiri Olsa [this message]
2023-11-02  6:00 ` 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=ZUJjZR6AHRdNYVHu@krava \
    --to=olsajiri@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chantr4@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kpsingh@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mykolal@fb.com \
    --cc=sdf@google.com \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.