Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2412926ioo; Sat, 28 May 2022 12:49:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJza32qKxgG+p94wibyVWGUWzt3iO7BOGSaj8ckWUou2iEz+s+uN+Uw+bmk/t/FgPxPb8HW1 X-Received: by 2002:a05:6a00:2281:b0:518:cfd2:5020 with SMTP id f1-20020a056a00228100b00518cfd25020mr23387513pfe.20.1653767353851; Sat, 28 May 2022 12:49:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653767353; cv=none; d=google.com; s=arc-20160816; b=IGn2P1bwz2FqMnwsHg5nhZFZFvtVZFwg71lP5PRlg4K6U7KfTmeDPNVazRdfjA2Mz3 1WKd15XdqXlWUTlwbz/Tx5RGSuc/mrBhH473QEM/wNajybxIwlEhyQqDCu79BN5hgK6Q J3KHWv+W78lR0puo3Ff0JAHTGNa+9GGIQ4jXw3PgePSoYS5gB3Gs0/XA19+SYa2Rxy50 HdoG5qLzQCby3WmAvZ7WkRa5HKRCdklTtWwWD8WY01mrz24QY7HQBH4bzdCUWB9wRzdy A1R5PxixERaSOEq+1NLf5C4AwVVtIsDF3GDN/2iN8BqViQgknHk3vEr29BpX+ahUgh7I gDqw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=DdBVtflAjGSj9Cb/w5MhkSQLJon6E1/XzpE2dRU0pXQ=; b=c5+tCXPHaXNPb3SboD7SpX97ADsSftzsj7oA0PYQNyeXa/rTRz+qOxWcytL+Y44Jdw aSD3CYC+ghlEeOtRLrnm+nPOWgjIr1pMw11iV/bnD7ZcR3JryH9ngdRA7tM+DBvClGIE eiPwaFHhOfNR650xoxzapadxa6yM1Z2yEJIbtSz+x+Flp6dSjXtRdJj88ni4a3dkxeaC aHO3MxbnyoNFa9JK4rBUNmiAJVuHFKsDLFJq2yec/lJoyHrLEmD16nZvl7IsG5TyyPXU 2b51NMa8f2jYncN1lPOi1obxm+MWrK9OWeKc1th9M1bBYqEEbzMATF1YzjLkp7ZUbVkK iL8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=JGyyRu51; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i5-20020a17090ad34500b001e070f1ddabsi6670576pjx.65.2022.05.28.12.49.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 12:49:13 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=JGyyRu51; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 947946C561; Sat, 28 May 2022 12:10:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349471AbiE0QY1 (ORCPT + 99 others); Fri, 27 May 2022 12:24:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232903AbiE0QYZ (ORCPT ); Fri, 27 May 2022 12:24:25 -0400 Received: from smtp-8fa9.mail.infomaniak.ch (smtp-8fa9.mail.infomaniak.ch [IPv6:2001:1600:3:17::8fa9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E16549F84 for ; Fri, 27 May 2022 09:24:22 -0700 (PDT) Received: from smtp-3-0001.mail.infomaniak.ch (unknown [10.4.36.108]) by smtp-2-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4L8qrN1bZvzMqWbp; Fri, 27 May 2022 18:24:20 +0200 (CEST) Received: from localhost (unknown [23.97.221.149]) by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4L8qrM6RHTzlhMbr; Fri, 27 May 2022 18:24:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1653668660; bh=hXEP0YV2tisSrUNLHisVWLIXyHgN/uN/8A9Zrhkd+Qo=; h=From:To:Cc:Subject:Date:From; b=JGyyRu51rIh96WccpOaxrreJkOdxxHA2C8UA6k1Jl+ZtYxoVcIG1Pu2CSiNyhi0+Q oFCGhWcc4IHI7q+muj7hUOtTo/06pPc6QG5Updu+mRPTVjIS+X3sD51MVw+4DZYd9o thYPSzk6yLgmjInePR3S8H+VHg3/QEv/LIKqri9E= From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: Shuah Khan Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Greg Kroah-Hartman , SeongJae Park , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v1] selftests/kselftest: Make failed tests exit with 1 Date: Fri, 27 May 2022 18:24:17 +0200 Message-Id: <20220527162417.2646998-1-mic@digikod.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To check that tests are passing we must parse the kselftest runner output. It is much more convenient to check the return value of the runner instead: 0 is OK, and 1 implies one or more errors. This has an impact on the kselftest's gen_tar bundle and the run_tests make target. Backporting this change would be useful to consistently test older kernels as well. Cc: Greg Kroah-Hartman Cc: SeongJae Park Cc: Shuah Khan Cc: stable@vger.kernel.org # 303f8e2d0200: selftests/kselftest/runner/run_one(): allow running non-executable files Signed-off-by: Mickaël Salaün Link: https://lore.kernel.org/r/20220527162417.2646998-1-mic@digikod.net --- tools/testing/selftests/kselftest/runner.sh | 36 +++++++++++++-------- tools/testing/selftests/run_kselftest.sh | 4 ++- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh index 294619ade49f..f6488a53a78c 100644 --- a/tools/testing/selftests/kselftest/runner.sh +++ b/tools/testing/selftests/kselftest/runner.sh @@ -46,6 +46,8 @@ run_one() DIR="$1" TEST="$2" NUM="$3" + local rc=1 + local ret=1 BASENAME_TEST=$(basename $TEST) @@ -107,29 +109,36 @@ run_one() cmd="$interpreter ./$BASENAME_TEST" else echo "not ok $test_num $TEST_HDR_MSG" - return + return 1 fi fi cd `dirname $TEST` > /dev/null - ((((( tap_timeout "$cmd" 2>&1; echo $? >&3) | + if (((( tap_timeout "$cmd" 2>&1; echo $? >&3) | tap_prefix >&4) 3>&1) | - (read xs; exit $xs)) 4>>"$logfile" && - echo "ok $test_num $TEST_HDR_MSG") || - (rc=$?; \ - if [ $rc -eq $skip_rc ]; then \ - echo "ok $test_num $TEST_HDR_MSG # SKIP" - elif [ $rc -eq $timeout_rc ]; then \ - echo "#" - echo "not ok $test_num $TEST_HDR_MSG # TIMEOUT $kselftest_timeout seconds" + (read xs; exit $xs)) 4>>"$logfile"; then + echo "ok $test_num $TEST_HDR_MSG" + ret=0 else - echo "not ok $test_num $TEST_HDR_MSG # exit=$rc" - fi) + rc=$? + if [ $rc -eq $skip_rc ]; then + echo "ok $test_num $TEST_HDR_MSG # SKIP" + ret=0 + elif [ $rc -eq $timeout_rc ]; then + echo "#" + echo "not ok $test_num $TEST_HDR_MSG # TIMEOUT $kselftest_timeout seconds" + else + echo "not ok $test_num $TEST_HDR_MSG # exit=$rc" + fi + fi cd - >/dev/null fi + return $ret } run_many() { + local ret=0 + echo "TAP version 13" DIR="${PWD#${BASE_DIR}/}" test_num=0 @@ -142,6 +151,7 @@ run_many() logfile="/tmp/$BASENAME_TEST" cat /dev/null > "$logfile" fi - run_one "$DIR" "$TEST" "$test_num" + run_one "$DIR" "$TEST" "$test_num" || ret=1 done + return $ret } diff --git a/tools/testing/selftests/run_kselftest.sh b/tools/testing/selftests/run_kselftest.sh index 97165a83df63..6164314f837e 100755 --- a/tools/testing/selftests/run_kselftest.sh +++ b/tools/testing/selftests/run_kselftest.sh @@ -85,9 +85,11 @@ if [ -n "$TESTS" ]; then available="$(echo "$valid" | sed -e 's/ /\n/g')" fi +ret=0 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) - ($dryrun cd "$collection" && $dryrun run_many $tests) + ($dryrun cd "$collection" && $dryrun run_many $tests) || ret=1 done +exit $ret base-commit: 7e284070abe53d448517b80493863595af4ab5f0 -- 2.36.0