Re: [PATCH rdma-core 4/6] pyverbs: Add unittests for extended completion-related classes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 03, 2019 at 05:53:50AM -0300, Noa Osherovich wrote:
> On 4/1/2019 5:26 PM, Jason Gunthorpe wrote:
> > On Sun, Mar 24, 2019 at 04:10:38PM +0200, Noa Osherovich wrote:
> >> Add unittests for extended CQ control path:
> >> - Creation and deletion of an extended CQ (good flow), with and
> >>   without a completion channel.
> >> - Bad flow checks: Verify failure for illegal comp_vector / cqe number.
> >>
> >> Signed-off-by: Noa Osherovich <noaos@xxxxxxxxxxxx>
> >> Reviewed-by: Maor Gottlieb <maorg@xxxxxxxxxxxx>
> >> Reviewed-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> >>  pyverbs/tests/cq.py | 81 ++++++++++++++++++++++++++++++++++++++++++++-
> >>  1 file changed, 80 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/pyverbs/tests/cq.py b/pyverbs/tests/cq.py
> >> index afe732e5e93c..4c1cea2b5296 100644
> >> +++ b/pyverbs/tests/cq.py
> >> @@ -6,8 +6,8 @@ Test module for pyverbs' cq module.
> >>  import unittest
> >>  import random
> >>  
> >> +from pyverbs.cq import CompChannel, CQ, CqInitAttrEx, CQEX
> >>  from pyverbs.pyverbs_error import PyverbsError
> >> -from pyverbs.cq import CompChannel, CQ
> >>  import pyverbs.device as d
> >>  import pyverbs.enums as e
> >>  
> >> @@ -124,7 +124,86 @@ class CCTest(unittest.TestCase):
> >>                  cc.close()
> >>  
> >>  
> >> +class CQEXTest(unittest.TestCase):
> >> +    """
> >> +    Test various functionalities of the CQEX class.
> >> +    """
> >> +
> >> +    @staticmethod
> >> +    def test_create_cq_ex():
> >> +        """
> >> +        Test ibv_create_cq_ex()
> >> +        """
> >> +        lst = d.get_device_list()
> >> +        for dev in lst:
> >> +            with d.Context(name=dev.name.decode()) as ctx:
> >> +                with CQEX(ctx, get_attrs_ex(ctx)):
> >> +                    pass
> > There is a way to use unittest so that it will setup a context before
> > calling the test - avoiding all this repetition. You should make a
> > patch to convert to that approach.
> >
> > Jason
> 
> Hi Jason, sorry for the late reply.
> I might be missing something. There's a setUp() method that seems to be
> just for that. Thing is, our tests iterate through all the available
> devices, and each case is executed for all the devices. Is this possible
> using setUp() or were you referring to something else?

The device to test should be an argument to the test runner and the
test runner should arrange things to iterate over the set of devices
to test

I forget exactly how I did this last time I worked with unit test, but
it wasn't hard..

Jason




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux