From patchwork Mon Sep 28 20:26:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 11804629 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 20EAD1746 for ; Mon, 28 Sep 2020 20:27:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01BBE208FE for ; Mon, 28 Sep 2020 20:27:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="f1z2MXwb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726803AbgI1U0z (ORCPT ); Mon, 28 Sep 2020 16:26:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726621AbgI1U0y (ORCPT ); Mon, 28 Sep 2020 16:26:54 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAEDAC0613CF for ; Mon, 28 Sep 2020 13:26:54 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id d13so1893698pgl.6 for ; Mon, 28 Sep 2020 13:26:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZOrfE0wnl6Q5jHyL+t54vVabQfAKKdOXl04nt52zYdk=; b=f1z2MXwb2iQEYv4KPFFnxv+HHKJhJrXpDOH+8K8NSuUJ3aFSmK19MG64n1ptPT1LiH I8zrgXqXf/KsjWY4BV8/xLc2b8iTSVV06C7TLglCRfuDU9Eo6xeLMVrQNdd99RqMx9rA y9bMe/0vUpC2pVInrvkR7nTpQDY4Zbffwbcc0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZOrfE0wnl6Q5jHyL+t54vVabQfAKKdOXl04nt52zYdk=; b=s4Dn5RmhdiB8cfXg4sioao9B/TrhvIJizhrzHktiLtizLlTKV2Roc4mAnS+bfAAC+7 S5l1aQp7U6/F2FSlaDb/XpGkxu0T6Agnl2+xp3WOdXVGONJAIXZ0j+MP6SVYiLg+0doJ FLPzhqmGbk5yereWyz/ksJ1//edP7mMAwdAR7790IJA2OFPrR13yBPuOLRY6uTuz8qkb 7zPSot9TFvhSCuoEMQjZGRR9sxZtDESw5B7QxvZWJo7N7k1KLXIw9p0JrcrO04tq7yOL qLhgTCri1mR8ECG1SOyu6fXO9S5T+r6GnPjAVXrPoI+kU/qpJ31WuTVtvo3XyXRI0eP6 fKpw== X-Gm-Message-State: AOAM533bHa4FV9VDTRoQzYnQUHNsSAHKMktpRzV6/ntXp17/dMN2oaKR 334l4SSTNjZFdwZUoQydd7+kGA== X-Google-Smtp-Source: ABdhPJxQuzqMyk4kjJoEQF/hXYqx8+JzbpEgS7yS3So3A3BdkwoayVUzOf2a8+ctWxPK/muoOVAP9g== X-Received: by 2002:aa7:9f10:0:b029:142:2501:34d4 with SMTP id g16-20020aa79f100000b0290142250134d4mr968913pfr.45.1601324813912; Mon, 28 Sep 2020 13:26:53 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id s22sm2742242pfd.90.2020.09.28.13.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 13:26:53 -0700 (PDT) From: Kees Cook To: Shuah Khan Cc: Kees Cook , Naresh Kamboju , Hangbin Liu , Jonathan Corbet , linux-doc@vger.kernel.org, Tim.Bird@sony.com, lkft-triage@lists.linaro.org, Anders Roxell , Justin Cook , Linux-Next Mailing List , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 1/3] selftests: Extract run_kselftest.sh and generate stand-alone test list Date: Mon, 28 Sep 2020 13:26:48 -0700 Message-Id: <20200928202650.2530280-2-keescook@chromium.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200928202650.2530280-1-keescook@chromium.org> References: <20200928202650.2530280-1-keescook@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Instead of building a script on the fly (which just repeats the same thing for each test collection), move the script out of the Makefile and into run_kselftest.sh, which reads kselftest-list.txt. Adjust the emit_tests target to report each test on a separate line so that test running tools (e.g. LAVA) can easily remove individual tests (for example, as seen in [1]). [1] https://github.com/Linaro/test-definitions/pull/208/commits/2e7b62155e4998e54ac0587704932484d4ff84c8 Signed-off-by: Kees Cook Tested-by: Naresh Kamboju --- tools/testing/selftests/Makefile | 26 ++++++---------------- tools/testing/selftests/lib.mk | 5 ++--- tools/testing/selftests/run_kselftest.sh | 28 ++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 22 deletions(-) create mode 100755 tools/testing/selftests/run_kselftest.sh diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 15c1c1359c50..d9c283503159 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -206,6 +206,7 @@ KSFT_INSTALL_PATH := $(abspath $(KSFT_INSTALL_PATH)) # Avoid changing the rest of the logic here and lib.mk. INSTALL_PATH := $(KSFT_INSTALL_PATH) ALL_SCRIPT := $(INSTALL_PATH)/run_kselftest.sh +TEST_LIST := $(INSTALL_PATH)/kselftest-list.txt install: all ifdef INSTALL_PATH @@ -214,6 +215,8 @@ ifdef INSTALL_PATH install -m 744 kselftest/module.sh $(INSTALL_PATH)/kselftest/ install -m 744 kselftest/runner.sh $(INSTALL_PATH)/kselftest/ install -m 744 kselftest/prefix.pl $(INSTALL_PATH)/kselftest/ + install -m 744 run_kselftest.sh $(INSTALL_PATH)/ + rm -f $(TEST_LIST) @ret=1; \ for TARGET in $(TARGETS); do \ BUILD_TARGET=$$BUILD/$$TARGET; \ @@ -222,33 +225,18 @@ ifdef INSTALL_PATH ret=$$((ret * $$?)); \ done; exit $$ret; - @# Ask all targets to emit their test scripts - echo "#!/bin/sh" > $(ALL_SCRIPT) - echo "BASE_DIR=\$$(realpath \$$(dirname \$$0))" >> $(ALL_SCRIPT) - echo "cd \$$BASE_DIR" >> $(ALL_SCRIPT) - echo ". ./kselftest/runner.sh" >> $(ALL_SCRIPT) - echo "ROOT=\$$PWD" >> $(ALL_SCRIPT) - echo "if [ \"\$$1\" = \"--summary\" ]; then" >> $(ALL_SCRIPT) - echo " logfile=\$$BASE_DIR/output.log" >> $(ALL_SCRIPT) - echo " cat /dev/null > \$$logfile" >> $(ALL_SCRIPT) - echo "fi" >> $(ALL_SCRIPT) - @# While building run_kselftest.sh skip also non-existent TARGET dirs: + @# Ask all targets to emit their test scripts + @# While building kselftest-list.text skip also non-existent TARGET dirs: @# they could be the result of a build failure and should NOT be @# included in the generated runlist. for TARGET in $(TARGETS); do \ BUILD_TARGET=$$BUILD/$$TARGET; \ [ ! -d $(INSTALL_PATH)/$$TARGET ] && echo "Skipping non-existent dir: $$TARGET" && continue; \ - echo "[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \ - echo "cd $$TARGET" >> $(ALL_SCRIPT); \ - echo -n "run_many" >> $(ALL_SCRIPT); \ echo -n "Emit Tests for $$TARGET\n"; \ - $(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \ - echo "" >> $(ALL_SCRIPT); \ - echo "cd \$$ROOT" >> $(ALL_SCRIPT); \ + $(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET COLLECTION=$$TARGET \ + -C $$TARGET emit_tests >> $(TEST_LIST); \ done; - - chmod u+x $(ALL_SCRIPT) else $(error Error: set INSTALL_PATH to use install) endif diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk index 51124b962d56..30848ca36555 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk @@ -107,9 +107,8 @@ endif emit_tests: for TEST in $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_PROGS); do \ BASENAME_TEST=`basename $$TEST`; \ - echo " \\"; \ - echo -n " \"$$BASENAME_TEST\""; \ - done; \ + echo "$(COLLECTION):$$BASENAME_TEST"; \ + done # define if isn't already. It is undefined in make O= case. ifeq ($(RM),) diff --git a/tools/testing/selftests/run_kselftest.sh b/tools/testing/selftests/run_kselftest.sh new file mode 100755 index 000000000000..8b0ad4766d78 --- /dev/null +++ b/tools/testing/selftests/run_kselftest.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# Run installed kselftest tests. +# +BASE_DIR=$(realpath $(dirname $0)) +cd $BASE_DIR +TESTS="$BASE_DIR"/kselftest-list.txt +if [ ! -r "$TESTS" ] ; then + echo "$0: Could not find list of tests to run ($TESTS)" >&2 + exit 1 +fi +available="$(cat "$TESTS")" + +. ./kselftest/runner.sh +ROOT=$PWD + +if [ "$1" = "--summary" ] ; then + logfile="$BASE_DIR"/output.log + cat /dev/null > $logfile +fi + +collections=$(echo "$available" | cut -d: -f1 | uniq) +for collection in $collections ; do + [ -w /dev/kmsg ] && echo "kselftest: Running tests in $collection" >> /dev/kmsg + tests=$(echo "$available" | grep "^$collection:" | cut -d: -f2) + (cd "$collection" && run_many $tests) +done From patchwork Mon Sep 28 20:26:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 11804627 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EA811112C for ; Mon, 28 Sep 2020 20:27:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C3C3A20809 for ; Mon, 28 Sep 2020 20:27:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="e9JuINGP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726900AbgI1U1E (ORCPT ); Mon, 28 Sep 2020 16:27:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726865AbgI1U0z (ORCPT ); Mon, 28 Sep 2020 16:26:55 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71CAEC0613D3 for ; Mon, 28 Sep 2020 13:26:55 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id o20so2178178pfp.11 for ; Mon, 28 Sep 2020 13:26:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CzRblziNDCaC7keBvDiohhrFtalx1DXB9TPgmLszZrA=; b=e9JuINGPJVrbQYKx7vuqE1Loo2OssneXzQmGiy4MVvC7Kr42QHsB4ujyYE3sThJClK eyB3VynG+2YNjxnCFf54brvGq1UAcCaEzzn8XYUwVZJfWgYnFd0mf7pKZMQf5XmutkrW EwMA/bmLqy5rsMsw501J+eXLKTtB/3DeH+SsE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CzRblziNDCaC7keBvDiohhrFtalx1DXB9TPgmLszZrA=; b=Qqngfv1Gs5P6tvrzcnMEsQJF2D5FALPR0ul2qDHBMgag42s3zthYO9VGUadSTiUo78 yuEGfTKXL8hiaFGe/JCkr6QWlpjtmSjxlWh+6xHb+pBdIvKf/E/c2o8QmJbg6hpFRYee qXEwpY36ohlIRCytA9PPmEWQi3j4BlEm4hkDz8VR1XA/wXt8GpW3dkQ2xmtRnO+aXJsT Bjb6EMruiKxkbODTmOaNnZKM/FhqT0sEhCuOZvihz5OmcqxkPDqiFIBldUFZlxSrEr4m OvNNqOvDv5W2Z9qpYJBIFEUQI+AfI+Yjum/niFkNd2fzwaNWGIkm34s8MATuddhW0u79 WLpw== X-Gm-Message-State: AOAM530auxg4Ms4UftFa2ZZ90bQ47AXKdU4MaT7mcGto2p4gNpbImFvL 4EgGH7ZCO+7j2nO5ePwkK/m1Xw== X-Google-Smtp-Source: ABdhPJw9/nkVGUaCF6L4XFEYdzCOxCettpuRg4CZXwXCSjvmtNORVnNbFu6HTgjWfkWiVu1RK/mdLQ== X-Received: by 2002:a62:6845:0:b029:13e:dcd:75bd with SMTP id d66-20020a6268450000b029013e0dcd75bdmr1112623pfc.12.1601324814948; Mon, 28 Sep 2020 13:26:54 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id bx18sm2214323pjb.6.2020.09.28.13.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 13:26:53 -0700 (PDT) From: Kees Cook To: Shuah Khan Cc: Kees Cook , Hangbin Liu , Naresh Kamboju , Jonathan Corbet , linux-doc@vger.kernel.org, Tim.Bird@sony.com, lkft-triage@lists.linaro.org, Anders Roxell , Justin Cook , Linux-Next Mailing List , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 2/3] selftests/run_kselftest.sh: Make each test individually selectable Date: Mon, 28 Sep 2020 13:26:49 -0700 Message-Id: <20200928202650.2530280-3-keescook@chromium.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200928202650.2530280-1-keescook@chromium.org> References: <20200928202650.2530280-1-keescook@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Currently with run_kselftest.sh there is no way to choose which test we could run. All the tests listed in kselftest-list.txt are all run every time. This patch enhanced the run_kselftest.sh to make the test collections (or tests) individually selectable. e.g.: $ ./run_kselftest.sh -c seccomp -t timers:posix_timers -t timers:nanosleep Additionally adds a way to list all known tests with "-l", usage with "-h", and perform a dry run without running tests with "-n". Co-developed-by: Hangbin Liu Signed-off-by: Hangbin Liu Signed-off-by: Kees Cook Tested-by: Naresh Kamboju --- tools/testing/selftests/run_kselftest.sh | 77 ++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/run_kselftest.sh b/tools/testing/selftests/run_kselftest.sh index 8b0ad4766d78..609a4ef9300e 100755 --- a/tools/testing/selftests/run_kselftest.sh +++ b/tools/testing/selftests/run_kselftest.sh @@ -8,21 +8,86 @@ cd $BASE_DIR TESTS="$BASE_DIR"/kselftest-list.txt if [ ! -r "$TESTS" ] ; then echo "$0: Could not find list of tests to run ($TESTS)" >&2 - exit 1 + available="" +else + available="$(cat "$TESTS")" fi -available="$(cat "$TESTS")" . ./kselftest/runner.sh ROOT=$PWD -if [ "$1" = "--summary" ] ; then - logfile="$BASE_DIR"/output.log - cat /dev/null > $logfile +usage() +{ + cat < $logfile + shift ;; + -t | --test) + TESTS="$TESTS $2" + shift 2 ;; + -c | --collection) + COLLECTIONS="$COLLECTIONS $2" + shift 2 ;; + -l | --list) + echo "$available" + exit 0 ;; + -n | --dry-run) + dryrun="echo" + shift ;; + -h | --help) + usage 0 ;; + "") + break ;; + *) + usage 1 ;; + esac +done + +# Add all selected collections to the explicit test list. +if [ -n "$COLLECTIONS" ]; then + for collection in $COLLECTIONS ; do + found="$(echo "$available" | grep "^$collection:")" + if [ -z "$found" ] ; then + echo "No such collection '$collection'" >&2 + exit 1 + fi + TESTS="$TESTS $found" + done +fi +# Replace available test list with explicitly selected tests. +if [ -n "$TESTS" ]; then + valid="" + for test in $TESTS ; do + found="$(echo "$available" | grep "^${test}$")" + if [ -z "$found" ] ; then + echo "No such test '$test'" >&2 + exit 1 + fi + valid="$valid $found" + done + available="$(echo "$valid" | sed -e 's/ /\n/g')" fi collections=$(echo "$available" | cut -d: -f1 | uniq) for collection in $collections ; do [ -w /dev/kmsg ] && echo "kselftest: Running tests in $collection" >> /dev/kmsg tests=$(echo "$available" | grep "^$collection:" | cut -d: -f2) - (cd "$collection" && run_many $tests) + ($dryrun cd "$collection" && $dryrun run_many $tests) done From patchwork Mon Sep 28 20:26:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 11804625 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80D3992C for ; Mon, 28 Sep 2020 20:27:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 54106207E8 for ; Mon, 28 Sep 2020 20:27:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="jzjFbeQC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726880AbgI1U1A (ORCPT ); Mon, 28 Sep 2020 16:27:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726871AbgI1U05 (ORCPT ); Mon, 28 Sep 2020 16:26:57 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C348C0613D5 for ; Mon, 28 Sep 2020 13:26:56 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id a9so1377855pjg.1 for ; Mon, 28 Sep 2020 13:26:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=84Wkm7II+zR8a1S1XbEc0SAaLAitSu9by2LK3K8LLZY=; b=jzjFbeQC0BOwC59BlIVN2ZD9Bjg+kpxXoCamP3rbFMeNXlT5A44rhrBi1/hP2VR/2N Yz4xMvTvF/IVCMTawSARPCrWJFAyxjqHWONLjXci0pBwHhpp+qK7flV9anmFW0vYRW97 kRVlk0d7tppB+g7b5R7BN30fkEEi2ATsg6ztU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=84Wkm7II+zR8a1S1XbEc0SAaLAitSu9by2LK3K8LLZY=; b=gTKsTmBYpfthIjDJ++tiWSSkHflY2tOw74PCZdmkIVQrVYUTk923g57aua+ldnEdcZ 1VlX6UyuTcvZ6jrlxP0clasIjl+bRRgvZzgK01nzECgmAa7WioBbIa5VoiBlx5wAnp7M UghVzS3hl0s648+Q7CbnEsurt2I0IW8EDMhj20IFpgQopSfPlvnBo/CJtqP8GtqhbTbj 41bxtT172xGPSNZAsf7xF+NdmMUCFScFocSfX/SPKFmhV8xfaOq0me2Hl/KbLsLoDbEO Y1SQR3g5IgRvAy5AiSdNV2tH11+dGW2wHbns0dPt6Dt6QQD8je2I+qDFCFvaMK6Rkix0 ajjw== X-Gm-Message-State: AOAM533KiArREj47zoqAWM8MDzNApRKXbVoWvd37/XO3L3ZmuEDjwUF9 PpV+7V1KxXVOoVZqsnE13IHD5A== X-Google-Smtp-Source: ABdhPJzunOfjF8LprL3XY61w3FvvpSkqtHIqXlVfnXXgRC88QVU+My/W354njw01Dr7RLCEJWbZv+Q== X-Received: by 2002:a17:90a:e38a:: with SMTP id b10mr817027pjz.17.1601324815742; Mon, 28 Sep 2020 13:26:55 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id s16sm2107828pgl.78.2020.09.28.13.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 13:26:53 -0700 (PDT) From: Kees Cook To: Shuah Khan Cc: Kees Cook , Naresh Kamboju , Hangbin Liu , Jonathan Corbet , linux-doc@vger.kernel.org, Tim.Bird@sony.com, lkft-triage@lists.linaro.org, Anders Roxell , Justin Cook , Linux-Next Mailing List , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 3/3] doc: dev-tools: kselftest.rst: Update examples and paths Date: Mon, 28 Sep 2020 13:26:50 -0700 Message-Id: <20200928202650.2530280-4-keescook@chromium.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200928202650.2530280-1-keescook@chromium.org> References: <20200928202650.2530280-1-keescook@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Update the installation commands and path details, detail the new options available in the run_kselftests.sh script. Signed-off-by: Kees Cook Reviewed-by: Naresh Kamboju --- Documentation/dev-tools/kselftest.rst | 35 +++++++++++++++++---------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/Documentation/dev-tools/kselftest.rst b/Documentation/dev-tools/kselftest.rst index 469d115a95f1..a901def730d9 100644 --- a/Documentation/dev-tools/kselftest.rst +++ b/Documentation/dev-tools/kselftest.rst @@ -125,32 +125,41 @@ Note that some tests will require root privileges. Install selftests ================= -You can use the kselftest_install.sh tool to install selftests in the -default location, which is tools/testing/selftests/kselftest, or in a -user specified location. +You can use the "install" target of "make" (which calls the `kselftest_install.sh` +tool) to install selftests in the default location (`tools/testing/selftests/kselftest_install`), +or in a user specified location via the `INSTALL_PATH` "make" variable. To install selftests in default location:: - $ cd tools/testing/selftests - $ ./kselftest_install.sh + $ make -C tools/testing/selftests install To install selftests in a user specified location:: - $ cd tools/testing/selftests - $ ./kselftest_install.sh install_dir + $ make -C tools/testing/selftests install INSTALL_PATH=/some/other/path Running installed selftests =========================== -Kselftest install as well as the Kselftest tarball provide a script -named "run_kselftest.sh" to run the tests. +Found in the install directory, as well as in the Kselftest tarball, +is a script named `run_kselftest.sh` to run the tests. You can simply do the following to run the installed Kselftests. Please note some tests will require root privileges:: - $ cd kselftest + $ cd kselftest_install $ ./run_kselftest.sh +To see the list of available tests, the `-l` option can be used:: + + $ ./run_kselftest.sh -l + +The `-c` option can be used to run all the tests from a test collection, or +the `-t` option for specific single tests. Either can be used multiple times:: + + $ ./run_kselftest.sh -c bpf -c seccomp -t timers:posix_timers -t timer:nanosleep + +For other features see the script usage output, seen with the `-h` option. + Packaging selftests =================== @@ -160,9 +169,9 @@ different system. To package selftests, run:: $ make -C tools/testing/selftests gen_tar This generates a tarball in the `INSTALL_PATH/kselftest-packages` directory. By -default, `.gz` format is used. The tar format can be overridden by specifying -a `FORMAT` make variable. Any value recognized by `tar's auto-compress`_ option -is supported, such as:: +default, `.gz` format is used. The tar compression format can be overridden by +specifying a `FORMAT` make variable. Any value recognized by `tar's auto-compress`_ +option is supported, such as:: $ make -C tools/testing/selftests gen_tar FORMAT=.xz