netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf] selftest/bpf: make bpftool if it is not already built
@ 2020-08-14  8:57 Balamuruhan S
  2020-08-14 16:01 ` Yonghong Song
  0 siblings, 1 reply; 3+ messages in thread
From: Balamuruhan S @ 2020-08-14  8:57 UTC (permalink / raw)
  To: bpf
  Cc: netdev, ast, daniel, naveen.n.rao, ravi.bangoria, sandipan,
	kafai, songliubraving, yhs, andriin, john.fastabend, kpsingh,
	Balamuruhan S

test_bpftool error out if bpftool is not available in bpftool dir
linux/tools/bpf/bpftool, build and clean it as part of test
bootstrap and teardown.

Error log:
---------
test_feature_dev_json (test_bpftool.TestBpftool) ... ERROR
test_feature_kernel (test_bpftool.TestBpftool) ... ERROR
test_feature_kernel_full (test_bpftool.TestBpftool) ... ERROR
test_feature_kernel_full_vs_not_full (test_bpftool.TestBpftool) ... ERROR
test_feature_macros (test_bpftool.TestBpftool) ... ERROR

======================================================================
ERROR: test_feature_dev_json (test_bpftool.TestBpftool)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ubuntu/disk/linux/tools/testing/selftests/bpf/test_bpftool.py",
    return f(*args, iface, **kwargs)
  File "/home/ubuntu/disk/linux/tools/testing/selftests/bpf/test_bpftool.py",
    res = bpftool_json(["feature", "probe", "dev", iface])
  File "/home/ubuntu/disk/linux/tools/testing/selftests/bpf/test_bpftool.py",
    res = _bpftool(args)
  File "/home/ubuntu/disk/linux/tools/testing/selftests/bpf/test_bpftool.py",
    return subprocess.check_output(_args)
  File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.8/subprocess.py", line 489, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'bpftool'

Signed-off-by: Balamuruhan S <bala24@linux.ibm.com>
---
 tools/testing/selftests/bpf/test_bpftool.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tools/testing/selftests/bpf/test_bpftool.py b/tools/testing/selftests/bpf/test_bpftool.py
index 4fed2dc25c0a..60357c6891a6 100644
--- a/tools/testing/selftests/bpf/test_bpftool.py
+++ b/tools/testing/selftests/bpf/test_bpftool.py
@@ -58,12 +58,25 @@ def default_iface(f):
     return wrapper
 
 
+def make_bpftool(clean=False):
+    cmd = "make"
+    if clean:
+        cmd = "make clean"
+    return subprocess.run(cmd, shell=True, cwd=bpftool_dir, check=True,
+                          stdout=subprocess.DEVNULL)
+
 class TestBpftool(unittest.TestCase):
     @classmethod
     def setUpClass(cls):
         if os.getuid() != 0:
             raise UnprivilegedUserError(
                 "This test suite needs root privileges")
+        if subprocess.getstatusoutput("bpftool -h")[0]:
+            make_bpftool()
+
+    @classmethod
+    def tearDownClass(cls):
+        make_bpftool(clean=True)
 
     @default_iface
     def test_feature_dev_json(self, iface):

base-commit: 6e868cf355725fbe9fa512d01b09b8ee7f3358f0
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf] selftest/bpf: make bpftool if it is not already built
  2020-08-14  8:57 [PATCH bpf] selftest/bpf: make bpftool if it is not already built Balamuruhan S
@ 2020-08-14 16:01 ` Yonghong Song
  2020-08-18  7:44   ` Balamuruhan S
  0 siblings, 1 reply; 3+ messages in thread
From: Yonghong Song @ 2020-08-14 16:01 UTC (permalink / raw)
  To: Balamuruhan S, bpf
  Cc: netdev, ast, daniel, naveen.n.rao, ravi.bangoria, sandipan,
	kafai, songliubraving, andriin, john.fastabend, kpsingh



On 8/14/20 1:57 AM, Balamuruhan S wrote:
> test_bpftool error out if bpftool is not available in bpftool dir
> linux/tools/bpf/bpftool, build and clean it as part of test
> bootstrap and teardown.
> 
> Error log:
> ---------
> test_feature_dev_json (test_bpftool.TestBpftool) ... ERROR
> test_feature_kernel (test_bpftool.TestBpftool) ... ERROR
> test_feature_kernel_full (test_bpftool.TestBpftool) ... ERROR
> test_feature_kernel_full_vs_not_full (test_bpftool.TestBpftool) ... ERROR
> test_feature_macros (test_bpftool.TestBpftool) ... ERROR
> 
> ======================================================================
> ERROR: test_feature_dev_json (test_bpftool.TestBpftool)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>    File "/home/ubuntu/disk/linux/tools/testing/selftests/bpf/test_bpftool.py",
>      return f(*args, iface, **kwargs)
>    File "/home/ubuntu/disk/linux/tools/testing/selftests/bpf/test_bpftool.py",
>      res = bpftool_json(["feature", "probe", "dev", iface])
>    File "/home/ubuntu/disk/linux/tools/testing/selftests/bpf/test_bpftool.py",
>      res = _bpftool(args)
>    File "/home/ubuntu/disk/linux/tools/testing/selftests/bpf/test_bpftool.py",
>      return subprocess.check_output(_args)
>    File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
>      return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
>    File "/usr/lib/python3.8/subprocess.py", line 489, in run
>      with Popen(*popenargs, **kwargs) as process:
>    File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
>      self._execute_child(args, executable, preexec_fn, close_fds,
>    File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
>      raise child_exception_type(errno_num, err_msg, err_filename)
> FileNotFoundError: [Errno 2] No such file or directory: 'bpftool'
> 
> Signed-off-by: Balamuruhan S <bala24@linux.ibm.com>
> ---
>   tools/testing/selftests/bpf/test_bpftool.py | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
> 
> diff --git a/tools/testing/selftests/bpf/test_bpftool.py b/tools/testing/selftests/bpf/test_bpftool.py
> index 4fed2dc25c0a..60357c6891a6 100644
> --- a/tools/testing/selftests/bpf/test_bpftool.py
> +++ b/tools/testing/selftests/bpf/test_bpftool.py
> @@ -58,12 +58,25 @@ def default_iface(f):
>       return wrapper
>   
>   
> +def make_bpftool(clean=False):
> +    cmd = "make"
> +    if clean:
> +        cmd = "make clean"
> +    return subprocess.run(cmd, shell=True, cwd=bpftool_dir, check=True,
> +                          stdout=subprocess.DEVNULL)
> +
>   class TestBpftool(unittest.TestCase):
>       @classmethod
>       def setUpClass(cls):
>           if os.getuid() != 0:
>               raise UnprivilegedUserError(
>                   "This test suite needs root privileges")
> +        if subprocess.getstatusoutput("bpftool -h")[0]:
> +            make_bpftool()
> +
> +    @classmethod
> +    def tearDownClass(cls):
> +        make_bpftool(clean=True)

I think make_bpftool clean should only be called if the make actually
triggered during setUpClass, right?

>   
>       @default_iface
>       def test_feature_dev_json(self, iface):
> 
> base-commit: 6e868cf355725fbe9fa512d01b09b8ee7f3358f0
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf] selftest/bpf: make bpftool if it is not already built
  2020-08-14 16:01 ` Yonghong Song
@ 2020-08-18  7:44   ` Balamuruhan S
  0 siblings, 0 replies; 3+ messages in thread
From: Balamuruhan S @ 2020-08-18  7:44 UTC (permalink / raw)
  To: Yonghong Song, bpf
  Cc: netdev, ast, daniel, naveen.n.rao, ravi.bangoria, sandipan,
	kafai, songliubraving, andriin, john.fastabend, kpsingh

On Fri, 2020-08-14 at 09:01 -0700, Yonghong Song wrote:
> 
> On 8/14/20 1:57 AM, Balamuruhan S wrote:
> > test_bpftool error out if bpftool is not available in bpftool dir
> > linux/tools/bpf/bpftool, build and clean it as part of test
> > bootstrap and teardown.
> > 
> > Error log:
> > ---------
> > test_feature_dev_json (test_bpftool.TestBpftool) ... ERROR
> > test_feature_kernel (test_bpftool.TestBpftool) ... ERROR
> > test_feature_kernel_full (test_bpftool.TestBpftool) ... ERROR
> > test_feature_kernel_full_vs_not_full (test_bpftool.TestBpftool) ... ERROR
> > test_feature_macros (test_bpftool.TestBpftool) ... ERROR
> > 
> > ======================================================================
> > ERROR: test_feature_dev_json (test_bpftool.TestBpftool)
> > ----------------------------------------------------------------------
> > Traceback (most recent call last):
> >    File
> > "/home/ubuntu/disk/linux/tools/testing/selftests/bpf/test_bpftool.py",
> >      return f(*args, iface, **kwargs)
> >    File
> > "/home/ubuntu/disk/linux/tools/testing/selftests/bpf/test_bpftool.py",
> >      res = bpftool_json(["feature", "probe", "dev", iface])
> >    File
> > "/home/ubuntu/disk/linux/tools/testing/selftests/bpf/test_bpftool.py",
> >      res = _bpftool(args)
> >    File
> > "/home/ubuntu/disk/linux/tools/testing/selftests/bpf/test_bpftool.py",
> >      return subprocess.check_output(_args)
> >    File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
> >      return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
> >    File "/usr/lib/python3.8/subprocess.py", line 489, in run
> >      with Popen(*popenargs, **kwargs) as process:
> >    File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
> >      self._execute_child(args, executable, preexec_fn, close_fds,
> >    File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
> >      raise child_exception_type(errno_num, err_msg, err_filename)
> > FileNotFoundError: [Errno 2] No such file or directory: 'bpftool'
> > 
> > Signed-off-by: Balamuruhan S <bala24@linux.ibm.com>
> > ---
> >   tools/testing/selftests/bpf/test_bpftool.py | 13 +++++++++++++
> >   1 file changed, 13 insertions(+)
> > 
> > diff --git a/tools/testing/selftests/bpf/test_bpftool.py
> > b/tools/testing/selftests/bpf/test_bpftool.py
> > index 4fed2dc25c0a..60357c6891a6 100644
> > --- a/tools/testing/selftests/bpf/test_bpftool.py
> > +++ b/tools/testing/selftests/bpf/test_bpftool.py
> > @@ -58,12 +58,25 @@ def default_iface(f):
> >       return wrapper
> >   
> >   
> > +def make_bpftool(clean=False):
> > +    cmd = "make"
> > +    if clean:
> > +        cmd = "make clean"
> > +    return subprocess.run(cmd, shell=True, cwd=bpftool_dir, check=True,
> > +                          stdout=subprocess.DEVNULL)
> > +
> >   class TestBpftool(unittest.TestCase):
> >       @classmethod
> >       def setUpClass(cls):
> >           if os.getuid() != 0:
> >               raise UnprivilegedUserError(
> >                   "This test suite needs root privileges")
> > +        if subprocess.getstatusoutput("bpftool -h")[0]:
> > +            make_bpftool()
> > +
> > +    @classmethod
> > +    def tearDownClass(cls):
> > +        make_bpftool(clean=True)
> 
> I think make_bpftool clean should only be called if the make actually
> triggered during setUpClass, right?

yes, I will fix it in the next version.

> 
> >   
> >       @default_iface
> >       def test_feature_dev_json(self, iface):
> > 
> > base-commit: 6e868cf355725fbe9fa512d01b09b8ee7f3358f0
> > 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-18  7:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-14  8:57 [PATCH bpf] selftest/bpf: make bpftool if it is not already built Balamuruhan S
2020-08-14 16:01 ` Yonghong Song
2020-08-18  7:44   ` Balamuruhan S

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).