From nobody Tue Apr 28 22:07:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6144AC433EF for ; Fri, 27 May 2022 16:24:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351994AbiE0QY2 (ORCPT ); Fri, 27 May 2022 12:24:28 -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: quoted-printable 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_o= ne(): allow running non-executable files Signed-off-by: Micka=C3=ABl Sala=C3=BCn Link: https://lore.kernel.org/r/20220527162417.2646998-1-mic@digikod.net Reported-by: kernel test robot --- 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/se= lftests/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=3D"$1" TEST=3D"$2" NUM=3D"$3" + local rc=3D1 + local ret=3D1 =20 BASENAME_TEST=3D$(basename $TEST) =20 @@ -107,29 +109,36 @@ run_one() cmd=3D"$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=3D$?; \ - 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 secon= ds" + (read xs; exit $xs)) 4>>"$logfile"; then + echo "ok $test_num $TEST_HDR_MSG" + ret=3D0 else - echo "not ok $test_num $TEST_HDR_MSG # exit=3D$rc" - fi) + rc=3D$? + if [ $rc -eq $skip_rc ]; then + echo "ok $test_num $TEST_HDR_MSG # SKIP" + ret=3D0 + elif [ $rc -eq $timeout_rc ]; then + echo "#" + echo "not ok $test_num $TEST_HDR_MSG # TIMEOUT $kselftest_timeout seco= nds" + else + echo "not ok $test_num $TEST_HDR_MSG # exit=3D$rc" + fi + fi cd - >/dev/null fi + return $ret } =20 run_many() { + local ret=3D0 + echo "TAP version 13" DIR=3D"${PWD#${BASE_DIR}/}" test_num=3D0 @@ -142,6 +151,7 @@ run_many() logfile=3D"/tmp/$BASENAME_TEST" cat /dev/null > "$logfile" fi - run_one "$DIR" "$TEST" "$test_num" + run_one "$DIR" "$TEST" "$test_num" || ret=3D1 done + return $ret } diff --git a/tools/testing/selftests/run_kselftest.sh b/tools/testing/selft= ests/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=3D"$(echo "$valid" | sed -e 's/ /\n/g')" fi =20 +ret=3D0 collections=3D$(echo "$available" | cut -d: -f1 | uniq) for collection in $collections ; do [ -w /dev/kmsg ] && echo "kselftest: Running tests in $collection" >> /de= v/kmsg tests=3D$(echo "$available" | grep "^$collection:" | cut -d: -f2) - ($dryrun cd "$collection" && $dryrun run_many $tests) + ($dryrun cd "$collection" && $dryrun run_many $tests) || ret=3D1 done +exit $ret base-commit: 7e284070abe53d448517b80493863595af4ab5f0 --=20 2.36.0