From patchwork Fri Mar 3 14:08:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Mosnacek X-Patchwork-Id: 13158842 X-Patchwork-Delegate: omosnacek@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0511C678D4 for ; Fri, 3 Mar 2023 14:09:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229511AbjCCOJ4 (ORCPT ); Fri, 3 Mar 2023 09:09:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230393AbjCCOJn (ORCPT ); Fri, 3 Mar 2023 09:09:43 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 429232A6C3 for ; Fri, 3 Mar 2023 06:09:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677852539; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bD2brzI2wQnZjtN+W4B4dIdiMoLwTI1EncX6adDpc8A=; b=ZnYy7pUtTHFyBIOllT3h8CJiVpun5APJUyvIfRmZocgNp9pcVZYcbq9ZN1VGuQHTXxCyCA MVG+ySE3OcDI0bKzSBwGbUzQXIdb8+MTRmryPhCqYjuq6qb8Kx7q9A5g/PBuqZDk5jv/Ii fHPPzhgaCe0wEo040pMQU4X5KIkNeMc= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-474-El0UCg8rPNCpd2fkAXMJmg-1; Fri, 03 Mar 2023 09:08:58 -0500 X-MC-Unique: El0UCg8rPNCpd2fkAXMJmg-1 Received: by mail-wm1-f69.google.com with SMTP id k36-20020a05600c1ca400b003eac86e4387so2882810wms.8 for ; Fri, 03 Mar 2023 06:08:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677852537; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bD2brzI2wQnZjtN+W4B4dIdiMoLwTI1EncX6adDpc8A=; b=MyXLHHeueDdExDg29L5Pk263ZoFh0fX1fngElHmvG4xFSg1vZLapNNbfmvtmJCMgjy /8tM7wg9qSLg2/NNSZuC12BSvUMLKBDEPJE21RdPt1mcFMD13PPKRpolp8g9xcHsiQH3 qVC1trJEzlawW/CDkPe4eXPXwPZLrz1EQjOlZWy73FiiQSweZbGdiTer66edpNHXmabv 8WTjffFu04Re09R0gmRdXiTo0ysgxeuTbjHB1lmbTCfjKsxH1RaJnWplY7scFGGA5PlZ W2XXutSQMYDbRaf8TZ8/2R/ICI6oNYkKi9S4a6LQs+ueKprkm9BhggfhStMWairhxrIK i+tA== X-Gm-Message-State: AO0yUKUM5r3BuKZxeOEIC2oWazbTBDMVdD5y3w9zlhXpxycGyAwEV9gw Qo03WTuMiAmMnepkUzurIG2Y85/DxYReg4Zdb7r3auD3HXoP0yyFFpE3cMjyR78DM1YrHLCUB5n LDqmXrdPC1AzqsIFbQ+mHzTBoIiXBNusahlny5RwarLwYE5zD/dHY62vuIXvpCpO7qMMJHQKu1P /jQA== X-Received: by 2002:a05:600c:1c13:b0:3e9:9fc5:2c6d with SMTP id j19-20020a05600c1c1300b003e99fc52c6dmr1771492wms.14.1677852536908; Fri, 03 Mar 2023 06:08:56 -0800 (PST) X-Google-Smtp-Source: AK7set8ZhIeR81eThsW6IB77Z41R5hCuAFOC/8FkMZ4/EVxMVrLVq5CHgFtisUCRXfhkKG+2v019OQ== X-Received: by 2002:a05:600c:1c13:b0:3e9:9fc5:2c6d with SMTP id j19-20020a05600c1c1300b003e99fc52c6dmr1771472wms.14.1677852536636; Fri, 03 Mar 2023 06:08:56 -0800 (PST) Received: from localhost.localdomain ([2a02:8308:b104:2c00:2e8:ec99:5760:fb52]) by smtp.gmail.com with ESMTPSA id t17-20020a05600c41d100b003dc4fd6e624sm2423650wmh.19.2023.03.03.06.08.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Mar 2023 06:08:55 -0800 (PST) From: Ondrej Mosnacek To: selinux@vger.kernel.org Cc: Mimi Zohar Subject: [PATCH testsuite 1/3] policy: make sure test_ibpkey_access_t can lock enough memory Date: Fri, 3 Mar 2023 15:08:51 +0100 Message-Id: <20230303140853.1276325-2-omosnace@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230303140853.1276325-1-omosnace@redhat.com> References: <20230303140853.1276325-1-omosnace@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org The ibv_create_cq() operation requires the caller to be able to lock enough memory (RLIMIT_MEMLOCK). In some environments (such as RHEL-8) the default resource limits may not be enough, requiring CAP_IPC_LOCK to go above the limit. To make sure the test works also under stricter resource limits, grant CAP_IPC_LOCK to test_ibpkey_access_t. Reported-by: Mimi Zohar Signed-off-by: Ondrej Mosnacek --- policy/test_ibpkey.te | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/policy/test_ibpkey.te b/policy/test_ibpkey.te index 863ff16..2bfb701 100644 --- a/policy/test_ibpkey.te +++ b/policy/test_ibpkey.te @@ -10,6 +10,10 @@ type test_ibpkey_access_t; testsuite_domain_type(test_ibpkey_access_t) typeattribute test_ibpkey_access_t ibpkeydomain; +# ibv_create_cq(3) locks some memory - make sure the domain can do that +# even with strict resource limits. +allow test_ibpkey_access_t self:capability ipc_lock; + dev_rw_infiniband_dev(test_ibpkey_access_t) dev_rw_sysfs(test_ibpkey_access_t) From patchwork Fri Mar 3 14:08:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Mosnacek X-Patchwork-Id: 13158843 X-Patchwork-Delegate: omosnacek@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48354C64EC4 for ; Fri, 3 Mar 2023 14:09:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230286AbjCCOJ4 (ORCPT ); Fri, 3 Mar 2023 09:09:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230322AbjCCOJn (ORCPT ); Fri, 3 Mar 2023 09:09:43 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C07692BEF6 for ; Fri, 3 Mar 2023 06:09:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677852541; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ST7dEqQS9DUBTgAx6jdcQBA+jnJBOFiBnHjhVvyp/0k=; b=YAzdwG8leA341ZlEYASg9DFbwewe6nydM41V0lxr5X3CCw+OudMEaEUWKLPEL7aTwSXfus PbeHtOQCBgkx6/wy0lsNKB0HDN75XmwULb+EnMMcaIPGYSxQABbw1JaYSLoYxiSbl2cTzl YO5WDBJmPPHCtR61nYWW9PJbgoi90xI= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-582-dHIXfQoQNRmGlpenVkRIBg-1; Fri, 03 Mar 2023 09:08:59 -0500 X-MC-Unique: dHIXfQoQNRmGlpenVkRIBg-1 Received: by mail-wr1-f71.google.com with SMTP id g6-20020adfa486000000b002c55ef1ec94so412817wrb.0 for ; Fri, 03 Mar 2023 06:08:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677852538; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ST7dEqQS9DUBTgAx6jdcQBA+jnJBOFiBnHjhVvyp/0k=; b=2buBKGocCai6aQu9d75Rkdq40W8qbrbHYSGd5vJ0XZ3S7eTq4sepaX0M+KiD5RCtfK Xrtxn8VrIuQSw/9xsIratgUHdxQjwNHjoXY9HiNlnqHlH045bwm53zcrvX0tB0dG23tg GjvFETVpjymJJ3dLJn94o0nqLTD00nhdW067rC9rBtmiX1mAMqYr84A/BPMmvSZHNZvg Cpy+Q+BipoXmfuZIakxexLaTL7LfaHjQtFEqDerk0lojztl5jsSDOt9OrHU0wgiaM62/ El5bVdbYzsn0OslVcxnXel8i+ssMEjQTaWWiUSOcbDSLNAR9f0RAKkQrxFNoAJoTjb2b GBpA== X-Gm-Message-State: AO0yUKW9IhnSbGPQmJqlJQjR6honhgKWqn/tc+SI0eFYvsE/u9huMKIS Bh0ii/eB0uRR1IW4mFnhG/SpsI7AX3N75StkSbZ7A5ykL26ypUCvnZMYehS5gm+tBlHhHLMc6jJ PgnoTjN3EOxD90nKKpPa4AdwqoAVjytBi2aHoGiDd1QDtkgQyAmYAsoQekpyvTyxiC+Qz/AQR5i jS4w== X-Received: by 2002:a05:600c:cc4:b0:3e7:6a59:d9d3 with SMTP id fk4-20020a05600c0cc400b003e76a59d9d3mr1809986wmb.37.1677852538281; Fri, 03 Mar 2023 06:08:58 -0800 (PST) X-Google-Smtp-Source: AK7set/Mv8+uf39pqp0vq/Ykj9eeNSaffFuWUDeYpth33RHverTLL32AOF8t86Tm6cOHMA7PD95Jkg== X-Received: by 2002:a05:600c:cc4:b0:3e7:6a59:d9d3 with SMTP id fk4-20020a05600c0cc400b003e76a59d9d3mr1809962wmb.37.1677852537950; Fri, 03 Mar 2023 06:08:57 -0800 (PST) Received: from localhost.localdomain ([2a02:8308:b104:2c00:2e8:ec99:5760:fb52]) by smtp.gmail.com with ESMTPSA id t17-20020a05600c41d100b003dc4fd6e624sm2423650wmh.19.2023.03.03.06.08.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Mar 2023 06:08:56 -0800 (PST) From: Ondrej Mosnacek To: selinux@vger.kernel.org Subject: [PATCH testsuite 2/3] policy: allow test_ibpkey_access_t to use RDMA netlink sockets Date: Fri, 3 Mar 2023 15:08:52 +0100 Message-Id: <20230303140853.1276325-3-omosnace@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230303140853.1276325-1-omosnace@redhat.com> References: <20230303140853.1276325-1-omosnace@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Since rdma-core version 25, ibv_get_device_list(3) first tries to get the device list via netlink and only if that fails it falls back to getting it from sysfs. Currently the policy denies getting it from netlink, generating some denials. Allow test_ibpkey_access_t the necessary permissions so it can do it the preferred way and doesn't generate audit AVC noise. Signed-off-by: Ondrej Mosnacek --- policy/test_ibpkey.te | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/policy/test_ibpkey.te b/policy/test_ibpkey.te index 2bfb701..b128f5e 100644 --- a/policy/test_ibpkey.te +++ b/policy/test_ibpkey.te @@ -14,6 +14,10 @@ typeattribute test_ibpkey_access_t ibpkeydomain; # even with strict resource limits. allow test_ibpkey_access_t self:capability ipc_lock; +# ibv_get_device_list(3) wants to list the devices via netlink by default +# (if denied it falls back to listing them via sysfs). +allow test_ibpkey_access_t self:netlink_rdma_socket create_socket_perms; + dev_rw_infiniband_dev(test_ibpkey_access_t) dev_rw_sysfs(test_ibpkey_access_t) From patchwork Fri Mar 3 14:08:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Mosnacek X-Patchwork-Id: 13158844 X-Patchwork-Delegate: omosnacek@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F21CEC7EE2F for ; Fri, 3 Mar 2023 14:09:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230316AbjCCOJ5 (ORCPT ); Fri, 3 Mar 2023 09:09:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231373AbjCCOJv (ORCPT ); Fri, 3 Mar 2023 09:09:51 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F1402CC55 for ; Fri, 3 Mar 2023 06:09:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677852542; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FwScJTD1hNgmOM00GgqSTpfBFJvArfgtsQpmo3/eHaI=; b=G8la4WHoLU6DrPyNdnI0TxKgy2sxZwHvBvkN0CZbeTXDqonVw5du17fabToYXaan2mI7yL Y+kXU+/8eaL91++iAcQlSbMe+V1EGVLdNYEO2BJX6eLzueaCjMPKmvUKyfjwKoBJrsDGBQ rT3dse/wmR8qz39n8YOJM1k89HQdcV8= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-290-06dEAPp5PlSgDGwgyrb7Ug-1; Fri, 03 Mar 2023 09:09:01 -0500 X-MC-Unique: 06dEAPp5PlSgDGwgyrb7Ug-1 Received: by mail-wr1-f72.google.com with SMTP id m10-20020adfe94a000000b002cdc5eac0d0so410576wrn.2 for ; Fri, 03 Mar 2023 06:09:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677852540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FwScJTD1hNgmOM00GgqSTpfBFJvArfgtsQpmo3/eHaI=; b=bxQLDw+SpGlWbXHaXy7LHzS3nJ5GUaR7/oYrzLZppnRReqyAh/Ikj4ijylbQ5gtxjE 93nBTvIXWEGAZ+yWYRIVd5InyzZ+trkAGkUxwDy7EU70xqIpVFIN9uPKMmW+P8rsUPuz Wsh0oiLjRJxk4VxhvknjjR/2yXrFh17sACVx8knMIcFkz1S2QtoqgJRGldnu5458pX3r kw/bviFDbhbDmfw0qcECeIbfuJtmPYEf7RzuABjaP04G2DIAD5vbl65u9AObUGHG4XsY kbXGaZvdVEeCiOzhc1K0S6wf1Z4IOwMyN2mm7Kh2IHgd4zfuUWn2xt+6odf7orHtfoAU 2Veg== X-Gm-Message-State: AO0yUKXH+6cDRMv+dLQMug5dSQ0StanhH1a/wM0xyq88jGOJZJ7XcrUU APyQuzSUh3M/54elO6f/MvfXniAsDYp/2qbtIe5161UfPGFsikzELi3nza3aDQClG7Pp9FVUMsF 8C0nF1+uEl/M+dDpQLSA6VTfpf7ft+17F6bFb7ZSmaRlTKlkun92dOhsHxp7MBI88kk7K0BG8+P LbYA== X-Received: by 2002:a05:600c:1c9c:b0:3ea:4af0:3475 with SMTP id k28-20020a05600c1c9c00b003ea4af03475mr1846908wms.1.1677852539857; Fri, 03 Mar 2023 06:08:59 -0800 (PST) X-Google-Smtp-Source: AK7set+zOTZIT5yakKOtUEioun6kZuzaxBKoWCCHypcmKUDyW4RRnWJe/DnUf1aKGkrUTS7ISTd4LQ== X-Received: by 2002:a05:600c:1c9c:b0:3ea:4af0:3475 with SMTP id k28-20020a05600c1c9c00b003ea4af03475mr1846851wms.1.1677852539172; Fri, 03 Mar 2023 06:08:59 -0800 (PST) Received: from localhost.localdomain ([2a02:8308:b104:2c00:2e8:ec99:5760:fb52]) by smtp.gmail.com with ESMTPSA id t17-20020a05600c41d100b003dc4fd6e624sm2423650wmh.19.2023.03.03.06.08.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Mar 2023 06:08:58 -0800 (PST) From: Ondrej Mosnacek To: selinux@vger.kernel.org Subject: [PATCH testsuite 3/3] tests/infiniband*: simplify test activation Date: Fri, 3 Mar 2023 15:08:53 +0100 Message-Id: <20230303140853.1276325-4-omosnace@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230303140853.1276325-1-omosnace@redhat.com> References: <20230303140853.1276325-1-omosnace@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Use Test::More and skip_all to enable/disable these tests if they are configured instead of doing this in the Makefile via grep. Signed-off-by: Ondrej Mosnacek --- Vagrantfile | 1 + tests/Makefile | 11 ++------- tests/infiniband_endport/test | 39 ++++++++++++++++++------------- tests/infiniband_pkey/test | 44 ++++++++++++++++++++--------------- 4 files changed, 51 insertions(+), 44 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 6f7675f..682b805 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -89,6 +89,7 @@ EOF e2fsprogs \ jfsutils \ dosfstools \ + rdma-core-devel \ #{kernel_pkgs} #{extra_commands} diff --git a/tests/Makefile b/tests/Makefile index 5998a9f..74df247 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -27,7 +27,8 @@ SUBDIRS:= domain_trans entrypoint execshare exectrace execute_no_trans \ task_setnice task_setscheduler task_getscheduler task_getsid \ task_getpgid task_setpgid file ioctl capable_file capable_net \ capable_sys dyntrans dyntrace bounds nnp_nosuid mmap unix_socket \ - inet_socket overlay checkreqprot mqueue mac_admin atsecure + inet_socket overlay checkreqprot mqueue mac_admin atsecure \ + infiniband_endport infiniband_pkey ifeq ($(shell grep -q cap_userns $(POLDEV)/include/support/all_perms.spt && echo true),true) ifneq ($(shell ./kvercmp $$(uname -r) 4.7),-1) @@ -82,14 +83,6 @@ endif # POL_VERS endif # POL_TYPE endif # MAX_KERNEL_POLICY -ifeq ($(shell grep "^SELINUX_INFINIBAND_ENDPORT_TEST=" infiniband_endport/ibendport_test.conf | cut -d'=' -f 2),1) -SUBDIRS += infiniband_endport -endif - -ifeq ($(shell grep "^SELINUX_INFINIBAND_PKEY_TEST=" infiniband_pkey/ibpkey_test.conf | cut -d'=' -f 2),1) -SUBDIRS += infiniband_pkey -endif - ifneq ($(shell ./kvercmp $$(uname -r) 5.2),-1) SUBDIRS += cgroupfs_label endif diff --git a/tests/infiniband_endport/test b/tests/infiniband_endport/test index f071fbc..c55ce84 100755 --- a/tests/infiniband_endport/test +++ b/tests/infiniband_endport/test @@ -1,25 +1,32 @@ #!/usr/bin/perl -use Test; +use Test::More; -BEGIN { plan tests => 3 } +my %conf; -$basedir = $0; -$basedir =~ s|(.*)/[^/]*|$1|; +BEGIN { + $basedir = $0; + $basedir =~ s|(.*)/[^/]*|$1|; + + $confpath = $basedir . "/ibendport_test.conf"; + open( $f, $confpath ) or die("Couldn't open $confpath"); + while ( $r = <$f> ) { + if ( $r =~ /^\s*#/ || $r =~ /^\s*$/ ) { next; } + chomp $r; + ( $k, $v ) = split( /=/, $r ); + $conf{$k} = $v; + } + close($f); -my %conf; -my $confpath = $basedir . "/ibendport_test.conf"; -open( $f, $confpath ) or die("Couldn't open ibtest.conf"); -while ( $r = <$f> ) { - if ( $r =~ /^\s*#/ || $r =~ /^\s*$/ ) { next; } - chomp $r; - ( $k, $v ) = split( /=/, $r ); - $conf{$k} = $v; + # Verify that we really want to run these tests. + if ( $conf{SELINUX_INFINIBAND_ENDPORT_TEST} eq 1 ) { + plan tests => 2; + } + else { + plan skip_all => "test not configured"; + } } -# verify that we really want to run these tests -ok( $conf{SELINUX_INFINIBAND_ENDPORT_TEST} eq 1 ); - @allowed_device_port = split( /,/, $conf{SELINUX_INFINIBAND_ENDPORT_TEST_ALLOWED} ); @denied_device_port = @@ -36,7 +43,7 @@ foreach (@allowed_device_port) { last; } } -ok( $result, 0 ); +ok( $result eq 0 ); foreach (@denied_device_port) { @dev_port_pair = split( / /, $_ ); diff --git a/tests/infiniband_pkey/test b/tests/infiniband_pkey/test index 382c259..e5d2efb 100755 --- a/tests/infiniband_pkey/test +++ b/tests/infiniband_pkey/test @@ -1,25 +1,31 @@ #!/usr/bin/perl -use Test; +use Test::More; -BEGIN { plan tests => 4 } +my %conf; -$basedir = $0; -$basedir =~ s|(.*)/[^/]*|$1|; +BEGIN { + $basedir = $0; + $basedir =~ s|(.*)/[^/]*|$1|; -my %conf; -$confpath = $basedir . "/ibpkey_test.conf"; -open( $f, $confpath ) or die("Couldn't open $confpath"); -while ( $r = <$f> ) { - if ( $r =~ /^\s*#/ || $r =~ /^\s*$/ ) { next; } - chomp $r; - ( $k, $v ) = split( /=/, $r ); - $conf{$k} = $v; -} -close($f); + $confpath = $basedir . "/ibpkey_test.conf"; + open( $f, $confpath ) or die("Couldn't open $confpath"); + while ( $r = <$f> ) { + if ( $r =~ /^\s*#/ || $r =~ /^\s*$/ ) { next; } + chomp $r; + ( $k, $v ) = split( /=/, $r ); + $conf{$k} = $v; + } + close($f); -# Verify that we really want to run these tests. -ok( $conf{SELINUX_INFINIBAND_PKEY_TEST} eq 1 ); + # Verify that we really want to run these tests. + if ( $conf{SELINUX_INFINIBAND_PKEY_TEST} eq 1 ) { + plan tests => 3; + } + else { + plan skip_all => "test not configured"; + } +} $device = $conf{SELINUX_INFINIBAND_PKEY_TEST_DEV}; $port = $conf{SELINUX_INFINIBAND_PKEY_TEST_PORT}; @@ -47,7 +53,7 @@ foreach (@unlabeled_pkeys) { } } if (@unlabeled_pkeys) { - ok( $result, 0 ); + ok( $result eq 0 ); } else { ok(1); @@ -69,7 +75,7 @@ foreach (@unlabeled_pkeys) { } } if (@unlabeled_pkeys) { - ok( $result >> 8, 13 ); + ok( $result >> 8 eq 13 ); } else { ok(1); @@ -83,7 +89,7 @@ foreach (@labeled_pkeys) { } } if (@labeled_pkeys) { - ok( $result >> 8, 13 ); + ok( $result >> 8 eq 13 ); } else { ok(1);