Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4448961imb; Wed, 6 Mar 2019 13:45:32 -0800 (PST) X-Google-Smtp-Source: APXvYqy0ivHs3XTfGG201TXc1QLpTw9IXearQdCMh+AuK3sTvqA9GXEFvxJMZXANVg2pjdF9cidd X-Received: by 2002:a17:902:b10f:: with SMTP id q15mr9396355plr.202.1551908732673; Wed, 06 Mar 2019 13:45:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551908732; cv=none; d=google.com; s=arc-20160816; b=TUZXp6b9MLeqLxS+uEG8QMuVWgpPABJfITrIpLhedR4GvLBsGP5Zasngpq6vfEyGbR ls1U/QwDPeD7N89Xqu9T4XKQN6lUI+am9gnql/MvBWJPWDaUOQzIezBUILQmkMpR2KzC V4YHpcsr51tHSSagj/gojJCBHsb1Xm6Myxf4xrgRKsj+Z8YaasBkXxQbAXzbzX89hkNn HssglX1GbGxxw86+u01cBJg97WurVd+gQ4XiHRRAAzTzg+4U6ebmbrqrbjFus6bAYEOS Zs+sXT9VlBUcSPSNckHaFkQ4kRmwXTrfLAMYfJQdvStkn3MAHA5Awlz4fXvO8kab1otZ m4rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YRu6pq+hbZsbA/uLHOfn3mnS6TXv4s3dfV60FY65kB8=; b=OR7X1YrQLNVRACJdnK4mIK5Wo8uc+w6WQbKcER7malsz36WJOJEO7i6yMDRR7eh+kQ nDRXCxKhPuxgcRXSN9HZMSHUln7cO5/m2klb9vHJaTncolU1bA61a+7hKlm1eOKiTX1g kL2cHDEtiiMR+0THFObrBzZ2QcMIIpe2I+RDPzeX0hWo8v0z2RCcqyFEfMMUrEZO53ve BJd50zigXu3SfmYWmZlvSjH0aQpQeO13v5PHLHr0Y9xdV3vWSTHInwmKSVavYTuRrErq 3GKtTyHW5FR43wSygSG3QPFInzk266naLwTVldRK5gQ5GHEQx6aollwWcQYee3eBBhin U/Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=Afutobdr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w21si2385785pga.0.2019.03.06.13.45.17; Wed, 06 Mar 2019 13:45:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=Afutobdr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726344AbfCFVnd (ORCPT + 99 others); Wed, 6 Mar 2019 16:43:33 -0500 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:35425 "EHLO out2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726010AbfCFVnc (ORCPT ); Wed, 6 Mar 2019 16:43:32 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id DEB5C21F6E; Wed, 6 Mar 2019 16:43:30 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 06 Mar 2019 16:43:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=YRu6pq+hbZsbA/uLHOfn3mnS6TXv4s3dfV60FY65kB8=; b=Afutobdr pYFXO595NWJJh+gpGhupvEFASZ994DrszqkrM+GWgYY4cYy7TXDOxUA61GR8Ok8i qGRPkKc89YUSrjXetSMj5ZYxuU69z3fdH+FYVkrsxqCMX3IaNuWLFf6+thH97GUm HEe4oT4K+GRsHewI8KZo+yFWIXteu+67vusLFrh2uSSEMdYVE4c28TbmH2uLqLlC k2+4GC9UggT40nVvVsjUUAzYVoLUrzDGRy3azH1SVAKV7hCeTADX+sTMDFgHK6sa b5ay6SIpuKXB5rE2E0odMDs3aUlIcSJhw2Dum4xUeg8kqWkR5WXuP39dROnIEJD0 3ao/VlSZX0hs9A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrfeeigdekjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepfdfvohgsihhn ucevrdcujfgrrhguihhnghdfuceothhosghinheskhgvrhhnvghlrdhorhhgqeenucfkph epuddvgedrudeiledrhedrudehkeenucfrrghrrghmpehmrghilhhfrhhomhepthhosghi nheskhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgepvd X-ME-Proxy: Received: from eros.localdomain (124-169-5-158.dyn.iinet.net.au [124.169.5.158]) by mail.messagingengine.com (Postfix) with ESMTPA id 379DAE4240; Wed, 6 Mar 2019 16:43:24 -0500 (EST) From: "Tobin C. Harding" To: Kees Cook , Shuah Khan Cc: "Tobin C. Harding" , Jann Horn , Andy Shevchenko , Randy Dunlap , Rasmus Villemoes , Stephen Rothwell , Andy Lutomirski , Daniel Micay , Arnd Bergmann , Miguel Ojeda , "Gustavo A. R. Silva" , Greg Kroah-Hartman , Alexander Shishkin , kernel-hardening@lists.openwall.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/7] kselftest/lib: Use new shell runner to define tests Date: Thu, 7 Mar 2019 08:42:22 +1100 Message-Id: <20190306214226.14598-4-tobin@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306214226.14598-1-tobin@kernel.org> References: <20190306214226.14598-1-tobin@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We just added a new script kselftest_module.sh that can be used to define kselftest tests that run tests within a kernel module. We can use it to reduce code duplication in all of the test runner scripts in tools/testing/selftests/lib/. Use new shell runner tools/testing/selftests/kselftest_module.sh to define test runner scripts. Signed-off-by: Tobin C. Harding --- tools/testing/selftests/lib/bitmap.sh | 25 ++++++++++---------- tools/testing/selftests/lib/prime_numbers.sh | 23 +++++++++--------- tools/testing/selftests/lib/printf.sh | 25 ++++++++++---------- 3 files changed, 35 insertions(+), 38 deletions(-) diff --git a/tools/testing/selftests/lib/bitmap.sh b/tools/testing/selftests/lib/bitmap.sh index 5a90006d1aea..ed4180ea0021 100755 --- a/tools/testing/selftests/lib/bitmap.sh +++ b/tools/testing/selftests/lib/bitmap.sh @@ -1,19 +1,18 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 -# Kselftest framework requirement - SKIP code is 4. -ksft_skip=4 +module=test_bitmap +description="bitmap" -# Runs bitmap infrastructure tests using test_bitmap kernel module -if ! /sbin/modprobe -q -n test_bitmap; then - echo "bitmap: module test_bitmap is not found [SKIP]" - exit $ksft_skip -fi +# +# Shouldn't need to edit anything below here. +# -if /sbin/modprobe -q test_bitmap; then - /sbin/modprobe -q -r test_bitmap - echo "bitmap: ok" -else - echo "bitmap: [FAIL]" - exit 1 +file="kselftest_module.sh" +path="../$file" +if [[ ! $KBUILD_SRC == "" ]]; then + path="${KBUILD_SRC}/tools/testing/selftests/$file" fi + +$path $module $description + diff --git a/tools/testing/selftests/lib/prime_numbers.sh b/tools/testing/selftests/lib/prime_numbers.sh index 78e7483c8d60..6f782386d897 100755 --- a/tools/testing/selftests/lib/prime_numbers.sh +++ b/tools/testing/selftests/lib/prime_numbers.sh @@ -2,18 +2,17 @@ # SPDX-License-Identifier: GPL-2.0 # Checks fast/slow prime_number generation for inconsistencies -# Kselftest framework requirement - SKIP code is 4. -ksft_skip=4 +module=prime_numbers +description="prime_numbers" -if ! /sbin/modprobe -q -n prime_numbers; then - echo "prime_numbers: module prime_numbers is not found [SKIP]" - exit $ksft_skip -fi +# +# Shouldn't need to edit anything below here. +# -if /sbin/modprobe -q prime_numbers selftest=65536; then - /sbin/modprobe -q -r prime_numbers - echo "prime_numbers: ok" -else - echo "prime_numbers: [FAIL]" - exit 1 +file="kselftest_module.sh" +path="../$file" +if [[ ! $KBUILD_SRC == "" ]]; then + path="${KBUILD_SRC}/tools/testing/selftests/$file" fi + +$path $module $description diff --git a/tools/testing/selftests/lib/printf.sh b/tools/testing/selftests/lib/printf.sh index 45a23e2d64ad..89717915d028 100755 --- a/tools/testing/selftests/lib/printf.sh +++ b/tools/testing/selftests/lib/printf.sh @@ -1,19 +1,18 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 -# Runs printf infrastructure using test_printf kernel module +# Tests the printf infrastructure using test_printf kernel module. -# Kselftest framework requirement - SKIP code is 4. -ksft_skip=4 +module=test_printf +description="printf" -if ! /sbin/modprobe -q -n test_printf; then - echo "printf: module test_printf is not found [SKIP]" - exit $ksft_skip -fi +# +# Shouldn't need to edit anything below here. +# -if /sbin/modprobe -q test_printf; then - /sbin/modprobe -q -r test_printf - echo "printf: ok" -else - echo "printf: [FAIL]" - exit 1 +file="kselftest_module.sh" +path="../$file" +if [[ ! $KBUILD_SRC == "" ]]; then + path="${KBUILD_SRC}/tools/testing/selftests/$file" fi + +$path $module $description -- 2.20.1