From patchwork Wed Mar 6 21:42:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 10841811 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 C383A922 for ; Wed, 6 Mar 2019 21:43:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B12B52E610 for ; Wed, 6 Mar 2019 21:43:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF5BA2EF3D; Wed, 6 Mar 2019 21:43:33 +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,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 2B76B2E610 for ; Wed, 6 Mar 2019 21:43:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726324AbfCFVnc (ORCPT ); Wed, 6 Mar 2019 16:43:32 -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 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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