From nobody Thu Apr 2 23:55:45 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC5A0410D38; Mon, 2 Mar 2026 14:13:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772460827; cv=none; b=jm3S7zJc32EJrN8Ix+Sk0hZ8uLGtNKeJ+Q0liURsmhADtKaO1xG1125TSmvf+aux7UCMqvSAjm1DlB5+AoK1UrwcX4v/g4wOmVlzXHIQ5a/uhJycDjVJXvZ32/fYBTXKHPBqObwcfZnu96lzK7DzDLBzo21FdUgFm9zsNrNQ9d8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772460827; c=relaxed/simple; bh=u8EUg0ZyQmSus3QNbAm2GZpaSK9u1dOI00AgCVKP5EM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Jk/tNDczH+eIkiIGrZtcEC25nzynx5OqWgwOmMwaKu+Lm9lT5kVZuutrikeaG48iATnZL420YmwGRmJzvYmdbi1hfhg9PLOXIDZONbnVWyxP8E9SMrgbFL7YcaI/3VCDfZcmGnvKSIi5wfS8Mz0xt+jc3LSS3dPTSpWNzJM/ED8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=FcoOC2CV; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=0Tv5IvqX; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="FcoOC2CV"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0Tv5IvqX" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1772460824; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DENFRSmvUruhh7sXW/NRQgaI5tyD0A/XM0dVW35m5wI=; b=FcoOC2CVX0+VLAczxAtyQJXBdVRFcCIEx2yQHLpF9PVaWRZdaYFcaHQaya1Ob1P09TNaz6 /uRVGsRlA71sgO/W2HT/Dq+FiH9LUK0DXBMcOTkK+zKQUkgLyZZao4F0wKH4yAwrxBBX92 emNpQkufUnqjlndV/+7P8jM0+6jdewHidV8tdQtF26e1cVfYQumP7V+0yejEBcI2FbgVdG ObyxNz5Clr6X9hymbxfIpafzJZ4oNBCYOBBCN+KDD7ZJ7D291a2a7oSbDI1XVQUhMBOLrI IcPICD+PLqkJ4gFeZgQAAZphyAkW+2EDxKCK8Gej4o0ci1So2jzkB1KQjRrdsA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1772460824; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DENFRSmvUruhh7sXW/NRQgaI5tyD0A/XM0dVW35m5wI=; b=0Tv5IvqXpCLDWZ0lvzuMNiotl7Quzu3ueFrV6/hTWEtEUBvBV0Lnus2GnBiAKIwUN+zCrL eB71SiD5yWkcmlBg== Date: Mon, 02 Mar 2026 15:13:28 +0100 Subject: [PATCH v2 1/5] selftests: kselftest: Treat xpass as successful result Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260302-kselftest-harness-v2-1-3143aa41d989@linutronix.de> References: <20260302-kselftest-harness-v2-0-3143aa41d989@linutronix.de> In-Reply-To: <20260302-kselftest-harness-v2-0-3143aa41d989@linutronix.de> To: Shuah Khan , Kees Cook , Andy Lutomirski , Will Drewry Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1772460823; l=814; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=u8EUg0ZyQmSus3QNbAm2GZpaSK9u1dOI00AgCVKP5EM=; b=8MA4Uz9MF4BNTC69FjxtUUa09KEjCDmtqcPnf/GzjD9EP3ERt7Y8RJx/WeF+Eum8fjxkXvi0w 36+L5Bh2uDuCJ3LFMmU1JcAna/crdwmdiVrEVMr4fludR7NKsS8+FV8 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The harness treats these tests as successful, as does pytest. Align kselftest.h to the rest of the ecosystem. None of the Linux selftests seem to actually use this anyways. Signed-off-by: Thomas Wei=C3=9Fschuh --- tools/testing/selftests/kselftest.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/= kselftest.h index afbcf8412ae5..1e7e73f77fa7 100644 --- a/tools/testing/selftests/kselftest.h +++ b/tools/testing/selftests/kselftest.h @@ -399,6 +399,7 @@ static inline __noreturn void ksft_exit_fail(void) #define ksft_finished() \ ksft_exit(ksft_plan =3D=3D \ ksft_cnt.ksft_pass + \ + ksft_cnt.ksft_xpass + \ ksft_cnt.ksft_xfail + \ ksft_cnt.ksft_xskip) =20 --=20 2.53.0 From nobody Thu Apr 2 23:55:45 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B5D735DA69; Mon, 2 Mar 2026 14:13:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772460828; cv=none; b=fEl9PwVch2xuwMvieUHM7PPWhW4fvFYXi5dJL+248PC/kyQn0bABt/vwa2VA6mENnpNL+DpRoCflwdeRO8TrkApZCogxVsSQVmnGoK3hWSf3dvNUnjWJRC2m8n2c+pJniCwgSSNj0JvrLxclEn7R3WWOV2NgnyJeM3E6wnYCqlk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772460828; c=relaxed/simple; bh=V8vSQHWWb1M8SLJAqKmywsmfnltQp09EHBShvtR+OH0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kdoahQsy/bW4zRmRN+HfGu+V8hoXkaaF72soTwfmhrROF0+wQrW+ERrFUONpSkfvJN3J+1m0zkBoHZaiIQfj7vXVYr4J7hbjbdw9r5qJj0aoI1NMgWNcAAF45EmzJOBh8sGPRcVBYMCMLQiCZqoSNizPROMkAjQZvszLoE+zd6M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=NT8DoQcu; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=b91droY2; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="NT8DoQcu"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="b91droY2" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1772460824; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TL6lzi9gyGFnwY8/4up0lnj+q863MPXXWAHBeqLq8d8=; b=NT8DoQcuoVZDF0li0rbfMhVQfjmuT09XBc1QoUgXLhM+vbXs8swrw7/pxPrf1H/Sf0zTrH vuYe01cAAXbKceZ9eBsAWSC5111vQGwz4nQ/s3sfSkEXpLoeyZ2d1ti/DeJCmBfRyGhaey OPVpVm+jK5BYmCnNlX/gmOwvGP5sQdTjRbZ0fw8kdALAdBEA5UYcZCXvdnUhEnetcJHubU sdIHozTo05ZMw8Pb+NvbZxpHzTFabOBf8CcHBJk362Zj97XtJPavTSFFTZyjmmRZ10Hz8a Nkg7eqt5WMH1GfHocorvk/gYbU1R6G9jk+67uvTolcCD+nA+1lsVKvlX8IEiJw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1772460824; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TL6lzi9gyGFnwY8/4up0lnj+q863MPXXWAHBeqLq8d8=; b=b91droY29SlqjDY43dWLRmTrtZPyQuyGqcDhvTomUGlRWby20EAcrhg8vfrTMWozMAhPNr yaKr8fcgBuLztHAg== Date: Mon, 02 Mar 2026 15:13:29 +0100 Subject: [PATCH v2 2/5] selftests: harness: Validate that explicit kselftest exitcodes are handled Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260302-kselftest-harness-v2-2-3143aa41d989@linutronix.de> References: <20260302-kselftest-harness-v2-0-3143aa41d989@linutronix.de> In-Reply-To: <20260302-kselftest-harness-v2-0-3143aa41d989@linutronix.de> To: Shuah Khan , Kees Cook , Andy Lutomirski , Will Drewry Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1772460823; l=4235; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=V8vSQHWWb1M8SLJAqKmywsmfnltQp09EHBShvtR+OH0=; b=3N1XwY1ThF5bft9/zL2kQsGsQFGCtCy9If84asq3zy7szXAP6JHMJXT5Wf2jLFZkNzwIMe5DG 1XtvqDKuioxBg2oUBrbVYxK+pqW5IzdDHKgP4Oqgbjqg0ARp33bWHuJ X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The test programs can directly call exit with one of the KSFT_* constants. Add tests for this functionality. Signed-off-by: Thomas Wei=C3=9Fschuh --- .../selftests/kselftest_harness/harness-selftest.c | 20 +++++++++++++ .../kselftest_harness/harness-selftest.expected | 35 ++++++++++++++++--= ---- 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/kselftest_harness/harness-selftest.c b= /tools/testing/selftests/kselftest_harness/harness-selftest.c index 7820bb5d0e6d..f109a21ed6f7 100644 --- a/tools/testing/selftests/kselftest_harness/harness-selftest.c +++ b/tools/testing/selftests/kselftest_harness/harness-selftest.c @@ -118,6 +118,26 @@ TEST_F(fixture_setup_failure, pass) { TH_LOG("after"); } =20 +TEST(exit_pass) { + exit(KSFT_PASS); +} + +TEST(exit_xpass) { + exit(KSFT_XPASS); +} + +TEST(exit_fail) { + exit(KSFT_FAIL); +} + +TEST(exit_xfail) { + exit(KSFT_XFAIL); +} + +TEST(exit_skip) { + exit(KSFT_SKIP); +} + int main(int argc, char **argv) { /* diff --git a/tools/testing/selftests/kselftest_harness/harness-selftest.exp= ected b/tools/testing/selftests/kselftest_harness/harness-selftest.expected index 97e1418c1c7e..da7febc11e10 100644 --- a/tools/testing/selftests/kselftest_harness/harness-selftest.expected +++ b/tools/testing/selftests/kselftest_harness/harness-selftest.expected @@ -1,6 +1,6 @@ TAP version 13 -1..9 -# Starting 9 tests from 4 test cases. +1..14 +# Starting 14 tests from 4 test cases. # RUN global.standalone_pass ... # harness-selftest.c:19:standalone_pass:before # harness-selftest.c:23:standalone_pass:after @@ -24,6 +24,22 @@ ok 3 global.signal_pass # signal_fail: Test terminated by assertion # FAIL global.signal_fail not ok 4 global.signal_fail +# RUN global.exit_pass ... +# OK global.exit_pass +ok 5 global.exit_pass +# RUN global.exit_xpass ... +# OK global.exit_xpass +ok 6 global.exit_xpass # XPASS unknown +# RUN global.exit_fail ... +# exit_fail: Test failed +# FAIL global.exit_fail +not ok 7 global.exit_fail +# RUN global.exit_xfail ... +# OK global.exit_xfail +ok 8 global.exit_xfail # XFAIL unknown +# RUN global.exit_skip ... +# OK global.exit_skip +ok 9 global.exit_skip # SKIP unknown # RUN fixture.pass ... # harness-selftest.c:53:pass:setup # harness-selftest.c:62:pass:before @@ -32,7 +48,7 @@ not ok 4 global.signal_fail # harness-selftest.c:66:pass:after # harness-selftest.c:58:pass:teardown same-process=3D1 # OK fixture.pass -ok 5 fixture.pass +ok 10 fixture.pass # RUN fixture.fail ... # harness-selftest.c:53:fail:setup # harness-selftest.c:70:fail:before @@ -40,25 +56,26 @@ ok 5 fixture.pass # harness-selftest.c:58:fail:teardown same-process=3D1 # fail: Test terminated by assertion # FAIL fixture.fail -not ok 6 fixture.fail +not ok 11 fixture.fail # RUN fixture.timeout ... # harness-selftest.c:53:timeout:setup # harness-selftest.c:77:timeout:before # timeout: Test terminated by timeout # FAIL fixture.timeout -not ok 7 fixture.timeout +not ok 12 fixture.timeout # RUN fixture_parent.pass ... # harness-selftest.c:87:pass:setup # harness-selftest.c:96:pass:before # harness-selftest.c:98:pass:after # harness-selftest.c:92:pass:teardown same-process=3D0 # OK fixture_parent.pass -ok 8 fixture_parent.pass +ok 13 fixture_parent.pass # RUN fixture_setup_failure.pass ... # harness-selftest.c:106:pass:setup # harness-selftest.c:108:pass:Expected 0 (0) =3D=3D 1 (1) # pass: Test terminated by assertion # FAIL fixture_setup_failure.pass -not ok 9 fixture_setup_failure.pass -# FAILED: 4 / 9 tests passed. -# Totals: pass:4 fail:5 xfail:0 xpass:0 skip:0 error:0 +not ok 14 fixture_setup_failure.pass +# FAILED: 8 / 14 tests passed. +# 1 skipped test(s) detected. Consider enabling relevant config options to= improve coverage. +# Totals: pass:5 fail:6 xfail:1 xpass:1 skip:1 error:0 --=20 2.53.0 From nobody Thu Apr 2 23:55:45 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAD4E401490; Mon, 2 Mar 2026 14:13:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772460829; cv=none; b=iNDWwV8SGq4EpMYg0+y9vASszveq0te3BUxmvtOqtWjdLUup7VgUipVu7ctXtT+q2WG3QyuoH2teND4JxIh91aQ97Yf7gKbUeOqloj3PPGUqJn2fCkGXDFBzdyfWVgidqyPnQ1Wsafqj5p/wNJ3Zm8qElgJi4f4xzjn5lKZPCwM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772460829; c=relaxed/simple; bh=jnLplW2RSbMejFkZ7e0CfafIL+qcW1ehsMmlyoyXM4A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=O0BoZy/JRej255zMR0tkLFIATtbjiuxR4TXG3SxzITWBtsIJjAs/iaLv04LehLW7flqV1pYdFbHdua7s7xL8OOChNEBK+pycAbzE4RNrlVq92AvaNbnCCXRYvnMxG7WIbh9b8nfyvrf8FcF523GzOPBR+h0rBlJsRWNdWAxOHp4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=twNWq7WY; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=3WyBdQOF; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="twNWq7WY"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="3WyBdQOF" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1772460825; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=amKHRDjcBb059S7pHir3E4X/PvDTUgafXu6Cdhxwago=; b=twNWq7WY3ANYd2tSVtrw+5riukKIyeKuKbSwbyqDdcvPCAyBKUSzZ4gzpSj4xTQBbYiUdn RL4emi4FPtQ1e196nhyo1QsEKvaAcDCAY1xn5ImE+0hoxqbRTVeuqGSYcv/aiu8zdYV4eI u7nfplEI9tv7ymu6CLj0Dg7b20ElqUefBei98zHcO5VIbFm486SFu1l2Wt4TqrF+Ko5ocG LYnhhCezMzApC9gR7ybTwK/gij8VCo19vwrGH3/JrDc+0EWZ8ICJr2BSFhaPl5aHN1yY+j Q6igPdlLQ+SqZtQOSSqUDeyTBLTmAzfXG0VmWm2LAK7jE//dpKWU4mscHx3WpQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1772460825; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=amKHRDjcBb059S7pHir3E4X/PvDTUgafXu6Cdhxwago=; b=3WyBdQOFR5NidypxuvSEa23gN1meVzlnnjsWKS0Vwd8YOSRUkaKLzeT/GskKr/LiOfr/GY t7b0mxz4rxOCchBQ== Date: Mon, 02 Mar 2026 15:13:30 +0100 Subject: [PATCH v2 3/5] selftests: kselftest: Add ksft_reset_state() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260302-kselftest-harness-v2-3-3143aa41d989@linutronix.de> References: <20260302-kselftest-harness-v2-0-3143aa41d989@linutronix.de> In-Reply-To: <20260302-kselftest-harness-v2-0-3143aa41d989@linutronix.de> To: Shuah Khan , Kees Cook , Andy Lutomirski , Will Drewry Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1772460823; l=947; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=jnLplW2RSbMejFkZ7e0CfafIL+qcW1ehsMmlyoyXM4A=; b=t2EeKcEMJ83k8Edj1IH8WXLF6Opdf9G7qjLT2DkIYwhoKyYTOsxqVtBCtoWhNKKWTdZCxdu/w F7CH2BY6hgiB745qDEcTOgkoVA7HIJ7h5+FCS+n6oyfFgqURXvR7yW3 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Add a helper to reset the internal state of the kselftest framework. It will be used by the selftest harness. Signed-off-by: Thomas Wei=C3=9Fschuh --- tools/testing/selftests/kselftest.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/= kselftest.h index 1e7e73f77fa7..6d809f08ab7b 100644 --- a/tools/testing/selftests/kselftest.h +++ b/tools/testing/selftests/kselftest.h @@ -476,4 +476,15 @@ static inline int ksft_min_kernel_version(unsigned int= min_major, return major > min_major || (major =3D=3D min_major && minor >=3D min_min= or); } =20 +static inline void ksft_reset_state(void) +{ + ksft_cnt.ksft_pass =3D 0; + ksft_cnt.ksft_fail =3D 0; + ksft_cnt.ksft_xfail =3D 0; + ksft_cnt.ksft_xpass =3D 0; + ksft_cnt.ksft_xskip =3D 0; + ksft_cnt.ksft_error =3D 0; + ksft_plan =3D 0; +} + #endif /* __KSELFTEST_H */ --=20 2.53.0 From nobody Thu Apr 2 23:55:45 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56348411618; Mon, 2 Mar 2026 14:13:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772460829; cv=none; b=g7Ejp5PGLIB+ew5fSMiJTXSpyX5e1b9Urj/Qkq1bgirW7B7cRbMSDxWuVENM6kV08ffqctYTCE/IosmuE3aSEuypeAAScGPjCTDcmuR++evC9hzZ9o8j5zu64MzOeF7MD7swiAtUdL0VmTrQrv2w5+o1wEOYYQFd2a+F30sT8Ls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772460829; c=relaxed/simple; bh=4MPhmuFauddjecmuhKrvYh9Gq/gX6TMzwOAi+PqtoDU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pztl5zJdRP3UCl2lfjH21fb6Khb4oDy0ZD6+l/Tufr+ILTtuXrcwOEfjj56Z+rEfeJIpVnvGZUssh++mGPWWT73xHTbWzHfQ5IlbZBhDOiKEcS9rzvT6UO2MVUzOu226H8jvAAibNKaRBjnryA2GeXO0MuW1fqFdO3yQ8t5Q8Uo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=J6xAj9bV; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=FTx4rgzz; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="J6xAj9bV"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="FTx4rgzz" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1772460825; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Nz4S9HMfmE/pxBD+ci9S4gKmVV+qW/+XzEZ/axWn09E=; b=J6xAj9bVu/2FB8KXyt5N/T1Q/iTzgB8xjEHT+r13oD+VMcoEiIol8mF7W0WxVJHr0mmr66 7NPyOqqg6/sibpXePHeuxDnITXos0OfHicF/6qeRl6DCvrYeFLY5vcgHN+A73G98EhpYLp mlK3QlslawyC4z2/AsY+RT2wZKef7gLaoDKCV6iuPc+lcwPBJ2mpWjM/KwJgh2taTiKO6y DW38SXMq5Lr+wUfPp8pW8qvpTVemMGgZ/YbEpINcUodGvwydVQ4/6hzbyI6rEdBn385EFw CC0LxSpD/FEacbfsIEkqeUQ6+Qu0XntYyy5a7EYzyA4WnhBZzBWeReg5CXSl2A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1772460825; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Nz4S9HMfmE/pxBD+ci9S4gKmVV+qW/+XzEZ/axWn09E=; b=FTx4rgzz6yZ/No0B/UbUwDHHjgYasMIHTQfuLZ1XsjsnIDWZCVlRaOpQcrVXGKolwixqmw GflE35mWmMeUp0CQ== Date: Mon, 02 Mar 2026 15:13:31 +0100 Subject: [PATCH v2 4/5] selftests: harness: Detect illegal mixing of kselftest and harness functionality Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260302-kselftest-harness-v2-4-3143aa41d989@linutronix.de> References: <20260302-kselftest-harness-v2-0-3143aa41d989@linutronix.de> In-Reply-To: <20260302-kselftest-harness-v2-0-3143aa41d989@linutronix.de> To: Shuah Khan , Kees Cook , Andy Lutomirski , Will Drewry Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Yuwen Chen X-Developer-Signature: v=1; a=ed25519-sha256; t=1772460823; l=1644; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=4MPhmuFauddjecmuhKrvYh9Gq/gX6TMzwOAi+PqtoDU=; b=kxqs1WsNQxLFrWuW8rVCeGF90uHB4kMwr3SzOWuGmIip2nrZq9GbAkwvLNy9Pqo1g9uPgbhhq 1KT0er8qj3wDNp1gFLslPwgAyPJtLsBjd9oo1GL8CVCFH21zQWUYDu7 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Users may accidentally use the kselftest_test_result_*() functions in their harness tests. If ksft_finished() is not used, the results reported in this way are silently ignored. Detect such false-positive cases and fail the test. A more correct test would be to reject *any* usage of the ksft APIs but that would force code churn on users. Correct usages, which do use ksft_finished() will not trigger this validation as the test will exit before it. Reported-by: Yuwen Chen Link: https://lore.kernel.org/lkml/tencent_56D79AF3D23CEFAF882E83A2196EC1F1= 2107@qq.com/ Signed-off-by: Thomas Wei=C3=9Fschuh --- This is intentionally a Link tag over a Closes tag, as the real fix will be to the selftests. --- tools/testing/selftests/kselftest_harness.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/se= lftests/kselftest_harness.h index 16a119a4656c..53e9e3d259dc 100644 --- a/tools/testing/selftests/kselftest_harness.h +++ b/tools/testing/selftests/kselftest_harness.h @@ -1222,7 +1222,16 @@ static void __run_test(struct __fixture_metadata *f, t->exit_code =3D KSFT_FAIL; } else if (child =3D=3D 0) { setpgrp(); + + /* Reset state inherited from the harness */ + ksft_reset_state(); + t->fn(t, variant); + + if (__test_passed(t) && (ksft_get_fail_cnt() || ksft_get_error_cnt())) { + ksft_print_msg("Illegal usage of low-level ksft APIs in harness test\n"= ); + t->exit_code =3D KSFT_FAIL; + } _exit(t->exit_code); } else { t->pid =3D child; --=20 2.53.0 From nobody Thu Apr 2 23:55:45 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 044AD411621; Mon, 2 Mar 2026 14:13:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772460830; cv=none; b=cU4JU03x8fuWvnCBZYjLaoiFx3vC9MvoanKZDgmuA9GQY+UMHDOtmZ01kW1wqoHMyaroX7mAOTV4fRquJjTgGr4tmx3rZfKJ0WRI59iICad8LRj7me3CH/Ic0+GFnkeRiMGE8q5HA0cODWhfEh8n3ASZvLYmKyJ3XiTN2PXpWYE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772460830; c=relaxed/simple; bh=g05FqznE3zdpHqGOXjPvkCdCzJma3wdQtoqnRP/jKME=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fTjQqy7Cy6IXUiEMuROzpdGyrUZrdgx6GdaLzo5OFXxyxYHJCJYOpZvuLJmD8CiGdrM3m20dlEhsjS7oo0UPLgZG7h04clD7bDDIP+/cwtC6AWWy0Sx62drkiDO/BvqxxYBQ8eiRbmQ5yxufcXdUzyakp8zPK/6SxP1u7g5pmfk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=P+PD84Af; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=gYzHYrxC; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="P+PD84Af"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="gYzHYrxC" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1772460826; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NuXfdQA4haBFHKa7g9cFrAB65YJuiAZ/bbopbHPJcO0=; b=P+PD84AfSCRNBT/0pMjKnXGyfCpcAU7YvX4LyPEzwp9VAXkWgqLSDuHRPHee7L3CBrfa3W vB4oU/P2XQPmcpCbrrW13hjlYmCZ0HLRu5MRFANbHWRU0qsPg6P2dL1UrEY/U6zw39y+im l4mCP3ywSK9taNkL1YDezZJpTa5/dWxXENoMvIr6y15ZlGyHucUaK3dtrVvKjRqFu2uOxf T+6hdGzvMqR1LPn2pCdHYQDCzOD++I4YKlKr6vnGvr2PbvaBsQaz+2lPh69CTUDkwGCoBr oULRwtff9iWm4vakimsuit15xZOxzQLQw4kUMfH8h7U8HczT5lZTFpOvebONng== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1772460826; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NuXfdQA4haBFHKa7g9cFrAB65YJuiAZ/bbopbHPJcO0=; b=gYzHYrxCr7Bp5ARNqVwBu2+TQlR+BPapjmGHhGaMuk9qlRhBLmaATkFO7rYML6ahEYlKPO oVnIFXEcTGOkEXAQ== Date: Mon, 02 Mar 2026 15:13:32 +0100 Subject: [PATCH v2 5/5] selftests: harness: Validate intermixing of kselftest and harness functionality Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260302-kselftest-harness-v2-5-3143aa41d989@linutronix.de> References: <20260302-kselftest-harness-v2-0-3143aa41d989@linutronix.de> In-Reply-To: <20260302-kselftest-harness-v2-0-3143aa41d989@linutronix.de> To: Shuah Khan , Kees Cook , Andy Lutomirski , Will Drewry Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1772460823; l=4451; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=g05FqznE3zdpHqGOXjPvkCdCzJma3wdQtoqnRP/jKME=; b=VizR5svCkiM/Y8VT7ywWeicV3QA1fmHIXuvDgQTFH9idOOf/5P2KtPK5sfTK9o2NaoWY0A65o PEb4kfRmv0NCrDN5XItjWhKNrngenwE5DTft4qYvkey9YCWIBNlg8yh X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Make sure that calling ksft_test_result_*() functions from harness tests work as expected. Signed-off-by: Thomas Wei=C3=9Fschuh --- .../selftests/kselftest_harness/harness-selftest.c | 20 +++++++++++++ .../kselftest_harness/harness-selftest.expected | 35 ++++++++++++++++--= ---- 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/kselftest_harness/harness-selftest.c b= /tools/testing/selftests/kselftest_harness/harness-selftest.c index f109a21ed6f7..3e3033d2745a 100644 --- a/tools/testing/selftests/kselftest_harness/harness-selftest.c +++ b/tools/testing/selftests/kselftest_harness/harness-selftest.c @@ -138,6 +138,26 @@ TEST(exit_skip) { exit(KSFT_SKIP); } =20 +TEST(test_result_pass) { + ksft_test_result_pass(""); +} + +TEST(test_result_xpass) { + ksft_test_result_xpass(""); +} + +TEST(test_result_fail) { + ksft_test_result_fail(""); +} + +TEST(test_result_xfail) { + ksft_test_result_xfail(""); +} + +TEST(test_result_skip) { + ksft_test_result_skip(""); +} + int main(int argc, char **argv) { /* diff --git a/tools/testing/selftests/kselftest_harness/harness-selftest.exp= ected b/tools/testing/selftests/kselftest_harness/harness-selftest.expected index da7febc11e10..c0a68ec124f8 100644 --- a/tools/testing/selftests/kselftest_harness/harness-selftest.expected +++ b/tools/testing/selftests/kselftest_harness/harness-selftest.expected @@ -1,6 +1,6 @@ TAP version 13 -1..14 -# Starting 14 tests from 4 test cases. +1..19 +# Starting 19 tests from 4 test cases. # RUN global.standalone_pass ... # harness-selftest.c:19:standalone_pass:before # harness-selftest.c:23:standalone_pass:after @@ -40,6 +40,23 @@ ok 8 global.exit_xfail # XFAIL unknown # RUN global.exit_skip ... # OK global.exit_skip ok 9 global.exit_skip # SKIP unknown +# RUN global.test_result_pass ... +# OK global.test_result_pass +ok 10 global.test_result_pass +# RUN global.test_result_xpass ... +# OK global.test_result_xpass +ok 11 global.test_result_xpass +# RUN global.test_result_fail ... +not ok 1 # Illegal usage of low-level ksft APIs in harness test +# test_result_fail: Test failed +# FAIL global.test_result_fail +not ok 12 global.test_result_fail +# RUN global.test_result_xfail ... +# OK global.test_result_xfail +ok 13 global.test_result_xfail +# RUN global.test_result_skip ... +# OK global.test_result_skip +ok 14 global.test_result_skip # RUN fixture.pass ... # harness-selftest.c:53:pass:setup # harness-selftest.c:62:pass:before @@ -48,7 +65,7 @@ ok 9 global.exit_skip # SKIP unknown # harness-selftest.c:66:pass:after # harness-selftest.c:58:pass:teardown same-process=3D1 # OK fixture.pass -ok 10 fixture.pass +ok 15 fixture.pass # RUN fixture.fail ... # harness-selftest.c:53:fail:setup # harness-selftest.c:70:fail:before @@ -56,26 +73,26 @@ ok 10 fixture.pass # harness-selftest.c:58:fail:teardown same-process=3D1 # fail: Test terminated by assertion # FAIL fixture.fail -not ok 11 fixture.fail +not ok 16 fixture.fail # RUN fixture.timeout ... # harness-selftest.c:53:timeout:setup # harness-selftest.c:77:timeout:before # timeout: Test terminated by timeout # FAIL fixture.timeout -not ok 12 fixture.timeout +not ok 17 fixture.timeout # RUN fixture_parent.pass ... # harness-selftest.c:87:pass:setup # harness-selftest.c:96:pass:before # harness-selftest.c:98:pass:after # harness-selftest.c:92:pass:teardown same-process=3D0 # OK fixture_parent.pass -ok 13 fixture_parent.pass +ok 18 fixture_parent.pass # RUN fixture_setup_failure.pass ... # harness-selftest.c:106:pass:setup # harness-selftest.c:108:pass:Expected 0 (0) =3D=3D 1 (1) # pass: Test terminated by assertion # FAIL fixture_setup_failure.pass -not ok 14 fixture_setup_failure.pass -# FAILED: 8 / 14 tests passed. +not ok 19 fixture_setup_failure.pass +# FAILED: 12 / 19 tests passed. # 1 skipped test(s) detected. Consider enabling relevant config options to= improve coverage. -# Totals: pass:5 fail:6 xfail:1 xpass:1 skip:1 error:0 +# Totals: pass:9 fail:7 xfail:1 xpass:1 skip:1 error:0 --=20 2.53.0