From patchwork Tue Feb 28 14:12:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Mosnacek X-Patchwork-Id: 13154953 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 3F9EEC6FA8E for ; Tue, 28 Feb 2023 14:13:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229803AbjB1ONp (ORCPT ); Tue, 28 Feb 2023 09:13:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbjB1ONo (ORCPT ); Tue, 28 Feb 2023 09:13:44 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B9704EEC for ; Tue, 28 Feb 2023 06:12:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677593573; 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=eUBux0vBmZ4YIMCUZLV6ctufZZ8MEusMxC91CoZ5h5Y=; b=dRSgfFZ1yDW6yeV0FQ2XfH3BV5ghbAkgvbOyyhRWpK3RYtjkIVexnIyso/CWLPTbYKQ7bx qmplVdO3GLoK3sas6RjJxyaDXy+yYTh3erlio1ZFNAPGXESAd5SLtkntB2hgNs+jxgD7eG X6lmy4O3qWPsXDL0PrIVrrFpJB0pAkM= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-495-9hMcekzpOOSRtLl3e-raLw-1; Tue, 28 Feb 2023 09:12:51 -0500 X-MC-Unique: 9hMcekzpOOSRtLl3e-raLw-1 Received: by mail-wr1-f70.google.com with SMTP id q7-20020a05600000c700b002cd9188abe5so341673wrx.3 for ; Tue, 28 Feb 2023 06:12:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=eUBux0vBmZ4YIMCUZLV6ctufZZ8MEusMxC91CoZ5h5Y=; b=QNGLc8lnXbpYjnoXVMbRimY4I91QTmTFtmxE7WTUqpZsF6ffVs0wpEruECKAloNjVC QXmS1xa3Ufy9s2jEZmNoKoz5B915CfUzDe/y1wd/yZZF42uCZXGzyM2qYHatSheo2nqC rO4TjR/pQa7FWLZeMTRfMV4C/l0u0Yov698YrmDyzrGrvHBGKS5NWy+MuHQFgiOLDjKQ fNUapBnfVSWlMAKE0CBlv/M89ABCxzbP5mqLxZAK33TIOlJL2RYm1nTKpwxGqOHxfYp3 q4P7ug/ZohCrB0RkN+wjY2J+gxSvIvXZeAVQqrwb3ftl79AfztKY0u8Quc0q0ycf3DKG UIOA== X-Gm-Message-State: AO0yUKWNLEuGhnwo5RxAnQLfVaDawYOL0l7DIGfmUyiBmB68c5XWAn1T nvRnAsHO7QxdXsKt44kI4qnShY91KLNHIAq5xoCbJIrhjOVi9zgt3eL6FnbZCnkruXxm/VhC2i3 +wOLSECkyykN9i3YDEBZsOlkBb5fcwfqvKmvCDIyXYIMhBAMq3QzdCcd7TPKtGKuvEjCBxnl0oC 9lwA== X-Received: by 2002:a05:600c:4ab0:b0:3eb:395b:19dc with SMTP id b48-20020a05600c4ab000b003eb395b19dcmr2281556wmp.9.1677593570499; Tue, 28 Feb 2023 06:12:50 -0800 (PST) X-Google-Smtp-Source: AK7set8Vti5fJAZqAgxBajITUW1KdQnsSxd4vxch8+a0ulFNV5sqiwqj8ZW3PN6zA5hyrqKhyikLUw== X-Received: by 2002:a05:600c:4ab0:b0:3eb:395b:19dc with SMTP id b48-20020a05600c4ab000b003eb395b19dcmr2281542wmp.9.1677593570180; Tue, 28 Feb 2023 06:12:50 -0800 (PST) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g14-20020a7bc4ce000000b003eb20d4d4a8sm12161129wmk.44.2023.02.28.06.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 06:12:49 -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: Tue, 28 Feb 2023 15:12:45 +0100 Message-Id: <20230228141247.626736-2-omosnace@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230228141247.626736-1-omosnace@redhat.com> References: <20230228141247.626736-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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/policy/test_ibpkey.te b/policy/test_ibpkey.te index 863ff16..97f0c3c 100644 --- a/policy/test_ibpkey.te +++ b/policy/test_ibpkey.te @@ -10,6 +10,8 @@ type test_ibpkey_access_t; testsuite_domain_type(test_ibpkey_access_t) typeattribute test_ibpkey_access_t ibpkeydomain; +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 Tue Feb 28 14:12:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Mosnacek X-Patchwork-Id: 13154954 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 AFCA4C64ED6 for ; Tue, 28 Feb 2023 14:13:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229681AbjB1ONq (ORCPT ); Tue, 28 Feb 2023 09:13:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbjB1ONp (ORCPT ); Tue, 28 Feb 2023 09:13:45 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 856B7729A for ; Tue, 28 Feb 2023 06:12:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677593574; 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=K90BzBIx/ZgK1MY9EECfYsVdvPhopneuQKAKEmtJN98=; b=fEHYl43rhh9re+FeCuMlU5pZvd0Rsp979CNiqcAF2qiN9cDyFaYsjL9t5N4719zZPBtI0m j+y+QPIvpy1rm4jzVztRqILLDIP3PRD3Qo01G4iuG0oUHxKTP/TXQpM1Y9o0osZ8tE5M8L ME3LIWZevkBbJly2ydwrQK5KX9YNQjg= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-65-OEFuwia-NXmc5YLiu-LwwQ-1; Tue, 28 Feb 2023 09:12:53 -0500 X-MC-Unique: OEFuwia-NXmc5YLiu-LwwQ-1 Received: by mail-wr1-f70.google.com with SMTP id n4-20020a5d5984000000b002c3b562d76cso1623921wri.12 for ; Tue, 28 Feb 2023 06:12:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=K90BzBIx/ZgK1MY9EECfYsVdvPhopneuQKAKEmtJN98=; b=5H2eE3CprqVmerUi73Ccoi7eSTpGcwRcJyXLAsAH81ZtEXn7c7NTEJDbh77b54/lOZ 205DYcarupniAjCEx/+unQMd1beMQeByYzX2m23Hewy8TmkEXL6LOrXphxqk94pwB2RD zcgtuCIlJ2JmIl3kMXoECfaCaq1qs/o8adMuBeW2FQmjtAjW16dcDXOuHQrFVwQMohMi 2Gnrm9qmKYxfP8XYLyLbBVOVqLbVnTjkFpoAVrCujArHAOSQD6mjmFdi1mErzQN+PNV+ /1mEsQjJR6pKA+Y/fTj5/RoA9Bmb+kLOfQ8GvO6OJVC/CeDJ9oNjQs/MS/AHYmMh1bY6 Jydw== X-Gm-Message-State: AO0yUKWUmmzTnYtapKzNQvYWVKjahd5iwcKsUzbzZ9zER+1gmwVDKmva Pcks+Ky5hIJ6MLbdeG8tQaie6JFc01ArfGq00D74YF4VZxy9z/fgT9CnmRiw0fOBEy/hsuJXMnF NP9IPoX0WAxbpoSb/T5f4A7qIPX49Q1h4wMPWTyTdkJiEZUmjcRr8SaHu2mbTrPWxOnvOeAr/Yh bDgA== X-Received: by 2002:a05:600c:3549:b0:3eb:25ff:3446 with SMTP id i9-20020a05600c354900b003eb25ff3446mr2207319wmq.4.1677593571973; Tue, 28 Feb 2023 06:12:51 -0800 (PST) X-Google-Smtp-Source: AK7set+zF28McyuGLVAypodqjzyc+NGtrvbwJ9SIMc6eVj67jtfEqCBQDYmFxos+h24KDu33ho4GUA== X-Received: by 2002:a05:600c:3549:b0:3eb:25ff:3446 with SMTP id i9-20020a05600c354900b003eb25ff3446mr2207304wmq.4.1677593571654; Tue, 28 Feb 2023 06:12:51 -0800 (PST) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g14-20020a7bc4ce000000b003eb20d4d4a8sm12161129wmk.44.2023.02.28.06.12.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 06:12:50 -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: Tue, 28 Feb 2023 15:12:46 +0100 Message-Id: <20230228141247.626736-3-omosnace@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230228141247.626736-1-omosnace@redhat.com> References: <20230228141247.626736-1-omosnace@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org ibv_get_device_list(3) first tries to get the device list via netlink and 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 | 1 + 1 file changed, 1 insertion(+) diff --git a/policy/test_ibpkey.te b/policy/test_ibpkey.te index 97f0c3c..6835897 100644 --- a/policy/test_ibpkey.te +++ b/policy/test_ibpkey.te @@ -11,6 +11,7 @@ testsuite_domain_type(test_ibpkey_access_t) typeattribute test_ibpkey_access_t ibpkeydomain; allow test_ibpkey_access_t self:capability ipc_lock; +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 Tue Feb 28 14:12:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Mosnacek X-Patchwork-Id: 13154955 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 87CE7C6FA8E for ; Tue, 28 Feb 2023 14:13:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229600AbjB1ONs (ORCPT ); Tue, 28 Feb 2023 09:13:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbjB1ONs (ORCPT ); Tue, 28 Feb 2023 09:13:48 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAB58A24A for ; Tue, 28 Feb 2023 06:12:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677593576; 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=OJntSZD78BSy3byPVykqzQsZI5eJvJkZmyNgcXRqNMaWHEsmJrjGJsrrmE38KosAL0QMLr WPYx4nBoVLKF0D2PhQmkKqn9C5z5kwgcjcYp/BXuHQs3H5n1E6jZH9MAEr8FnbN8akXWtT Q78AC9euP4oAlz03F9I7oGUO7Y1Rysw= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-1-YTmS6somMEGMbO_HDHI_xg-1; Tue, 28 Feb 2023 09:12:54 -0500 X-MC-Unique: YTmS6somMEGMbO_HDHI_xg-1 Received: by mail-wr1-f69.google.com with SMTP id q7-20020a05600000c700b002cd9188abe5so341712wrx.3 for ; Tue, 28 Feb 2023 06:12:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=i/aLUg6nM9bDKziWA65Zy5kaBVBanXlMImK/qKrXK4F8QqaxoJ56BATfQUIbM9dSsM IsznSaLVPVdJMs37Pm735Sj1lvBHm3oK4oZ734K4ekjxmCNmFDb998DGxckRLg7C31lQ Sh8mkN+SPutaE89wLazcWgOCJIChOMWd8YtyvymwPrZp+nvyIeYTjP/LxH4SRUFfRjPV HMsKHk++KwZnx8+rqMXih2CTkGfCyLWXKD9BreECzES5xMteRy6hwHC9/pRfVx4PfG9x mO8Jj+8m1CGHSbGhZ/5yJB/hvnv8VwrkCRyFnNhpfMvW2N7vBSfrbkovvxv6C9PeZTCL RSbg== X-Gm-Message-State: AO0yUKVU7PrLaa5L/RxftS75Fz703Tu+zqEE+rKuu6Xxb8tYT9bELsLH D4m0BtkLMGCBAdaBhx7bOKh8sGu7AuGqSmfI9oTR+CfuTBcFHeMP0pdgPliHW12HCuV1zbVFMlx 3gipJEKJq22L8mZFBunJXevT4Wsn1ALXO/Du4UM//r4i7ufy3b8OCIHQ4Ie1osrpnE6OHRzGqZH 7ZgQ== X-Received: by 2002:a05:600c:1652:b0:3eb:399d:ab18 with SMTP id o18-20020a05600c165200b003eb399dab18mr2225897wmn.35.1677593573307; Tue, 28 Feb 2023 06:12:53 -0800 (PST) X-Google-Smtp-Source: AK7set8TlqnJTTojgSSx2itOCo8NrxjP8KCtx7ScEhrjbTeWMs2u67EeZ8nPlOQkEi/j+ui/r6CsyA== X-Received: by 2002:a05:600c:1652:b0:3eb:399d:ab18 with SMTP id o18-20020a05600c165200b003eb399dab18mr2225877wmn.35.1677593572904; Tue, 28 Feb 2023 06:12:52 -0800 (PST) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g14-20020a7bc4ce000000b003eb20d4d4a8sm12161129wmk.44.2023.02.28.06.12.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 06:12:51 -0800 (PST) From: Ondrej Mosnacek To: selinux@vger.kernel.org Subject: [PATCH testsuite 3/3] tests/infiniband*: simplify test activation Date: Tue, 28 Feb 2023 15:12:47 +0100 Message-Id: <20230228141247.626736-4-omosnace@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230228141247.626736-1-omosnace@redhat.com> References: <20230228141247.626736-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);