Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3292870pxk; Mon, 28 Sep 2020 13:28:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrWkavg7ixwGdn9ET7c/Kb/EaF87qCr+6RK7aXnSM5zHdNAOQbjK8bp7onnjqI62GMiZcR X-Received: by 2002:a17:906:594c:: with SMTP id g12mr501206ejr.347.1601324914775; Mon, 28 Sep 2020 13:28:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601324914; cv=none; d=google.com; s=arc-20160816; b=tPVEsboIIua/wtccZOnwIdCVrtd4DbqS+QnJmjRH5Wph6dokexsT2S8F14coUnBrGT rMQlQlNl6L4xMF+O8So6uGrIzPQGCY0b9j8IMNgJPjXX1lLtls1gSPo/I9XGLeks1HZl gJchaHfAhXXVwN3PbpZSeimO+WFJ5LmhKMaJ4EAePlM9X3LaXTbUPcu4RASV7CS38EdJ vZL2fWF/oVRhjDHecgrdQHD3X5km0njZMA+P3gc6kWJdZuP2KkixMI7cohmKUDzWINHd m3YoCbY2ev3LiXMB00hJ6j2DFq5TNJEaelPzdGE24358rsSEwfb7/YDl1Aq6+5O7W94y e5uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CzRblziNDCaC7keBvDiohhrFtalx1DXB9TPgmLszZrA=; b=uPNGtc3DkmC/51CmNYmEcw9z/9ueW1lUcPK2VRKvrJO6w5ijaQBs6YcMiodSk0lI6J iBvtOV73NJl1ZOuzWMRvzSKWZaprrfmQwUIbN3Dtw4jUYLEByzGcgm754+VFKZ+ZMgqz er4f1BQKRAzRnHJdOPZER8zzgN4WoZRoNKN34zwXxtuysJuQPB2VZk3f7SzBAXCh/E38 RXfq5mq9CekMdr1/eKAU/jGY2J1WLXuoIqQZSoUiLw2uc/HL+tc4eG202BfKPBTKvhkg NGqf3Xv8cVSDqkU7iBb6L3ss1LLqURTt8VXSq17lNSoDp40EUtp4iA0lo57KoEF3m9oe NnHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=e9JuINGP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i11si1493717edl.230.2020.09.28.13.28.12; Mon, 28 Sep 2020 13:28:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=e9JuINGP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726901AbgI1U1F (ORCPT + 99 others); Mon, 28 Sep 2020 16:27:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726868AbgI1U0z (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 71FDDC0613D4 for ; Mon, 28 Sep 2020 13:26:55 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id k8so2209983pfk.2 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=gF1ekJoVwSWzdsTkko0K2EQC9gWCTd/4ScQL9RJ/hqUJdXAMXWqyUINycFwzaXHXxg ++RorhhwZTYMOGavb0pKv7Xpabr58T79KaE+BW36vON3CvEU3ApF7IcD1Du1PsnEFUCP UH4iiBxcfOLbUeEazP3RHvWyLYXP2G4Q0GN4/lP227bVoRvJryA53nwOBvqjCjbTehuY 6LO7lwjGbUA+l7sPEPR2BylEszdRGJeyy5WyQv7i2Xm+IYwRp71wnha6TdoS7TnHEby4 CkHbPiNuub//jtNyqV548BGEBF5dZK6TIXS2xTdFP0nBitEw88YN1I9j4ubrE4/cbW73 j8qg== X-Gm-Message-State: AOAM533yN0M9lpT7K7KLSWWJwz411mKnYM6GBASi2OegsRyRRlPt9UZC 7IrErA8Vw3NVO+8ivg9HXgSovQ== 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- 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 -- 2.25.1