From patchwork Sun Feb 24 13:06:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noa Osherovich X-Patchwork-Id: 10827941 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 3E1D717E9 for ; Sun, 24 Feb 2019 13:08:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9108B20881 for ; Sun, 24 Feb 2019 13:08:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 848B4212DA; Sun, 24 Feb 2019 13:08:56 +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 278C71FFE5 for ; Sun, 24 Feb 2019 13:08:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728295AbfBXNIy (ORCPT ); Sun, 24 Feb 2019 08:08:54 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:50533 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728059AbfBXNIy (ORCPT ); Sun, 24 Feb 2019 08:08:54 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from noaos@mellanox.com) with ESMTPS (AES256-SHA encrypted); 24 Feb 2019 15:06:49 +0200 Received: from reg-l-vrt-059-009.mtl.labs.mlnx (reg-l-vrt-059-009.mtl.labs.mlnx [10.135.59.9]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x1OD6mfe026210; Sun, 24 Feb 2019 15:06:49 +0200 From: Noa Osherovich To: leonro@mellanox.com, jgg@mellanox.com, dledford@redhat.com Cc: linux-rdma@vger.kernel.org, Noa Osherovich Subject: [PATCH rdma-core 10/19] pyverbs: Add unittests for memory window control path Date: Sun, 24 Feb 2019 15:06:29 +0200 Message-Id: <20190224130638.31848-11-noaos@mellanox.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190224130638.31848-1-noaos@mellanox.com> References: <20190224130638.31848-1-noaos@mellanox.com> 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 This patch tests creation and destruction of memory window. Signed-off-by: Noa Osherovich --- pyverbs/tests/mr.py | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/pyverbs/tests/mr.py b/pyverbs/tests/mr.py index 409cd41e3c06..c97c6ac38d6d 100644 --- a/pyverbs/tests/mr.py +++ b/pyverbs/tests/mr.py @@ -3,11 +3,11 @@ import unittest import random -from pyverbs.pyverbs_error import PyverbsRDMAError +from pyverbs.pyverbs_error import PyverbsRDMAError, PyverbsError from pyverbs.base import PyverbsRDMAErrno import pyverbs.tests.utils as u +from pyverbs.mr import MR, MW import pyverbs.device as d -from pyverbs.mr import MR from pyverbs.pd import PD import pyverbs.enums as e @@ -144,3 +144,40 @@ class mr_test(unittest.TestCase): with MR(pd, length, u.get_access_flags()) as mr: buf = mr.buf + +class mw_test(unittest.TestCase): + """ + Test various functionalities of the MW class. + """ + def test_reg_mw(self): + """ Test ibv_alloc_mw() """ + lst = d.get_device_list() + for dev in lst: + with d.Context(name=dev.name.decode()) as ctx: + with PD(ctx) as pd: + with MW(pd, random.choice([e.IBV_MW_TYPE_1, e.IBV_MW_TYPE_2])) as mw: + pass + + def test_dereg_mw(self): + """ Test ibv_dealloc_mw() """ + lst = d.get_device_list() + for dev in lst: + with d.Context(name=dev.name.decode()) as ctx: + with PD(ctx) as pd: + with MW(pd, random.choice([e.IBV_MW_TYPE_1, e.IBV_MW_TYPE_2])) as mw: + mw.close() + + def test_reg_mw_wrong_type(self): + """ Test ibv_alloc_mw() """ + lst = d.get_device_list() + for dev in lst: + with d.Context(name=dev.name.decode()) as ctx: + with PD(ctx) as pd: + try: + mw_type =random.randint(3, 100) + mw = MW(pd, mw_type) + except PyverbsRDMAError as e: + pass + else: + raise PyverbsError('Created a MW with type {t}'.\ + format(t=mw_type))