From patchwork Mon Aug 19 06:58:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noa Osherovich X-Patchwork-Id: 11100359 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3576817E2 for ; Mon, 19 Aug 2019 06:58:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24A5928560 for ; Mon, 19 Aug 2019 06:58:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1906B285A0; Mon, 19 Aug 2019 06:58:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C8CB28560 for ; Mon, 19 Aug 2019 06:58:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725872AbfHSG6i (ORCPT ); Mon, 19 Aug 2019 02:58:38 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:53151 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726390AbfHSG6f (ORCPT ); Mon, 19 Aug 2019 02:58:35 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from noaos@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Aug 2019 09:58:30 +0300 Received: from reg-l-vrt-059-007.mtl.labs.mlnx (reg-l-vrt-059-007.mtl.labs.mlnx [10.135.59.7]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7J6wUND004602; Mon, 19 Aug 2019 09:58:30 +0300 From: Noa Osherovich To: dledford@redhat.com, jgg@mellanox.com, leonro@mellanox.com Cc: linux-rdma@vger.kernel.org, Noa Osherovich Subject: [PATCH rdma-core 01/14] pyverbs/tests: Rename base class Date: Mon, 19 Aug 2019 09:58:14 +0300 Message-Id: <20190819065827.26921-2-noaos@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819065827.26921-1-noaos@mellanox.com> References: <20190819065827.26921-1-noaos@mellanox.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Rename PyverbsTestCase to PyverbsAPITestCase as a preparation for addition of feature-based tests. Signed-off-by: Noa Osherovich --- pyverbs/tests/addr.py | 4 ++-- pyverbs/tests/base.py | 2 +- pyverbs/tests/cq.py | 8 ++++---- pyverbs/tests/device.py | 4 ++-- pyverbs/tests/mr.py | 8 ++++---- pyverbs/tests/pd.py | 4 ++-- pyverbs/tests/qp.py | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pyverbs/tests/addr.py b/pyverbs/tests/addr.py index 1326eec0d0f6..1c56f56bd0bd 100644 --- a/pyverbs/tests/addr.py +++ b/pyverbs/tests/addr.py @@ -1,15 +1,15 @@ # SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) # Copyright (c) 2019 Mellanox Technologies, Inc. All rights reserved. See COPYING file +from pyverbs.tests.base import PyverbsAPITestCase from pyverbs.addr import GlobalRoute, AHAttr, AH from pyverbs.pyverbs_error import PyverbsError -from pyverbs.tests.base import PyverbsTestCase import pyverbs.device as d import pyverbs.enums as e from pyverbs.pd import PD from pyverbs.cq import WC -class AHTest(PyverbsTestCase): +class AHTest(PyverbsAPITestCase): """ Test various functionalities of the AH class. """ diff --git a/pyverbs/tests/base.py b/pyverbs/tests/base.py index 9541e61b0d55..a1eae2becdc0 100644 --- a/pyverbs/tests/base.py +++ b/pyverbs/tests/base.py @@ -5,7 +5,7 @@ import unittest import pyverbs.device as d -class PyverbsTestCase(unittest.TestCase): +class PyverbsAPITestCase(unittest.TestCase): def setUp(self): """ Opens the devices and queries them diff --git a/pyverbs/tests/cq.py b/pyverbs/tests/cq.py index 38f145f865ba..e1e56d363011 100644 --- a/pyverbs/tests/cq.py +++ b/pyverbs/tests/cq.py @@ -7,12 +7,12 @@ import random from pyverbs.cq import CompChannel, CQ, CqInitAttrEx, CQEX from pyverbs.pyverbs_error import PyverbsError -from pyverbs.tests.base import PyverbsTestCase +from pyverbs.tests.base import PyverbsAPITestCase import pyverbs.tests.utils as u import pyverbs.enums as e -class CQTest(PyverbsTestCase): +class CQTest(PyverbsAPITestCase): """ Test various functionalities of the CQ class. """ @@ -84,7 +84,7 @@ class CQTest(PyverbsTestCase): cq.close() -class CCTest(PyverbsTestCase): +class CCTest(PyverbsAPITestCase): """ Test various functionalities of the Completion Channel class. """ @@ -105,7 +105,7 @@ class CCTest(PyverbsTestCase): cc.close() -class CQEXTest(PyverbsTestCase): +class CQEXTest(PyverbsAPITestCase): """ Test various functionalities of the CQEX class. """ diff --git a/pyverbs/tests/device.py b/pyverbs/tests/device.py index 54ff438d12fa..63f195156119 100644 --- a/pyverbs/tests/device.py +++ b/pyverbs/tests/device.py @@ -8,7 +8,7 @@ import resource import random from pyverbs.pyverbs_error import PyverbsError, PyverbsRDMAError -from pyverbs.tests.base import PyverbsTestCase +from pyverbs.tests.base import PyverbsAPITestCase import pyverbs.tests.utils as u import pyverbs.device as d @@ -137,7 +137,7 @@ class DeviceTest(unittest.TestCase): format(p=port)) -class DMTest(PyverbsTestCase): +class DMTest(PyverbsAPITestCase): """ Test various functionalities of the DM class. """ diff --git a/pyverbs/tests/mr.py b/pyverbs/tests/mr.py index e303fd575de4..4be3987fc18b 100644 --- a/pyverbs/tests/mr.py +++ b/pyverbs/tests/mr.py @@ -7,7 +7,7 @@ from itertools import combinations as com import random from pyverbs.pyverbs_error import PyverbsRDMAError, PyverbsError -from pyverbs.tests.base import PyverbsTestCase +from pyverbs.tests.base import PyverbsAPITestCase from pyverbs.base import PyverbsRDMAErrno from pyverbs.mr import MR, MW, DMMR import pyverbs.tests.utils as u @@ -18,7 +18,7 @@ import pyverbs.enums as e MAX_IO_LEN = 1048576 -class MRTest(PyverbsTestCase): +class MRTest(PyverbsAPITestCase): """ Test various functionalities of the MR class. """ @@ -154,7 +154,7 @@ class MRTest(PyverbsTestCase): mr.buf -class MWTest(PyverbsTestCase): +class MWTest(PyverbsAPITestCase): """ Test various functionalities of the MW class. """ @@ -200,7 +200,7 @@ class MWTest(PyverbsTestCase): format(t=mw_type)) -class DMMRTest(PyverbsTestCase): +class DMMRTest(PyverbsAPITestCase): """ Test various functionalities of the DMMR class. """ diff --git a/pyverbs/tests/pd.py b/pyverbs/tests/pd.py index 5072a4a35de1..87528db7d437 100644 --- a/pyverbs/tests/pd.py +++ b/pyverbs/tests/pd.py @@ -5,13 +5,13 @@ Test module for pyverbs' pd module. """ import random -from pyverbs.tests.base import PyverbsTestCase +from pyverbs.tests.base import PyverbsAPITestCase from pyverbs.base import PyverbsRDMAErrno import pyverbs.device as d from pyverbs.pd import PD -class PDTest(PyverbsTestCase): +class PDTest(PyverbsAPITestCase): """ Test various functionalities of the PD class. """ diff --git a/pyverbs/tests/qp.py b/pyverbs/tests/qp.py index be152d4ca5bd..bbf28244f641 100644 --- a/pyverbs/tests/qp.py +++ b/pyverbs/tests/qp.py @@ -5,7 +5,7 @@ Test module for pyverbs' qp module. """ import random -from pyverbs.tests.base import PyverbsTestCase +from pyverbs.tests.base import PyverbsAPITestCase from pyverbs.qp import QPInitAttr, QPAttr, QP import pyverbs.tests.utils as u import pyverbs.enums as e @@ -13,7 +13,7 @@ from pyverbs.pd import PD from pyverbs.cq import CQ -class QPTest(PyverbsTestCase): +class QPTest(PyverbsAPITestCase): """ Test various functionalities of the QP class. """ From patchwork Mon Aug 19 06:58:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noa Osherovich X-Patchwork-Id: 11100343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 43EBA1908 for ; Mon, 19 Aug 2019 06:58:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34002285A0 for ; Mon, 19 Aug 2019 06:58:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28C31285A7; Mon, 19 Aug 2019 06:58:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3E41285A8 for ; Mon, 19 Aug 2019 06:58:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725958AbfHSG6f (ORCPT ); Mon, 19 Aug 2019 02:58:35 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:53157 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726211AbfHSG6f (ORCPT ); Mon, 19 Aug 2019 02:58:35 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from noaos@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Aug 2019 09:58:30 +0300 Received: from reg-l-vrt-059-007.mtl.labs.mlnx (reg-l-vrt-059-007.mtl.labs.mlnx [10.135.59.7]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7J6wUNE004602; Mon, 19 Aug 2019 09:58:30 +0300 From: Noa Osherovich To: dledford@redhat.com, jgg@mellanox.com, leonro@mellanox.com Cc: linux-rdma@vger.kernel.org, Noa Osherovich Subject: [PATCH rdma-core 02/14] pyverbs: Move tests to a stand-alone directory Date: Mon, 19 Aug 2019 09:58:15 +0300 Message-Id: <20190819065827.26921-3-noaos@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819065827.26921-1-noaos@mellanox.com> References: <20190819065827.26921-1-noaos@mellanox.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Unittests can be added regardless of pyverbs, change the directory hierarchy to reflect that. Signed-off-by: Noa Osherovich --- tests/CMakeLists.txt | 14 ++++++++++++++ {pyverbs/tests => tests}/__init__.py | 0 {pyverbs/tests => tests}/base.py | 0 pyverbs/tests/addr.py => tests/test_addr.py | 2 +- pyverbs/tests/cq.py => tests/test_cq.py | 4 ++-- pyverbs/tests/device.py => tests/test_device.py | 4 ++-- pyverbs/tests/mr.py => tests/test_mr.py | 4 ++-- pyverbs/tests/pd.py => tests/test_pd.py | 2 +- pyverbs/tests/qp.py => tests/test_qp.py | 4 ++-- {pyverbs/tests => tests}/utils.py | 0 10 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 tests/CMakeLists.txt rename {pyverbs/tests => tests}/__init__.py (100%) rename {pyverbs/tests => tests}/base.py (100%) rename pyverbs/tests/addr.py => tests/test_addr.py (98%) rename pyverbs/tests/cq.py => tests/test_cq.py (98%) rename pyverbs/tests/device.py => tests/test_device.py (99%) rename pyverbs/tests/mr.py => tests/test_mr.py (99%) rename pyverbs/tests/pd.py => tests/test_pd.py (97%) rename pyverbs/tests/qp.py => tests/test_qp.py (99%) rename {pyverbs/tests => tests}/utils.py (100%) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 000000000000..f1ba542fab90 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) +# Copyright (c) 2019, Mellanox Technologies. All rights reserved. See COPYING file + +rdma_python_test(tests + __init__.py + test_addr.py + base.py + test_cq.py + test_device.py + test_mr.py + test_pd.py + test_qp.py + utils.py + ) diff --git a/pyverbs/tests/__init__.py b/tests/__init__.py similarity index 100% rename from pyverbs/tests/__init__.py rename to tests/__init__.py diff --git a/pyverbs/tests/base.py b/tests/base.py similarity index 100% rename from pyverbs/tests/base.py rename to tests/base.py diff --git a/pyverbs/tests/addr.py b/tests/test_addr.py similarity index 98% rename from pyverbs/tests/addr.py rename to tests/test_addr.py index 1c56f56bd0bd..9cc801226e69 100644 --- a/pyverbs/tests/addr.py +++ b/tests/test_addr.py @@ -1,9 +1,9 @@ # SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) # Copyright (c) 2019 Mellanox Technologies, Inc. All rights reserved. See COPYING file -from pyverbs.tests.base import PyverbsAPITestCase from pyverbs.addr import GlobalRoute, AHAttr, AH from pyverbs.pyverbs_error import PyverbsError +from tests.base import PyverbsAPITestCase import pyverbs.device as d import pyverbs.enums as e from pyverbs.pd import PD diff --git a/pyverbs/tests/cq.py b/tests/test_cq.py similarity index 98% rename from pyverbs/tests/cq.py rename to tests/test_cq.py index e1e56d363011..7848f39c9c63 100644 --- a/pyverbs/tests/cq.py +++ b/tests/test_cq.py @@ -7,9 +7,9 @@ import random from pyverbs.cq import CompChannel, CQ, CqInitAttrEx, CQEX from pyverbs.pyverbs_error import PyverbsError -from pyverbs.tests.base import PyverbsAPITestCase -import pyverbs.tests.utils as u +from tests.base import PyverbsAPITestCase import pyverbs.enums as e +import tests.utils as u class CQTest(PyverbsAPITestCase): diff --git a/pyverbs/tests/device.py b/tests/test_device.py similarity index 99% rename from pyverbs/tests/device.py rename to tests/test_device.py index 63f195156119..e395e793c28f 100644 --- a/pyverbs/tests/device.py +++ b/tests/test_device.py @@ -8,8 +8,8 @@ import resource import random from pyverbs.pyverbs_error import PyverbsError, PyverbsRDMAError -from pyverbs.tests.base import PyverbsAPITestCase -import pyverbs.tests.utils as u +from tests.base import PyverbsAPITestCase +import tests.utils as u import pyverbs.device as d PAGE_SIZE = resource.getpagesize() diff --git a/pyverbs/tests/mr.py b/tests/test_mr.py similarity index 99% rename from pyverbs/tests/mr.py rename to tests/test_mr.py index 4be3987fc18b..e87fb33624ed 100644 --- a/pyverbs/tests/mr.py +++ b/tests/test_mr.py @@ -7,13 +7,13 @@ from itertools import combinations as com import random from pyverbs.pyverbs_error import PyverbsRDMAError, PyverbsError -from pyverbs.tests.base import PyverbsAPITestCase +from tests.base import PyverbsAPITestCase from pyverbs.base import PyverbsRDMAErrno from pyverbs.mr import MR, MW, DMMR -import pyverbs.tests.utils as u import pyverbs.device as d from pyverbs.pd import PD import pyverbs.enums as e +import tests.utils as u MAX_IO_LEN = 1048576 diff --git a/pyverbs/tests/pd.py b/tests/test_pd.py similarity index 97% rename from pyverbs/tests/pd.py rename to tests/test_pd.py index 87528db7d437..978cf4900146 100644 --- a/pyverbs/tests/pd.py +++ b/tests/test_pd.py @@ -5,7 +5,7 @@ Test module for pyverbs' pd module. """ import random -from pyverbs.tests.base import PyverbsAPITestCase +from tests.base import PyverbsAPITestCase from pyverbs.base import PyverbsRDMAErrno import pyverbs.device as d from pyverbs.pd import PD diff --git a/pyverbs/tests/qp.py b/tests/test_qp.py similarity index 99% rename from pyverbs/tests/qp.py rename to tests/test_qp.py index bbf28244f641..1ce98388871b 100644 --- a/pyverbs/tests/qp.py +++ b/tests/test_qp.py @@ -5,12 +5,12 @@ Test module for pyverbs' qp module. """ import random -from pyverbs.tests.base import PyverbsAPITestCase from pyverbs.qp import QPInitAttr, QPAttr, QP -import pyverbs.tests.utils as u +from tests.base import PyverbsAPITestCase import pyverbs.enums as e from pyverbs.pd import PD from pyverbs.cq import CQ +import tests.utils as u class QPTest(PyverbsAPITestCase): diff --git a/pyverbs/tests/utils.py b/tests/utils.py similarity index 100% rename from pyverbs/tests/utils.py rename to tests/utils.py From patchwork Mon Aug 19 06:58:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noa Osherovich X-Patchwork-Id: 11100357 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 021DE112C for ; Mon, 19 Aug 2019 06:58:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6A8028590 for ; Mon, 19 Aug 2019 06:58:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB8E2285A0; Mon, 19 Aug 2019 06:58:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D18C285AB for ; Mon, 19 Aug 2019 06:58:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726553AbfHSG6f (ORCPT ); Mon, 19 Aug 2019 02:58:35 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:53158 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726541AbfHSG6e (ORCPT ); Mon, 19 Aug 2019 02:58:34 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from noaos@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Aug 2019 09:58:30 +0300 Received: from reg-l-vrt-059-007.mtl.labs.mlnx (reg-l-vrt-059-007.mtl.labs.mlnx [10.135.59.7]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7J6wUNF004602; Mon, 19 Aug 2019 09:58:30 +0300 From: Noa Osherovich To: dledford@redhat.com, jgg@mellanox.com, leonro@mellanox.com Cc: linux-rdma@vger.kernel.org, Noa Osherovich Subject: [PATCH rdma-core 03/14] build: Add pyverbs-based test to the build Date: Mon, 19 Aug 2019 09:58:16 +0300 Message-Id: <20190819065827.26921-4-noaos@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819065827.26921-1-noaos@mellanox.com> References: <20190819065827.26921-1-noaos@mellanox.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Have the tests installed separately from pyverbs as they're not a part of the package. They will now be placed under /usr/share/doc/rdma-core-{version}/tests. The tests can be executed as follows: python3 /usr/share/doc/rdma-core-{version}/run_tests.py Signed-off-by: Noa Osherovich --- CMakeLists.txt | 11 +++++++++++ buildlib/pyverbs_functions.cmake | 7 +++++++ debian/python3-pyverbs.install | 2 ++ pyverbs/CMakeLists.txt | 17 ----------------- redhat/rdma-core.spec | 2 ++ pyverbs/run_tests.py => run_tests.py | 0 suse/rdma-core.spec | 2 ++ 7 files changed, 24 insertions(+), 17 deletions(-) rename pyverbs/run_tests.py => run_tests.py (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc17ef36cf24..d076ab2c9d3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -648,6 +648,7 @@ add_subdirectory(infiniband-diags/man) if (CYTHON_EXECUTABLE) add_subdirectory(pyverbs) + add_subdirectory(tests) endif() # Binaries @@ -666,6 +667,16 @@ if (UDEV_FOUND) endif() add_subdirectory(srp_daemon) +if (CYTHON_EXECUTABLE) +rdma_python_test("" + run_tests.py + ) + +rdma_internal_binary( + run_tests.py + ) +endif() + ibverbs_finalize() rdma_finalize_libs() diff --git a/buildlib/pyverbs_functions.cmake b/buildlib/pyverbs_functions.cmake index 9d5258617035..8ea5dc0df7de 100644 --- a/buildlib/pyverbs_functions.cmake +++ b/buildlib/pyverbs_functions.cmake @@ -35,6 +35,13 @@ function(rdma_python_module PY_MODULE) endforeach() endfunction() +function(rdma_python_test PY_MODULE) + foreach(PY_FILE ${ARGN}) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PY_FILE} + DESTINATION ${CMAKE_INSTALL_DOCDIR}/${PY_MODULE}) + endforeach() +endfunction() + # Make a python script runnable from the build/bin directory with all the # correct paths filled in function(rdma_internal_binary) diff --git a/debian/python3-pyverbs.install b/debian/python3-pyverbs.install index 20130d8a9a03..10efb97232fd 100644 --- a/debian/python3-pyverbs.install +++ b/debian/python3-pyverbs.install @@ -1 +1,3 @@ usr/lib/python3/dist-packages/pyverbs +usr/share/doc/rdma-core/run_tests.py +usr/share/doc/rdma-core/tests diff --git a/pyverbs/CMakeLists.txt b/pyverbs/CMakeLists.txt index 328263fcc739..da49093c2cf0 100644 --- a/pyverbs/CMakeLists.txt +++ b/pyverbs/CMakeLists.txt @@ -16,22 +16,5 @@ rdma_cython_module(pyverbs rdma_python_module(pyverbs __init__.py pyverbs_error.py - run_tests.py utils.py ) - -rdma_python_module(pyverbs/tests - tests/__init__.py - tests/addr.py - tests/base.py - tests/cq.py - tests/device.py - tests/mr.py - tests/pd.py - tests/qp.py - tests/utils.py - ) - -rdma_internal_binary( - run_tests.py - ) diff --git a/redhat/rdma-core.spec b/redhat/rdma-core.spec index f07919ccecd5..239c56b581e8 100644 --- a/redhat/rdma-core.spec +++ b/redhat/rdma-core.spec @@ -650,4 +650,6 @@ rm -rf %{buildroot}/%{_sbindir}/srp_daemon.sh %if %{with_pyverbs} %files -n python3-pyverbs %{python3_sitearch}/pyverbs +%{_docdir}/%{name}-%{version}/tests/*.py +%{_docdir}/%{name}-%{version}/run_tests.py %endif diff --git a/pyverbs/run_tests.py b/run_tests.py similarity index 100% rename from pyverbs/run_tests.py rename to run_tests.py diff --git a/suse/rdma-core.spec b/suse/rdma-core.spec index 5a01327c4852..cdb6793e4f75 100644 --- a/suse/rdma-core.spec +++ b/suse/rdma-core.spec @@ -852,6 +852,8 @@ rm -rf %{buildroot}/%{_sbindir}/srp_daemon.sh %if %{with_pyverbs} %files -n python3-pyverbs %{python3_sitearch}/pyverbs +%{_docdir}/%{name}-%{version}/tests/*.py +%{_docdir}/%{name}-%{version}/run_tests.py %endif %changelog From patchwork Mon Aug 19 06:58:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noa Osherovich X-Patchwork-Id: 11100339 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB85C174A for ; Mon, 19 Aug 2019 06:58:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBB8D285B9 for ; Mon, 19 Aug 2019 06:58:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0382285B8; Mon, 19 Aug 2019 06:58:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AD8E285A0 for ; Mon, 19 Aug 2019 06:58:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726550AbfHSG6f (ORCPT ); Mon, 19 Aug 2019 02:58:35 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:53156 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726736AbfHSG6e (ORCPT ); Mon, 19 Aug 2019 02:58:34 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from noaos@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Aug 2019 09:58:30 +0300 Received: from reg-l-vrt-059-007.mtl.labs.mlnx (reg-l-vrt-059-007.mtl.labs.mlnx [10.135.59.7]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7J6wUNG004602; Mon, 19 Aug 2019 09:58:30 +0300 From: Noa Osherovich To: dledford@redhat.com, jgg@mellanox.com, leonro@mellanox.com Cc: linux-rdma@vger.kernel.org, Maxim Chicherin Subject: [PATCH rdma-core 04/14] tests: BaseResources Class Date: Mon, 19 Aug 2019 09:58:17 +0300 Message-Id: <20190819065827.26921-5-noaos@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819065827.26921-1-noaos@mellanox.com> References: <20190819065827.26921-1-noaos@mellanox.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Maxim Chicherin Base aggregator object which contains basic resources like Context and PD. Signed-off-by: Maxim Chicherin --- tests/base.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/base.py b/tests/base.py index a1eae2becdc0..88f00e07b326 100644 --- a/tests/base.py +++ b/tests/base.py @@ -3,7 +3,10 @@ import unittest +from pyverbs.device import Context import pyverbs.device as d +from pyverbs.pd import PD + class PyverbsAPITestCase(unittest.TestCase): def setUp(self): @@ -21,3 +24,22 @@ class PyverbsAPITestCase(unittest.TestCase): def tearDown(self): for tup in self.devices: tup[0].close() + + +class BaseResources(object): + """ + BaseResources class is a base aggregator object which contains basic + resources like Context and PD. It opens a context over the given device + and port and allocates a PD. + """ + def __init__(self, dev_name, ib_port, gid_index): + """ + Initializes a BaseResources object. + :param dev_name: Device name to be used (default: 'ibp0s8f0') + :param ib_port: IB port of the device to use (default: 1) + :param gid_index: Which GID index to use (default: 0) + """ + self.ctx = Context(name=dev_name) + self.gid_index = gid_index + self.pd = PD(self.ctx) + self.ib_port = ib_port From patchwork Mon Aug 19 06:58:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noa Osherovich X-Patchwork-Id: 11100365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 68D6F174A for ; Mon, 19 Aug 2019 06:58:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5487A28560 for ; Mon, 19 Aug 2019 06:58:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48F7928590; Mon, 19 Aug 2019 06:58:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9547285A0 for ; Mon, 19 Aug 2019 06:58:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726390AbfHSG6j (ORCPT ); Mon, 19 Aug 2019 02:58:39 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:53155 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726812AbfHSG6f (ORCPT ); Mon, 19 Aug 2019 02:58:35 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from noaos@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Aug 2019 09:58:31 +0300 Received: from reg-l-vrt-059-007.mtl.labs.mlnx (reg-l-vrt-059-007.mtl.labs.mlnx [10.135.59.7]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7J6wUNH004602; Mon, 19 Aug 2019 09:58:30 +0300 From: Noa Osherovich To: dledford@redhat.com, jgg@mellanox.com, leonro@mellanox.com Cc: linux-rdma@vger.kernel.org, Maxim Chicherin , Noa Osherovich Subject: [PATCH rdma-core 05/14] tests: RDMATestCase Date: Mon, 19 Aug 2019 09:58:18 +0300 Message-Id: <20190819065827.26921-6-noaos@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819065827.26921-1-noaos@mellanox.com> References: <20190819065827.26921-1-noaos@mellanox.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Maxim Chicherin Base class for future tests which allows user-set parameters: device name, IB port, GID index and PKey index can be provided to the tests. If not, they're selected at random. Signed-off-by: Maxim Chicherin Signed-off-by: Noa Osherovich --- tests/base.py | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/tests/base.py b/tests/base.py index 88f00e07b326..e141b83dea0e 100644 --- a/tests/base.py +++ b/tests/base.py @@ -2,9 +2,11 @@ # Copyright (c) 2019 Mellanox Technologies, Inc . All rights reserved. See COPYING file import unittest +import random from pyverbs.device import Context import pyverbs.device as d +import pyverbs.enums as e from pyverbs.pd import PD @@ -26,6 +28,105 @@ class PyverbsAPITestCase(unittest.TestCase): tup[0].close() +class RDMATestCase(unittest.TestCase): + """ + A base class for test cases which provides the option for user parameters. + These can be provided by manually adding the test case to the runner: + suite = unittest.TestSuite() + ... # Regular auto-detection of test cases, no parameters used. + # Now follows your manual addition of test cases e.g: + suite.addTest(RDMATestCase.parametrize(, dev_name='..', + ib_port=1, gid_index=3, + pkey_index=42)) + """ + ZERO_GID = '0000:0000:0000:0000' + + def __init__(self, methodName='runTest', dev_name=None, ib_port=None, + gid_index=None, pkey_index=None): + super(RDMATestCase, self).__init__(methodName) + self.dev_name = dev_name + self.ib_port = ib_port + self.gid_index = gid_index + self.pkey_index = pkey_index + + @staticmethod + def parametrize(testcase_klass, dev_name=None, ib_port=None, gid_index=None, + pkey_index=None): + """ + Create a test suite containing all the tests from the given subclass + with the given dev_name, port, gid index and pkey_index. + """ + loader = unittest.TestLoader() + names = loader.getTestCaseNames(testcase_klass) + suite = unittest.TestSuite() + for n in names: + suite.addTest(testcase_klass(n, dev_name=dev_name, ib_port=ib_port, + gid_index=gid_index, + pkey_index=pkey_index)) + return suite + + def setUp(self): + """ + Verify that the test case has dev_name, ib_port, gid_index and pkey index. + If not provided by the user, a random valid combination will be used. + """ + if self.pkey_index is None: + # To avoid iterating the entire pkeys table, if a pkey index wasn't + # provided, use index 0 which is always valid + self.pkey_index = 0 + + self.args = [] + if self.dev_name is not None: + ctx = d.Context(name=self.dev_name) + if self.ib_port is not None: + if self.gid_index is not None: + # We have all we need, return + return + else: + # Add avaiable GIDs of the given dev_name + port + self._add_gids_per_port(ctx, self.dev_name, self.ib_port) + else: + # Add available GIDs for each port of the given dev_name + self._add_gids_per_device(ctx, self.dev_name) + else: + # Iterate available devices, add available GIDs for each of + # their ports + lst = d.get_device_list() + for dev in lst: + dev_name = dev.name.decode() + ctx = d.Context(name=dev_name) + self._add_gids_per_device(ctx, dev_name) + + if not self.args: + raise unittest.SkipTest('No dev/port/GID combinations, please check your setup and try again') + # Choose one combination and use it + args = random.choice(self.args) + self.dev_name = args[0] + self.ib_port = args[1] + self.gid_index = args[2] + + def _add_gids_per_port(self, ctx, dev, port): + idx = 0 + ll = ctx.query_port(port).link_layer + while True: + gid = ctx.query_gid(port, idx) + if gid.gid[-19:] == self.ZERO_GID: + # No point iterating on + break + if ll == e.IBV_LINK_LAYER_ETHERNET and gid.gid[0:4] == 'fe80': + # Use only IPv4/IPv6 GIDs + idx += 1 + continue + else: + self.args.append([dev, port, idx]) + idx += 1 + + def _add_gids_per_device(self, ctx, dev): + port_count = ctx.query_device().phys_port_cnt + for port in range(port_count): + self._add_gids_per_port(ctx, dev, port+1) + + class BaseResources(object): """ BaseResources class is a base aggregator object which contains basic From patchwork Mon Aug 19 06:58:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noa Osherovich X-Patchwork-Id: 11100345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5DCA818EC for ; Mon, 19 Aug 2019 06:58:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CEF628590 for ; Mon, 19 Aug 2019 06:58:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B3C4285AB; Mon, 19 Aug 2019 06:58:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3841285B0 for ; Mon, 19 Aug 2019 06:58:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726808AbfHSG6f (ORCPT ); Mon, 19 Aug 2019 02:58:35 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:53153 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726550AbfHSG6e (ORCPT ); Mon, 19 Aug 2019 02:58:34 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from noaos@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Aug 2019 09:58:31 +0300 Received: from reg-l-vrt-059-007.mtl.labs.mlnx (reg-l-vrt-059-007.mtl.labs.mlnx [10.135.59.7]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7J6wUNI004602; Mon, 19 Aug 2019 09:58:30 +0300 From: Noa Osherovich To: dledford@redhat.com, jgg@mellanox.com, leonro@mellanox.com Cc: linux-rdma@vger.kernel.org, Noa Osherovich , Maxim Chicherin Subject: [PATCH rdma-core 06/14] tests: TrafficResources class Date: Mon, 19 Aug 2019 09:58:19 +0300 Message-Id: <20190819065827.26921-7-noaos@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819065827.26921-1-noaos@mellanox.com> References: <20190819065827.26921-1-noaos@mellanox.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Basic traffic aggregation object which contains MR, CQ and QP. It also provides common control path functions to create these objects. Signed-off-by: Maxim Chicherin Signed-off-by: Noa Osherovich --- tests/base.py | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/utils.py | 20 ++++++++++++ 2 files changed, 105 insertions(+) diff --git a/tests/base.py b/tests/base.py index e141b83dea0e..54ebac27d522 100644 --- a/tests/base.py +++ b/tests/base.py @@ -4,10 +4,15 @@ import unittest import random +from pyverbs.pyverbs_error import PyverbsError, PyverbsRDMAError +from pyverbs.qp import QPCap, QPInitAttr, QPAttr, QP +from tests.utils import wc_status_to_str from pyverbs.device import Context import pyverbs.device as d import pyverbs.enums as e from pyverbs.pd import PD +from pyverbs.cq import CQ +from pyverbs.mr import MR class PyverbsAPITestCase(unittest.TestCase): @@ -144,3 +149,83 @@ class BaseResources(object): self.gid_index = gid_index self.pd = PD(self.ctx) self.ib_port = ib_port + + +class TrafficResources(BaseResources): + """ + Basic traffic class. It provides the basic RDMA resources and operations + needed for traffic. + """ + def __init__(self, dev_name, ib_port, gid_index): + """ + Initializes a TrafficResources object with the given values and creates + basic RDMA resources. + :param dev_name: Device name to be used + :param ib_port: IB port of the device to use + :param gid_index: Which GID index to use + """ + super(TrafficResources, self).__init__(dev_name=dev_name, + ib_port=ib_port, + gid_index=gid_index) + self.psn = random.getrandbits(24) + self.msg_size = 1024 + self.num_msgs = 1000 + self.port_attr = None + self.mr = None + self.cq = None + self.qp = None + self.rqpn = 0 + self.rpsn = 0 + self.init_resources() + + @property + def qpn(self): + return self.qp.qp_num + + def init_resources(self): + """ + Initializes a CQ, MR and an RC QP. + :return: None + """ + self.port_attr = self.ctx.query_port(self.ib_port) + self.create_cq() + self.create_mr() + self.create_qp() + + def create_cq(self): + """ + Initializes self.cq with a CQ of depth - defined by each + test. + :return: None + """ + self.cq = CQ(self.ctx, self.num_msgs, None, None, 0) + + def create_mr(self): + """ + Initializes self.mr with an MR of length - defined by each + test. + :return: None + """ + self.mr = MR(self.pd, self.msg_size, e.IBV_ACCESS_LOCAL_WRITE) + + def create_qp(self): + """ + Initializes self.qp with an RC QP. + :return: None + """ + qp_caps = QPCap(max_recv_wr=self.num_msgs) + qp_init_attr = QPInitAttr(qp_type=e.IBV_QPT_RC, scq=self.cq, + rcq=self.cq, cap=qp_caps) + qp_attr = QPAttr(port_num=self.ib_port) + self.qp = QP(self.pd, qp_init_attr, qp_attr) + + def pre_run(self, rpsn, rqpn): + """ + Modify the QP's state to RTS and fill receive queue with work + requests. + This method is not implemented in this class. + :param rpsn: Remote PSN + :param rqpn: Remote QPN + :return: None + """ + raise NotImplementedError() diff --git a/tests/utils.py b/tests/utils.py index c84865a10a40..30166f41d555 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -221,3 +221,23 @@ def random_qp_init_attr_ex(attr_ex, attr, qpt=None): qia = QPInitAttrEx(qp_type=qpt, cap=qp_cap, sq_sig_all=sig, comp_mask=mask, create_flags=cflags, max_tso_header=max_tso) return qia + + +def wc_status_to_str(status): + try: + return \ + {0: 'Success', 1: 'Local length error', + 2: 'local QP operation error', 3: 'Local EEC operation error', + 4: 'Local protection error', 5: 'WR flush error', + 6: 'Memory window bind error', 7: 'Bad response error', + 8: 'Local access error', 9: 'Remote invalidate request error', + 10: 'Remote access error', 11: 'Remote operation error', + 12: 'Retry exceeded', 13: 'RNR retry exceeded', + 14: 'Local RDD violation error', + 15: 'Remote invalidate RD request error', + 16: 'Remote aort error', 17: 'Invalidate EECN error', + 18: 'Invalidate EEC state error', 19: 'Fatal error', + 20: 'Response timeout error', 21: 'General error'}[status] + except KeyError: + return 'Unknown WC status ({s})'.format(s=status) + From patchwork Mon Aug 19 06:58:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noa Osherovich X-Patchwork-Id: 11100349 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B0D46112C for ; Mon, 19 Aug 2019 06:58:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E7D928560 for ; Mon, 19 Aug 2019 06:58:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92640285A7; Mon, 19 Aug 2019 06:58:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC59A28560 for ; Mon, 19 Aug 2019 06:58:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726817AbfHSG6f (ORCPT ); Mon, 19 Aug 2019 02:58:35 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:53154 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726810AbfHSG6e (ORCPT ); Mon, 19 Aug 2019 02:58:34 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from noaos@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Aug 2019 09:58:31 +0300 Received: from reg-l-vrt-059-007.mtl.labs.mlnx (reg-l-vrt-059-007.mtl.labs.mlnx [10.135.59.7]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7J6wUNJ004602; Mon, 19 Aug 2019 09:58:31 +0300 From: Noa Osherovich To: dledford@redhat.com, jgg@mellanox.com, leonro@mellanox.com Cc: linux-rdma@vger.kernel.org, Maxim Chicherin Subject: [PATCH rdma-core 07/14] tests: RCResources and UDResources classes Date: Mon, 19 Aug 2019 09:58:20 +0300 Message-Id: <20190819065827.26921-8-noaos@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819065827.26921-1-noaos@mellanox.com> References: <20190819065827.26921-1-noaos@mellanox.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Maxim Chicherin Add RC and UD specific aggregation objects. They provide traffic-specific implementations for control path functions such as modify QP. Signed-off-by: Maxim Chicherin --- tests/base.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/tests/base.py b/tests/base.py index 54ebac27d522..a28e9b9dc466 100644 --- a/tests/base.py +++ b/tests/base.py @@ -4,9 +4,8 @@ import unittest import random -from pyverbs.pyverbs_error import PyverbsError, PyverbsRDMAError from pyverbs.qp import QPCap, QPInitAttr, QPAttr, QP -from tests.utils import wc_status_to_str +from pyverbs.addr import AHAttr, GlobalRoute from pyverbs.device import Context import pyverbs.device as d import pyverbs.enums as e @@ -229,3 +228,66 @@ class TrafficResources(BaseResources): :return: None """ raise NotImplementedError() + + +class RCResources(TrafficResources): + PATH_MTU = e.IBV_MTU_1024 + MAX_DEST_RD_ATOMIC = 1 + MAX_RD_ATOMIC = 1 + MIN_RNR_TIMER =12 + RETRY_CNT = 7 + RNR_RETRY = 7 + TIMEOUT = 14 + + def to_rts(self, rpsn, rqpn): + """ + Set the QP attributes' values to arbitrary values (same values used in + ibv_rc_pingpong). + :param rpsn: Remote PSN (packet serial number) + :param rqpn: Remote QP number + :return: None + """ + attr = QPAttr(port_num=self.ib_port) + attr.dest_qp_num = rqpn + attr.path_mtu = self.PATH_MTU + attr.max_dest_rd_atomic = self.MAX_DEST_RD_ATOMIC + attr.min_rnr_timer = self.MIN_RNR_TIMER + attr.rq_psn = rpsn + attr.sq_psn = self.psn + attr.timeout = self.TIMEOUT + attr.retry_cnt = self.RETRY_CNT + attr.rnr_retry = self.RNR_RETRY + attr.max_rd_atomic = self.MAX_RD_ATOMIC + gr = GlobalRoute(dgid=self.ctx.query_gid(self.ib_port, self.gid_index), + sgid_index=self.gid_index) + ah_attr = AHAttr(port_num=self.ib_port, is_global=1, gr=gr, + dlid=self.port_attr.lid) + attr.ah_attr = ah_attr + self.qp.to_rts(attr) + + def pre_run(self, rpsn, rqpn): + self.rqpn = rqpn + self.rpsn = rpsn + self.to_rts(rpsn, rqpn) + + +class UDResources(TrafficResources): + UD_QKEY = 0x11111111 + UD_PKEY_INDEX = 0 + + def create_mr(self): + self.mr = MR(self.pd, self.msg_size + self.GRH_SIZE, + e.IBV_ACCESS_LOCAL_WRITE) + + def create_qp(self): + qp_caps = QPCap(max_recv_wr=self.num_msgs) + qp_init_attr = QPInitAttr(qp_type=e.IBV_QPT_UD, cap=qp_caps, + scq=self.cq, rcq=self.cq) + qp_attr = QPAttr(port_num=self.ib_port) + qp_attr.qkey = self.UD_QKEY + qp_attr.pkey_index = self.UD_PKEY_INDEX + self.qp = QP(self.pd, qp_init_attr, qp_attr) + + def pre_run(self, rpsn, rqpn): + self.rqpn = rqpn + self.rpsn = rpsn \ No newline at end of file From patchwork Mon Aug 19 06:58:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noa Osherovich X-Patchwork-Id: 11100361 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 929F0174A for ; Mon, 19 Aug 2019 06:58:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8206D28590 for ; Mon, 19 Aug 2019 06:58:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 768D8285A0; Mon, 19 Aug 2019 06:58:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 251FA285A8 for ; Mon, 19 Aug 2019 06:58:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726464AbfHSG6f (ORCPT ); Mon, 19 Aug 2019 02:58:35 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:53162 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726553AbfHSG6e (ORCPT ); Mon, 19 Aug 2019 02:58:34 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from noaos@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Aug 2019 09:58:31 +0300 Received: from reg-l-vrt-059-007.mtl.labs.mlnx (reg-l-vrt-059-007.mtl.labs.mlnx [10.135.59.7]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7J6wUNK004602; Mon, 19 Aug 2019 09:58:31 +0300 From: Noa Osherovich To: dledford@redhat.com, jgg@mellanox.com, leonro@mellanox.com Cc: linux-rdma@vger.kernel.org, Maxim Chicherin Subject: [PATCH rdma-core 08/14] tests: ODP requires decorator Date: Mon, 19 Aug 2019 09:58:21 +0300 Message-Id: <20190819065827.26921-9-noaos@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819065827.26921-1-noaos@mellanox.com> References: <20190819065827.26921-1-noaos@mellanox.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Maxim Chicherin Add a 'requires_odp' decorator, to be used when registering an MR with ON_DEMAND access flag. Signed-off-by: Maxim Chicherin --- tests/utils.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/utils.py b/tests/utils.py index 30166f41d555..20a7e8d38e54 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -5,6 +5,7 @@ Provide some useful helper function for pyverbs' tests. """ from itertools import combinations as com from string import ascii_lowercase as al +import unittest import random from pyverbs.qp import QPCap, QPInitAttrEx @@ -241,3 +242,32 @@ def wc_status_to_str(status): except KeyError: return 'Unknown WC status ({s})'.format(s=status) + +# Decorators + +def requires_odp(qp_type): + def outer(func): + def inner(instance): + odp_supported(instance.ctx, qp_type) + return func(instance) + return inner + return outer + + +def odp_supported(ctx, qp_type): + """ + Check device ODP capabilities, support only send/recv so far. + :param ctx: Device Context + :param qp_type: QP type ('rc', 'ud' or 'uc') + :return: None + """ + odp_caps = ctx.query_device_ex().odp_caps + if odp_caps.general_caps == 0: + raise unittest.SkipTest('ODP is not supported - No ODP caps') + qp_odp_caps = getattr(odp_caps, '{}_odp_caps'.format(qp_type)) + has_odp_send = qp_odp_caps & e.IBV_ODP_SUPPORT_SEND + has_odp_recv = qp_odp_caps & e.IBV_ODP_SUPPORT_RECV + if has_odp_send == 0: + raise unittest.SkipTest('ODP is not supported - ODP send not supported') + if has_odp_recv == 0: + raise unittest.SkipTest('ODP is not supported - ODP recv not supported') From patchwork Mon Aug 19 06:58:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noa Osherovich X-Patchwork-Id: 11100353 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2AD21174A for ; Mon, 19 Aug 2019 06:58:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18EF628560 for ; Mon, 19 Aug 2019 06:58:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D721285A7; Mon, 19 Aug 2019 06:58:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7778E28590 for ; Mon, 19 Aug 2019 06:58:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726814AbfHSG6h (ORCPT ); Mon, 19 Aug 2019 02:58:37 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:53163 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725872AbfHSG6f (ORCPT ); Mon, 19 Aug 2019 02:58:35 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from noaos@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Aug 2019 09:58:31 +0300 Received: from reg-l-vrt-059-007.mtl.labs.mlnx (reg-l-vrt-059-007.mtl.labs.mlnx [10.135.59.7]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7J6wUNL004602; Mon, 19 Aug 2019 09:58:31 +0300 From: Noa Osherovich To: dledford@redhat.com, jgg@mellanox.com, leonro@mellanox.com Cc: linux-rdma@vger.kernel.org, Maxim Chicherin Subject: [PATCH rdma-core 09/14] tests: Add traffic helper methods Date: Mon, 19 Aug 2019 09:58:22 +0300 Message-Id: <20190819065827.26921-10-noaos@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819065827.26921-1-noaos@mellanox.com> References: <20190819065827.26921-1-noaos@mellanox.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Maxim Chicherin This patch adds common methods needed for data path such as creation of send/recv work requests, post_send/recv wrappers etc. Signed-off-by: Maxim Chicherin --- tests/utils.py | 151 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 150 insertions(+), 1 deletion(-) diff --git a/tests/utils.py b/tests/utils.py index 20a7e8d38e54..881ce4d03634 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -8,6 +8,9 @@ from string import ascii_lowercase as al import unittest import random +from pyverbs.pyverbs_error import PyverbsError, PyverbsRDMAError +from pyverbs.addr import AHAttr, AH, GlobalRoute +from pyverbs.wr import SGE, SendWR, RecvWR from pyverbs.qp import QPCap, QPInitAttrEx import pyverbs.device as d import pyverbs.enums as e @@ -23,6 +26,7 @@ MIN_DM_LOG_ALIGN = 0 MAX_DM_LOG_ALIGN = 6 # Raw Packet QP supports TSO header, which creates a larger send WQE. MAX_RAW_PACKET_SEND_WR = 2500 +GRH_SIZE = 40 def get_mr_length(): @@ -242,9 +246,154 @@ def wc_status_to_str(status): except KeyError: return 'Unknown WC status ({s})'.format(s=status) +# Traffic helpers + +def get_send_wr(agr_obj, is_server): + """ + Creates a single SGE Send WR for agr_obj's QP type. The content of the + message is either 's' for server side or 'c' for client side. + :param agr_obj: Aggregation object which contains all resources necessary + :param is_server: Indicates whether this is server or client side + :return: send wr + """ + qp_type = agr_obj.qp.qp_type + mr = agr_obj.mr + if qp_type == e.IBV_QPT_UD: + send_sge = SGE(mr.buf + GRH_SIZE, agr_obj.msg_size, mr.lkey) + else: + send_sge = SGE(mr.buf, agr_obj.msg_size, mr.lkey) + msg = agr_obj.msg_size * ('s' if is_server else 'c') + mr.write(msg, agr_obj.msg_size) + return SendWR(num_sge=1, sg=[send_sge]) + + +def get_recv_wr(agr_obj): + """ + Creates a single SGE Recv WR for agr_obj's QP type. + :param agr_obj: Aggregation object which contains all resources necessary + :return: recv wr + """ + qp_type = agr_obj.qp.qp_type + mr = agr_obj.mr + if qp_type == e.IBV_QPT_UD: + recv_sge = SGE(mr.buf, agr_obj.msg_size + GRH_SIZE, mr.lkey) + else: + recv_sge = SGE(mr.buf, agr_obj.msg_size, mr.lkey) + return RecvWR(sg=[recv_sge], num_sge=1) + + +def post_send(agr_obj, send_wr, gid_index, port): + """ + Post a single send WR to the QP. Post_send's second parameter (send bad wr) + is ignored for simplicity. For UD traffic an address vector is added as + well. + :param agr_obj: aggregation object which contains all resources necessary + :param send_wr: Send work request to post send + :param gid_index: Local gid index + :param port: IB port number + :return: None + """ + qp_type = agr_obj.qp.qp_type + if qp_type == e.IBV_QPT_UD: + gr = GlobalRoute(dgid=agr_obj.ctx.query_gid(port, gid_index), + sgid_index=gid_index) + ah_attr = AHAttr(port_num=port, is_global=1, gr=gr, + dlid=agr_obj.port_attr.lid) + ah = AH(agr_obj.pd, attr=ah_attr) + send_wr.set_wr_ud(ah, agr_obj.rqpn, agr_obj.UD_QKEY) + agr_obj.qp.post_send(send_wr, None) + + +def post_recv(qp, recv_wr, num_wqes=1): + """ + Call the QP's post_recv() method times. Post_recv's second + parameter (recv bad wr) is ignored for simplicity. + :param qp: QP which posts receive work request + :param recv_wr: Receive work request to post + :param num_wqes: Number of WQEs to post + :return: None + """ + for _ in range(num_wqes): + qp.post_recv(recv_wr, None) -# Decorators +def poll_cq(cq, count=1): + """ + Poll completions from the CQ. + Note: This function calls the blocking poll() method of the CQ + until completions were received. Alternatively, gets a + single CQ event when events are used. + :param cq: CQ to poll from + :param count: How many completions to poll + :return: An array of work completions of length , None + when events are used + """ + wcs = None + while count > 0: + nc, wcs = cq.poll(count) + for wc in wcs: + if wc.status != e.IBV_WC_SUCCESS: + raise PyverbsRDMAError('Completion status is {s}'. + format(s=wc_status_to_str(wc.status))) + count -= nc + return wcs + + +def validate(received_str, is_server, msg_size): + """ + Validates the received buffer against the expected result. + The application should set client's send buffer to 'c's and the + server's send buffer to 's's. + If the expected buffer is different than the actual, an exception will + be raised. + :param received_str: The received buffer to check + :param is_server: Indicates whether this is the server (receiver) or + client side + :param msg_size: the message size of the received packet + :return: None + """ + expected_str = msg_size * ('c' if is_server else 's') + received_str = received_str.decode() + if received_str[0:msg_size] == \ + expected_str[0:msg_size]: + return + else: + raise PyverbsError( + 'Data validation failure: expected {exp}, received {rcv}'. + format(exp=expected_str, rcv=received_str)) + + +def traffic(client, server, iters, gid_idx, port): + """ + Runs basic traffic between two sides + :param client: client side, clients base class is BaseTraffic + :param server: server side, servers base class is BaseTraffic + :param iters: number of traffic iterations + :param gid_idx: local gid index + :param port: IB port + :return: + """ + s_recv_wr = get_recv_wr(server) + c_recv_wr = get_recv_wr(client) + post_recv(client.qp, c_recv_wr, client.num_msgs) + post_recv(server.qp, s_recv_wr, server.num_msgs) + for _ in range(iters): + c_send_wr = get_send_wr(client, False) + post_send(client, c_send_wr, gid_idx, port) + poll_cq(client.cq) + poll_cq(server.cq) + post_recv(client.qp, c_recv_wr) + msg_received = server.mr.read(server.msg_size, 0) + validate(msg_received, True, server.msg_size) + s_send_wr = get_send_wr(server, True) + post_send(server, s_send_wr, gid_idx, port) + poll_cq(server.cq) + poll_cq(client.cq) + post_recv(server.qp, s_recv_wr) + msg_received = client.mr.read(client.msg_size, 0) + validate(msg_received, False, client.msg_size) + +# Decorators def requires_odp(qp_type): def outer(func): def inner(instance): From patchwork Mon Aug 19 06:58:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noa Osherovich X-Patchwork-Id: 11100341 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BC2E17E2 for ; Mon, 19 Aug 2019 06:58:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0EDD285A0 for ; Mon, 19 Aug 2019 06:58:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DEE28285B8; Mon, 19 Aug 2019 06:58:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76DC8285A7 for ; Mon, 19 Aug 2019 06:58:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726736AbfHSG6f (ORCPT ); Mon, 19 Aug 2019 02:58:35 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:53173 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725958AbfHSG6e (ORCPT ); Mon, 19 Aug 2019 02:58:34 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from noaos@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Aug 2019 09:58:31 +0300 Received: from reg-l-vrt-059-007.mtl.labs.mlnx (reg-l-vrt-059-007.mtl.labs.mlnx [10.135.59.7]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7J6wUNM004602; Mon, 19 Aug 2019 09:58:31 +0300 From: Noa Osherovich To: dledford@redhat.com, jgg@mellanox.com, leonro@mellanox.com Cc: linux-rdma@vger.kernel.org, Maxim Chicherin , Noa Osherovich Subject: [PATCH rdma-core 10/14] tests: Add ODP RC test Date: Mon, 19 Aug 2019 09:58:23 +0300 Message-Id: <20190819065827.26921-11-noaos@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819065827.26921-1-noaos@mellanox.com> References: <20190819065827.26921-1-noaos@mellanox.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Maxim Chicherin Add a TestCase for ODP/RC traffic. Signed-off-by: Maxim Chicherin Signed-off-by: Noa Osherovich --- tests/CMakeLists.txt | 1 + tests/test_odp.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/test_odp.py diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f1ba542fab90..6f3c23cd1ec0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -10,5 +10,6 @@ rdma_python_test(tests test_mr.py test_pd.py test_qp.py + test_odp.py utils.py ) diff --git a/tests/test_odp.py b/tests/test_odp.py new file mode 100644 index 000000000000..a9f3bf4573a5 --- /dev/null +++ b/tests/test_odp.py @@ -0,0 +1,30 @@ +from tests.base import RDMATestCase +from tests.utils import requires_odp, traffic +from tests.base import RCResources +from pyverbs.mr import MR +import pyverbs.enums as e + + +class OdpRC(RCResources): + @requires_odp('rc') + def create_mr(self): + self.mr = MR(self.pd, self.msg_size, + e.IBV_ACCESS_LOCAL_WRITE | e.IBV_ACCESS_ON_DEMAND) + + +class OdpTestCase(RDMATestCase): + def setUp(self): + super(OdpTestCase, self).setUp() + self.iters = 100 + self.qp_dict = {'rc': OdpRC} + + def create_players(self, qp_type): + client = self.qp_dict[qp_type](self.dev_name, self.ib_port, self.gid_index) + server = self.qp_dict[qp_type](self.dev_name, self.ib_port, self.gid_index) + client.pre_run(server.psn, server.qpn) + server.pre_run(client.psn, client.qpn) + return client, server + + def test_odp_rc_traffic(self): + client, server = self.create_players('rc') + traffic(client, server, self.iters, self.gid_index, self.ib_port) From patchwork Mon Aug 19 06:58:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noa Osherovich X-Patchwork-Id: 11100337 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A8F89112C for ; Mon, 19 Aug 2019 06:58:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97DBE28590 for ; Mon, 19 Aug 2019 06:58:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B3EB285B8; Mon, 19 Aug 2019 06:58:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCC0628590 for ; Mon, 19 Aug 2019 06:58:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726810AbfHSG6f (ORCPT ); Mon, 19 Aug 2019 02:58:35 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:53174 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726464AbfHSG6e (ORCPT ); Mon, 19 Aug 2019 02:58:34 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from noaos@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Aug 2019 09:58:31 +0300 Received: from reg-l-vrt-059-007.mtl.labs.mlnx (reg-l-vrt-059-007.mtl.labs.mlnx [10.135.59.7]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7J6wUNN004602; Mon, 19 Aug 2019 09:58:31 +0300 From: Noa Osherovich To: dledford@redhat.com, jgg@mellanox.com, leonro@mellanox.com Cc: linux-rdma@vger.kernel.org, Maxim Chicherin Subject: [PATCH rdma-core 11/14] tests: Add ODP UD test Date: Mon, 19 Aug 2019 09:58:24 +0300 Message-Id: <20190819065827.26921-12-noaos@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819065827.26921-1-noaos@mellanox.com> References: <20190819065827.26921-1-noaos@mellanox.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Maxim Chicherin Add a TestCase for ODP/UD traffic. Signed-off-by: Maxim Chicherin --- tests/test_odp.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/test_odp.py b/tests/test_odp.py index a9f3bf4573a5..922cd0d9aad5 100644 --- a/tests/test_odp.py +++ b/tests/test_odp.py @@ -1,10 +1,17 @@ from tests.base import RDMATestCase from tests.utils import requires_odp, traffic -from tests.base import RCResources +from tests.base import RCResources, UDResources from pyverbs.mr import MR import pyverbs.enums as e +class OdpUD(UDResources): + @requires_odp('ud') + def create_mr(self): + self.mr = MR(self.pd, self.msg_size + self.GRH_SIZE , + e.IBV_ACCESS_LOCAL_WRITE | e.IBV_ACCESS_ON_DEMAND) + + class OdpRC(RCResources): @requires_odp('rc') def create_mr(self): @@ -16,7 +23,7 @@ class OdpTestCase(RDMATestCase): def setUp(self): super(OdpTestCase, self).setUp() self.iters = 100 - self.qp_dict = {'rc': OdpRC} + self.qp_dict = {'rc': OdpRC, 'ud': OdpUD} def create_players(self, qp_type): client = self.qp_dict[qp_type](self.dev_name, self.ib_port, self.gid_index) @@ -28,3 +35,7 @@ class OdpTestCase(RDMATestCase): def test_odp_rc_traffic(self): client, server = self.create_players('rc') traffic(client, server, self.iters, self.gid_index, self.ib_port) + + def test_odp_ud_traffic(self): + client, server = self.create_players('ud') + traffic(client, server, self.iters, self.gid_index, self.ib_port) From patchwork Mon Aug 19 06:58:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noa Osherovich X-Patchwork-Id: 11100355 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A3BC18EC for ; Mon, 19 Aug 2019 06:58:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A00528560 for ; Mon, 19 Aug 2019 06:58:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E5E228590; Mon, 19 Aug 2019 06:58:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0492E285A0 for ; Mon, 19 Aug 2019 06:58:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726541AbfHSG6f (ORCPT ); Mon, 19 Aug 2019 02:58:35 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:53183 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726808AbfHSG6e (ORCPT ); Mon, 19 Aug 2019 02:58:34 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from noaos@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Aug 2019 09:58:31 +0300 Received: from reg-l-vrt-059-007.mtl.labs.mlnx (reg-l-vrt-059-007.mtl.labs.mlnx [10.135.59.7]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7J6wUNO004602; Mon, 19 Aug 2019 09:58:31 +0300 From: Noa Osherovich To: dledford@redhat.com, jgg@mellanox.com, leonro@mellanox.com Cc: linux-rdma@vger.kernel.org, Noa Osherovich Subject: [PATCH rdma-core 12/14] tests: Fix test locating process Date: Mon, 19 Aug 2019 09:58:25 +0300 Message-Id: <20190819065827.26921-13-noaos@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819065827.26921-1-noaos@mellanox.com> References: <20190819065827.26921-1-noaos@mellanox.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a module-specific load_tests method in __init__.py. It currently locates all existing tests under its directory (files should start with 'test_') and runs them without any parameters. In order to run a test with a specific set of parameters, user can add the relevant lines in __init__.py (example provided in the file). Signed-off-by: Noa Osherovich --- run_tests.py | 20 +++++++------------- tests/__init__.py | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/run_tests.py b/run_tests.py index dbee92d942bd..4f6b212dab9f 100644 --- a/run_tests.py +++ b/run_tests.py @@ -1,22 +1,16 @@ # SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) # Copyright (c) 2018, Mellanox Technologies. All rights reserved. See COPYING file -import unittest,os,os.path,fnmatch -import tests +import unittest + +# Run from /usr/share/doc/rdma-core- def test_all(): - # FIXME: This implementation is for older Python versions, will - # be replaced with discover() - return test_suite + module = __import__('tests') + loader = unittest.TestLoader() + suite = loader.loadTestsFromModule(module) + return suite -module = __import__("tests") -fns = [os.path.splitext(I)[0] for I in fnmatch.filter(os.listdir(module.__path__[0]),"*.py")] -fns.remove("__init__") -for I in fns: - __import__("tests." + I) -test_suite = unittest.TestSuite(unittest.defaultTestLoader.loadTestsFromNames(fns,module)) if __name__ == '__main__': unittest.main(defaultTest="test_all") - - diff --git a/tests/__init__.py b/tests/__init__.py index e69de29bb2d1..7a2efdfb6e6b 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) +# Copyright (c) 2019 Mellanox Technologies, Inc . All rights reserved. See COPYING file + +import unittest + + +def load_tests(loader, standard_tests, pattern): + loader = unittest.TestLoader() + suite = loader.discover('tests') + return suite +# To run only some test cases / parametrized tests: +# 1. Add RDMATestCase to the imports: +# from tests.base import RDMATestCase +# 2. Replace the current TestSuite with a customized one and add tests to it +# (parameters are optional) +# suite = unittest.TestSuite() +# suite.addTest(RDMATestCase.parametrize(YourTestCase, dev_name='rocep0s8f0', ...)) From patchwork Mon Aug 19 06:58:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noa Osherovich X-Patchwork-Id: 11100363 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F301317E2 for ; Mon, 19 Aug 2019 06:58:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E022228560 for ; Mon, 19 Aug 2019 06:58:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D45A1285A7; Mon, 19 Aug 2019 06:58:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44D6228560 for ; Mon, 19 Aug 2019 06:58:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726670AbfHSG6i (ORCPT ); Mon, 19 Aug 2019 02:58:38 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:53184 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726717AbfHSG6f (ORCPT ); Mon, 19 Aug 2019 02:58:35 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from noaos@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Aug 2019 09:58:31 +0300 Received: from reg-l-vrt-059-007.mtl.labs.mlnx (reg-l-vrt-059-007.mtl.labs.mlnx [10.135.59.7]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7J6wUNP004602; Mon, 19 Aug 2019 09:58:31 +0300 From: Noa Osherovich To: dledford@redhat.com, jgg@mellanox.com, leonro@mellanox.com Cc: linux-rdma@vger.kernel.org, Noa Osherovich Subject: [PATCH rdma-core 13/14] Documentation: Add background for rdma-core tests Date: Mon, 19 Aug 2019 09:58:26 +0300 Message-Id: <20190819065827.26921-14-noaos@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819065827.26921-1-noaos@mellanox.com> References: <20190819065827.26921-1-noaos@mellanox.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP testing.md describes the design behind the tests' infrastructure and provides explanations for: - How to run tests. - How to control which tests to run and with which parameters. - How to add tests. Signed-off-by: Noa Osherovich --- Documentation/testing.md | 126 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 Documentation/testing.md diff --git a/Documentation/testing.md b/Documentation/testing.md new file mode 100644 index 000000000000..218dc36be478 --- /dev/null +++ b/Documentation/testing.md @@ -0,0 +1,126 @@ +# Testing in rdma-core + +rdma-core now offers an infrastructure for quick and easy additions of feature- +specific tests. + +## Design +### Resources Management +`BaseResources` class is the basic objects aggregator available. It includes a +Context and a PD. +Inheriting from it is `TrafficResources` class, which also holds a MR, CQ and +QP, making it enough to support loopback traffic testing. It exposes methods for +creation of these objects which can be overridden by inheriting classes. +Inheriting from `TrafficResources` are currently two class: +- `RCResources` +- `UDResources` + +Both add traffic-specific constants. `UDResources` for example overrides +create_mr and adds the size of the GRH header to the message size. `RCResources` +exposes a wrapper to modify the QP to RTS. + +### Tests-related Classes +`unittest.TestCase` is a logical test unit in Python's unittest module. +`RDMATestCase` inherits from it and adds the option to accept parameters +(example will follow below) or use a random set of valid parameters: +- If no device was provided, it iterates over the existing devices, for each + port of each device, it checks which GID indexes are valid (in RoCE, only + IPv4 and IPv6 based GIDs are used). Each is added to an array + and one entry is selected. +- If a device was provided, the same process is done for all ports of this + device, and so on. + +### Traffic Utilities +tests/utils.py offers a few wrappers for common traffic operations, making the +use of default values even shorter. Those traffic utilities accept an +aggregation object as their first parameter and rely on that object to have +valid RDMA resources for proper functioning. +- get_[send, recv]_wr() creates a [Send, Recv]WR object with a single SGE. It + also sets the MR content to be 'c's for client side or 's's for server side + (this is later validated). +- post_send() posts a single send request to the aggregation object's QP. If the + QP is a UD QP, an address vector will be added to the send WR. +- post_recv() posts the given RecvWR times, so it can be used to fill the + RQ prior to traffic as well as during traffic. +- poll_cq() polls completions from the CQ and raises an exception on a + non-success status. +- validate() verifies that the data in the MR is as expected ('c's for server, + 's's for client). +- traffic() runs iterations of send/recv between 2 players. + +## How to run rdma-core's tests +The tests are not a Python package, as such they can be found under +/usr/share/doc/rdma-core-{version}. +In order to run all tests: +``` +cd /usr/share/doc/rdma-core-26.0 +python3 run_tests.py +``` +Output will be something like: +``` +$ python3 run_tests.py +..........................................ss............... +---------------------------------------------------------------------- +Ran 59 tests in 13.268s + +OK (skipped=2) +``` +A dot represents a passing test. 's' means a skipped test. 'E' means a test +that failed. + +Tests can also be executed in verbose mode: +``` +$ python3 run_tests.py -v +test_create_ah (test_addr.AHTest) ... ok +test_create_ah_roce (test_addr.AHTest) ... ok +test_destroy_ah (test_addr.AHTest) ... ok +test_create_comp_channel (test_cq.CCTest) ... ok +< many more lines here> +test_odp_rc_traffic (test_odp.OdpTestCase) ... skipped 'No dev/port/GID combinations, please check your setup and try again' +test_odp_ud_traffic (test_odp.OdpTestCase) ... skipped 'No dev/port/GID combinations, please check your setup and try again' + + +---------------------------------------------------------------------- +Ran 59 tests in 12.857s + +OK (skipped=2) +``` +Verbose mode provides the reason for skipping the test (if one was provided by +the test developer). + +### Customized Execution +tests/__init__.py defines a `load_tests` function that returns a +unittest.TestSuite with the tests that will be executed. +The default implementation collects all test_* methods from all the classes that +inherit from `unittest.TestCase` (or `RDMATestCase`) and located in files under +tests directory which names starts with test_. +Users can replace that and create a suite that contains only a few selected +tests: +``` +suite = unittest.TestSuite() +suite.addTest(RDMATestCase.parametrize(YourTestCase)) +``` +We're using 'parametrize' as it instantiates the TestCase for us. +'parametrize' can accept arguments as well (device name, IB port, GID index and +PKey index): +``` +suite = unittest.TestSuite() +suite.addTest(RDMATestCase.parametrize(YourTestCase, dev_name='devname')) +``` + +## Writing Tests +The following section explains how to add a new test, using tests/test_odp.py +as an example. It's a simple test that runs ping-pong over a few different +traffic types. + +ODP requires capability check, so a decorator was added to tests/utils.py. +The first change for ODP execution is when registering a memory region (need to +set the ON_DEMAND access flag), so we do as follows: +1. Create the players by inheriting from `RCResources` (for RC traffic). +2. In the player, override create_mr() and add the decorator to it. It will run + before the actual call to ibv_reg_mr and if ODP caps are off, the test will + be skipped. + 3. Create the `OdpTestCase` by inheriting from `RDMATestCase`. + 4. In the test case, add a method starting with test_, to let the unittest + infrastructure that this is a test. + 5. In the test method, create the players (which already check the ODP caps) + and call the traffic() function, providing it the two players. From patchwork Mon Aug 19 06:58:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noa Osherovich X-Patchwork-Id: 11100351 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E379017E2 for ; Mon, 19 Aug 2019 06:58:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3A9A28560 for ; Mon, 19 Aug 2019 06:58:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C79BB285A0; Mon, 19 Aug 2019 06:58:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 581A7285C3 for ; Mon, 19 Aug 2019 06:58:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726661AbfHSG6h (ORCPT ); Mon, 19 Aug 2019 02:58:37 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:53190 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726814AbfHSG6g (ORCPT ); Mon, 19 Aug 2019 02:58:36 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from noaos@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Aug 2019 09:58:31 +0300 Received: from reg-l-vrt-059-007.mtl.labs.mlnx (reg-l-vrt-059-007.mtl.labs.mlnx [10.135.59.7]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7J6wUNQ004602; Mon, 19 Aug 2019 09:58:31 +0300 From: Noa Osherovich To: dledford@redhat.com, jgg@mellanox.com, leonro@mellanox.com Cc: linux-rdma@vger.kernel.org, Noa Osherovich Subject: [PATCH rdma-core 14/14] tests: Unify API tests' output Date: Mon, 19 Aug 2019 09:58:27 +0300 Message-Id: <20190819065827.26921-15-noaos@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819065827.26921-1-noaos@mellanox.com> References: <20190819065827.26921-1-noaos@mellanox.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When executed in verbose mode, unittest infrastructure prints a test's docstring if it's in a single line format, which was used in some tests. Change those to use multiline format instead. Signed-off-by: Noa Osherovich --- tests/test_device.py | 6 ++++-- tests/test_mr.py | 36 +++++++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/tests/test_device.py b/tests/test_device.py index e395e793c28f..32dedb34d559 100644 --- a/tests/test_device.py +++ b/tests/test_device.py @@ -120,7 +120,9 @@ class DeviceTest(unittest.TestCase): @staticmethod def test_query_port_bad_flow(): - """ Verify that querying non-existing ports fails as expected """ + """ + Verify that querying non-existing ports fails as expected + """ lst = d.get_device_list() for dev in lst: with d.Context(name=dev.name.decode()) as ctx: @@ -199,7 +201,7 @@ class DMTest(PyverbsAPITestCase): def test_destroy_dm_bad_flow(self): """ - test calling ibv_free_dm() twice + Test calling ibv_free_dm() twice """ for ctx, attr, attr_ex in self.devices: if attr_ex.max_dm_size == 0: diff --git a/tests/test_mr.py b/tests/test_mr.py index e87fb33624ed..d11a4b8f8f26 100644 --- a/tests/test_mr.py +++ b/tests/test_mr.py @@ -32,7 +32,9 @@ class MRTest(PyverbsAPITestCase): pass def test_dereg_mr(self): - """ Test ibv_dereg_mr() """ + """ + Test ibv_dereg_mr() + """ for ctx, attr, attr_ex in self.devices: with PD(ctx) as pd: flags = u.get_access_flags(ctx) @@ -42,7 +44,9 @@ class MRTest(PyverbsAPITestCase): @staticmethod def test_reg_mr_bad_flow(): - """ Verify that trying to register a MR with None PD fails """ + """ + Verify that trying to register a MR with None PD fails + """ try: # Use the simplest access flags necessary MR(None, random.randint(0, 10000), e.IBV_ACCESS_LOCAL_WRITE) @@ -53,7 +57,9 @@ class MRTest(PyverbsAPITestCase): raise PyverbsRDMAErrno('Created a MR with None PD') def test_dereg_mr_twice(self): - """ Verify that explicit call to MR's close() doesn't fails """ + """ + Verify that explicit call to MR's close() doesn't fail + """ for ctx, attr, attr_ex in self.devices: with PD(ctx) as pd: flags = u.get_access_flags(ctx) @@ -65,7 +71,9 @@ class MRTest(PyverbsAPITestCase): mr.close() def test_reg_mr_bad_flags(self): - """ Verify that illegal flags combination fails as expected """ + """ + Verify that illegal flags combination fails as expected + """ for ctx, attr, attr_ex in self.devices: with PD(ctx) as pd: for i in range(5): @@ -159,35 +167,45 @@ class MWTest(PyverbsAPITestCase): Test various functionalities of the MW class. """ def test_reg_mw_type1(self): - """ Test ibv_alloc_mw() """ + """ + Test ibv_alloc_mw() for type 1 MW + """ for ctx, attr, attr_ex in self.devices: with PD(ctx) as pd: with MW(pd, e.IBV_MW_TYPE_1): pass def test_reg_mw_type2(self): - """ Test ibv_alloc_mw() """ + """ + Test ibv_alloc_mw() for type 2 MW + """ for ctx, attr, attr_ex in self.devices: with PD(ctx) as pd: with MW(pd, e.IBV_MW_TYPE_2): pass def test_dereg_mw_type1(self): - """ Test ibv_dealloc_mw() """ + """ + Test ibv_dealloc_mw() for type 1 MW + """ for ctx, attr, attr_ex in self.devices: with PD(ctx) as pd: with MW(pd, e.IBV_MW_TYPE_1) as mw: mw.close() def test_dereg_mw_type2(self): - """ Test ibv_dealloc_mw() """ + """ + Test ibv_dealloc_mw() for type 2 MW + """ for ctx, attr, attr_ex in self.devices: with PD(ctx) as pd: with MW(pd, e.IBV_MW_TYPE_2) as mw: mw.close() def test_reg_mw_wrong_type(self): - """ Test ibv_alloc_mw() """ + """ + Verify that trying to create a MW of a wrong type fails + """ for ctx, attr, attr_ex in self.devices: with PD(ctx) as pd: try: