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: 10841825 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 4C27F922 for ; Wed, 6 Mar 2019 21:43:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EB2E2E8F0 for ; Wed, 6 Mar 2019 21:43:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D02C2EF3D; Wed, 6 Mar 2019 21:43:58 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 511722E8F0 for ; Wed, 6 Mar 2019 21:43:57 +0000 (UTC) Received: (qmail 8131 invoked by uid 550); 6 Mar 2019 21:43:43 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 8013 invoked from network); 6 Mar 2019 21:43:42 -0000 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: 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 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