Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1487452pxk; Fri, 25 Sep 2020 16:48:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdKWVZkrT0Ljjfm9PzdlIAP/f0Ya3kUxnVR8YwXXdanS33CxdaRdgpUTWeO8ERCua+r7fC X-Received: by 2002:a17:907:aa9:: with SMTP id bz9mr5009284ejc.421.1601077687494; Fri, 25 Sep 2020 16:48:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601077687; cv=none; d=google.com; s=arc-20160816; b=qA2kRdFQdxw9ABtEdpuxW1VEdPjSbN3BQL5bmNOsqIIb0elZ6upkeUHgiPYPlTZdd+ z8nDxWI9QvUhea19r61ie27ezvQzwlfthMfHl3/XR4SjeUhBNTtb/hpkwb7YoQOZbtO+ sNItdnZDxmH1SvWryuk/+HHHsJId7pfUUt3MHeuTsD1HfM529nCoIKwAujyGpwTELcd8 J/sUuZiSwrD6PyUzWHdA+HKk0h4g30DC/i9upmR5IPwkclbL3sW90l9Z/b9gncf+zyg0 DvZPnk7ckK8WmyaU7gEjb6y/BwrdG5Kbfp1NQzpeUVZbPHJdndoxk2nRotd/14UM+hjd Cq6g== 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=f1jwHVzfZHrVmqikaqf6fuMg9CXwRG2rrwLcl0E/Pb4=; b=tSdMBbqpHnKB1yVejyXiTb7WO8JAs6uhIDQUQJH1jpkb42SQ24WhCk0BVWufaMRDnk kzFZxzbnDRw5LsKpwY5LSOTE80dowxTe6qjl0IHORZzYeG94OC7mjdvifV5gXX9j9a7q st2vZATMncLyoAk6v6tQbz2KxqvpFH1+Pj86mVuDHmpXxVYQn0baTHWbUNewSAhxQBkM nE1t3wQVETLmspE8VpI7O+UKw0YujNzdocJefpRz67ow+WfGne9TloRozYiYm/2yOxgn J9oBeli4SeUVK6+ffsY/WzymNs+5hDO8xsFqMYBPrMn4QiTZGXYM9hy35eu4+oncX6/e +u6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=D3Cu1hB1; 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 n11si3018365edr.118.2020.09.25.16.47.44; Fri, 25 Sep 2020 16:48:07 -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=D3Cu1hB1; 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 S1729444AbgIYXpi (ORCPT + 99 others); Fri, 25 Sep 2020 19:45:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729424AbgIYXph (ORCPT ); Fri, 25 Sep 2020 19:45:37 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD6FEC0613D5 for ; Fri, 25 Sep 2020 16:45:37 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id fa1so283125pjb.0 for ; Fri, 25 Sep 2020 16:45:37 -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=f1jwHVzfZHrVmqikaqf6fuMg9CXwRG2rrwLcl0E/Pb4=; b=D3Cu1hB1m1lprTGmLAyG6xV6ny/FBHq9zXv9pEvu7WhFaxncAb+SrVuCLTeD4Zf3xq FbfynQPNXe70ufCEMGMqt7qt0AlHlEW0BauITWLILYYQKogCVBUPBhCjQUy9cYCksHOS Os/7DZ9Ovw3UDeMuB1PlKY42Dpa8mwL4kVRCk= 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=f1jwHVzfZHrVmqikaqf6fuMg9CXwRG2rrwLcl0E/Pb4=; b=S9JVgimTs8Y3F2dha5Z1Tb6jO6WPfy9CEbt3WJyD5c0GjNVtTCXmlmF528K7FG5PqR 5yVKkPm5QH++qUDoKdE2QPv/KDASuyatHRsaKXlAt72KPZHj0Wr0CdBn6gMaet/8Ead4 81MrRXHQuieKAk4aXP3bAlieZcfxVYS7OH49k1eCztqn+at62gGoa1FzP8+BHeBsQfTM w5TaRkAH/xwpF5RXyMFF8YiNR5kpwztKiEuTL9ejINa0VGVsNt2AXg8gEeVSbjzLQvWW OXckoXSK9fPfhLFTGmHHvvSObFuyn2MdL+ynDM4doZPaYoPmXCreNNyMak5mk/cGi/cR hshA== X-Gm-Message-State: AOAM5305VZmWsLrFhEUnnivCDyzXbMB4wX4ZceN70f020Rs2dQq5bSQp 3fp2JCncQ2PXP++JhExVpc0IBNmCTPjPmiaN X-Received: by 2002:a17:90b:f83:: with SMTP id ft3mr17057pjb.234.1601077537186; Fri, 25 Sep 2020 16:45:37 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id c20sm3660942pfc.209.2020.09.25.16.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Sep 2020 16:45:36 -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 2/2] selftests/run_kselftest.sh: Make each test individually selectable Date: Fri, 25 Sep 2020 16:45:27 -0700 Message-Id: <20200925234527.1885234-3-keescook@chromium.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200925234527.1885234-1-keescook@chromium.org> References: <20200925234527.1885234-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 e07344be28ae..c08089f80e28 100755 --- a/tools/testing/selftests/run_kselftest.sh +++ b/tools/testing/selftests/run_kselftest.sh @@ -4,21 +4,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