From nobody Sat Feb 7 05:53:13 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 7A4332FD697; Wed, 28 Jan 2026 10:24:38 +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=1769595879; cv=none; b=IKAOcCIfiCiPdAfgStgtyz3vuLmHflxTrCFGIyQKHV7D5CgEOvA0QCySy6g4RAqlrGbv2OXXAGR+et7hRhEeB6LrkVZt/atxT3NoeFhzwrjJQzFAQDFugFJ31z/lhUGv5ZukQyM3dVVjwp3w50vMtpyDhdP/PY+OmRDdlH+uizs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769595879; c=relaxed/simple; bh=e48bmD7vgHTOz8cT191AtlkutcsNg4yWKs+H2Snws1I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Lwvw5f9Qtb3VoaxOrnIrvWgLihNOSJnP4Mq2olIjUNQ8BYpiTidPpK2YxLoLTQapTx2jZQ/idqaLiIgl4RUPerMT2Q4v+Y4sOilIKZihEH42kthk2v9asz+gv8lC1OEcITMbph4WCu/OyvI7YA4YNKpLlFrUPElD/SlxurYdMII= 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=WlNvCih2; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=cc6db/d4; 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="WlNvCih2"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="cc6db/d4" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1769595877; 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=LbuNG7HvvntG2agb1VQphZS+Ig7+gNzZe5U3c7IxW1w=; b=WlNvCih2Zvgvp8B1MM27L4Gbdp9J3IDAWFerWgYsuiaCeulic+P9a5ohaEn08HC7x/7T1I MlQWFsQhVtxlU58lS0JVOH/rc12SGtHSqCrr4MnB79+KYsu/rTcEjGC/kzEbmHQHRPd6dh xUeiToM62dNYqVIkPx8xornf1jcYjt9vi2aV8vyu4LCzOQODXrSuV8aG64WZ1B68wtveWC eD2gA9cRP2giLiVkhAc2HewcStaalNzt+m9l/n4qGpe0hOAN9MRnODtwN8VltujtYSOe1F 358uTqY0VkztlQmx4qmNpBqempKxzEMUKOfdxjMz4Xp6FLTm0NGnYLeACsXRkg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1769595877; 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=LbuNG7HvvntG2agb1VQphZS+Ig7+gNzZe5U3c7IxW1w=; b=cc6db/d4U5i4eepEJsjn7IwwSKVJ7H1sQYqt060IHGsn/5SrT9in0ekq5VJhA9zMCdG4cu 8Lvmj9hFw/lAO8CQ== Date: Wed, 28 Jan 2026 11:24:33 +0100 Subject: [PATCH 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: <20260128-kselftest-harness-v1-1-cb259fa81cd0@linutronix.de> References: <20260128-kselftest-harness-v1-0-cb259fa81cd0@linutronix.de> In-Reply-To: <20260128-kselftest-harness-v1-0-cb259fa81cd0@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=1769595876; l=814; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=e48bmD7vgHTOz8cT191AtlkutcsNg4yWKs+H2Snws1I=; b=CxlD1hjoyAhEcwPCqLai/Kd3Bz1z/BKtws8KMm/RRtJF4d27dE1pp0SAJiCT95BulhJK/gFRZ mrceRNXivr4BGCKCrqv8M0FjQqgWRVgE0x/Omb6JQlAdXUYgbmj1SJK 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.52.0 From nobody Sat Feb 7 05:53:13 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 EA51C2E9ED8; Wed, 28 Jan 2026 10:24:38 +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=1769595880; cv=none; b=ED3AC+LnRy5Zz+8sr6n3iCT7YfvKzfkNozDKHf8Fcfxy/kKTZU5t8+u5PYbvJiprPUlkyI5QOtXLnGPBqZbT3JPlfdmTFTuwx0MPCmo1Sk9W/P2B2AzG38pH3ferDc/+ThwUZu6hPIMKfOGKjGxUJyqXHehCVQfkVqiXwZuiSQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769595880; c=relaxed/simple; bh=HRNu4z8w8EZPbzRq85FQ5ZWuqXq4wsKth+f/gjHccvs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tX2YtTO++QcVoe6OtvCnMf623rY5dGZ2q5EPEVdoqlkSwx2iX2Dd72Zv1gjAEInVvkLkNSPMeejLlf3z5cU9amR3ES/gdRuofLXA7R0Yl1DBalW4/kXJSZHxIUvo9CBZx8Okx8DWZCRnjMOC4Gld4pYXf/7PZF3WRcdLuErEX24= 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=ncQGpBOW; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=736+CxVq; 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="ncQGpBOW"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="736+CxVq" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1769595877; 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=JppsLuxHY2cBj9oDPbgokEIBtBEhc7Ey8FlaBKNqWlA=; b=ncQGpBOWkSOJFF2CQAnYaWHyUHrInWGPR36H2rN+YSC9D8agFw5MS31uJ9mIjlEA85eMH/ 6Cguv51aJQQ0+izGiNMEAjXBbiPrLS3Z5xkyGkrXGEBZOoELLMGNfg6SWaP6TCj9EevR4w YDXdKakEui7C+vpAO8DcWX7+PljHEqjgDGzyKFao9O5WC7Z/doXPv1muziJZBweaWvQUPN I/J4ZAGMrKQf4G8Qf3ImO+uGR4SX1OCA+SJWoE1QsMYFE5CaOKeZS6uCaggHjlFs241EKy qt4pXhbH5H0FCRV16gFJUmDxtItYGh8LeA2BDdkXYvXOB0ahs4+RUYC+qNXsvw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1769595877; 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=JppsLuxHY2cBj9oDPbgokEIBtBEhc7Ey8FlaBKNqWlA=; b=736+CxVqmTMnOgHidwPS9ygOv2Xd0Pcz92WkctgEDc/NHwuwDZTueD+zXQVKFIxKp+7Hmd ZuOzZdxxcdx6BzAA== Date: Wed, 28 Jan 2026 11:24:34 +0100 Subject: [PATCH 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: <20260128-kselftest-harness-v1-2-cb259fa81cd0@linutronix.de> References: <20260128-kselftest-harness-v1-0-cb259fa81cd0@linutronix.de> In-Reply-To: <20260128-kselftest-harness-v1-0-cb259fa81cd0@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=1769595876; l=4235; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=HRNu4z8w8EZPbzRq85FQ5ZWuqXq4wsKth+f/gjHccvs=; b=9su08gX4c9r5oNm46sQk8RYSMJIi+o4ZytFAZH3fZ8Ha9PmVTEpCFKzw0veAGy6FfO+mEQ9va nOueV4tkvhWAID+S2XxuUEVo02XRCjp498KSezdxawMsdQF7LIWC3/f 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.52.0 From nobody Sat Feb 7 05:53:13 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 788E52E8B6B; Wed, 28 Jan 2026 10:24:39 +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=1769595880; cv=none; b=o5yMW1fPtEkGcqbBsnpVmyCqIuVM345zChMcUFa1vOl5hCr7+2fofHMt/a0NMTA+YDUJPtot5AJNBwvijuL1kuYmtZtT5P4f3takkax8Q+5RYy5nIc93N11du8q0yQ8swV0e3Goz1dBaR+RvWUCYCmCPWNgoj+0o38tub19Ki5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769595880; c=relaxed/simple; bh=4ZP43tZBP/y5Yypr+B35Tkwkx6rebvs59GV2Y/mc/oY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fNAeT4mmIt+WhHTtOxG8NzWcjya6SWBShEPS8fwnM9SeEJAHUvBzOSgzMdqFjb44rzdtC5oMyAX0zSXtxNSdhDdsQSnVwakBr/g/y8koP86fNcsr9tFroo/AjWSRzW1ypmwn0Ak7d5/FYZs+/jzfZE7hAokDvQjJGpDsflOvwy0= 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=z3KMfhLn; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=AR67r/rL; 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="z3KMfhLn"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="AR67r/rL" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1769595878; 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=2SATdtGSdXWpcc4Jp34tPsqDMd+6GlgQIVHuGtJoCT0=; b=z3KMfhLn+cQ//qgy2hjduXRJcp3RLy0Az4WP1kqQgHmkUre1nM5m+Q67DRC/ilmrkZj0yw 5BVQjOGemM+QdDpRgwZsHXcOLuq83/zi/yPLOyL04WkyUh3yDDZ/XD926eD3ZphfN+kpF6 onemXA617PB+bzASEO9P9YTk64coebzegd/V2hm8IdlpSuEDUK51sDJ7ICx/Vb5PVtXe7o mIFW3WZLPQKN0+jDMygtq/BgQ+GmrQWC3MJZH4v5ttalVQwXPqLVI0LiWMX3fqa2m1jyhs J2wiYaCymojGIIBqCxOMUBiRMQVUF/KQKUuEClM1Yjkc0EvPv1ungwa+kGngdg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1769595878; 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=2SATdtGSdXWpcc4Jp34tPsqDMd+6GlgQIVHuGtJoCT0=; b=AR67r/rLLYVtQAXvmPMGnGos+5r27gE8UTd28HP63knqWuwl8xL10amlj0TGOEg+4ypU9c /zjwGx8qizJqolBg== Date: Wed, 28 Jan 2026 11:24:35 +0100 Subject: [PATCH 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: <20260128-kselftest-harness-v1-3-cb259fa81cd0@linutronix.de> References: <20260128-kselftest-harness-v1-0-cb259fa81cd0@linutronix.de> In-Reply-To: <20260128-kselftest-harness-v1-0-cb259fa81cd0@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=1769595876; l=948; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=4ZP43tZBP/y5Yypr+B35Tkwkx6rebvs59GV2Y/mc/oY=; b=kqapdEEqQYE+DbVelXPSl3LOIGh3diiACKBB/m9KMAsPHMoL027PHGNThykwY8F2C5u7Su8Jy IWfeQKtl0ZKD1CYixoSqPQHRF3Lc7nYLFbwKDnhzZyPtpi+hzH9N30g 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..7979d6904ac6 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.52.0 From nobody Sat Feb 7 05:53:13 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 430033009ED; Wed, 28 Jan 2026 10:24:40 +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=1769595881; cv=none; b=N1rTs/HDz3FcCy2vphk9cugwtYORryFooITkMkQmDRN7NKn0nsLTuBxPbw3QPFD5Wk60bVPFyld+GLJ8DhjOPy4bOdveE0yFyBvCQhe8GE/cfNQ4C2VUYoCNHmrc9YoTRU7ZM0siChBNnDvnqMiXbUarVKT5aWZZAq5Q/nE743w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769595881; c=relaxed/simple; bh=JAGIyo7uHu02wmsXenqxKdWTtyrL5SRUkDJGKs429A0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M5MJ/PJEbrl9cR4R88/8jlEMAAhDu5sqCKz9nKLI1T1S/86g3veTMLS9Yo2GpuZNeIHMFQ7y1dziZRneCmifDdup6I0Oupcwv/H0gU8LIyFScVWNW6+2Nqs61XWYCUDIFTf+oISjj983jV5CYlTzR3u1Cq/bpcOC2t+ai2FPlKA= 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=vnGQqd4T; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=sy2cBbOy; 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="vnGQqd4T"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="sy2cBbOy" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1769595878; 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=h094TGqPdEZdGAE351vHcgY/GUuHvPkqMcFJn5StH3g=; b=vnGQqd4TIMQA4f/lokzkyL6N2j9vUSaLUoulNOSfngyatZhywvVfVXlseYwb/RgjsAU8Yd JFwq/bRy/PQl7TFaM8Yikx2Bn2QMX/c3fUW6a+Lf3ltrX3AUePI3GDbOaP/HuBzR0OgP9n bKkCVKtWo0SOR+QrRLSh+hhLtN57cfU+eRvFrIsJ4MMnyqByGZsS12m73s2XjLjlAS3Tbj 5LNMVudd4jPhDLJNqhXwgwMzGV/b4/fR4Jjzg5n0IEFJPUPCYEC9fU4uOB9do3NwDFKKlD m4VAzSLHrazKDw3swRr0HNO/D0Bd23OGYI/F24CW7MRqVmEmgX757wuCLzKjHA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1769595878; 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=h094TGqPdEZdGAE351vHcgY/GUuHvPkqMcFJn5StH3g=; b=sy2cBbOympleZ3QCQldQmqJxEMsKt5FC9HPivAVaalXBnS9Z/Ws2ACwYs6sfpOLYjuyxK2 uJ8uU1yUnVa2CuBg== Date: Wed, 28 Jan 2026 11:24:36 +0100 Subject: [PATCH 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: <20260128-kselftest-harness-v1-4-cb259fa81cd0@linutronix.de> References: <20260128-kselftest-harness-v1-0-cb259fa81cd0@linutronix.de> In-Reply-To: <20260128-kselftest-harness-v1-0-cb259fa81cd0@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=1769595876; l=1714; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=JAGIyo7uHu02wmsXenqxKdWTtyrL5SRUkDJGKs429A0=; b=qz7K87evmY5YXplIseWpn7JYDZEPgT/YRPNft+DjLNg61Q2lYsS6nngaB9X3uoB7NVIvU0SVT 681Im/e5Lv4DSdd3hs19A23F8mynIHHBABBqw4aNLVLmnLjjrsUTcaa 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. Signed-off-by: Thomas Wei=C3=9Fschuh --- 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 baae6b7ded41..93dcba095338 100644 --- a/tools/testing/selftests/kselftest_harness.h +++ b/tools/testing/selftests/kselftest_harness.h @@ -1216,7 +1216,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.52.0 From nobody Sat Feb 7 05:53:13 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 B864C2FE05B; Wed, 28 Jan 2026 10:24:40 +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=1769595882; cv=none; b=hNCRuXpE8nQYpvfyBbj5dLA6Lc6bsZM4w96kwn2+KTlI0IG/gnJzeLlDNp6HQ6f8E6zge/znylRIgVoN3WFScb+UA1dHsF+OGz3annH/AmJqdDysw+aiW+te8TunvRwV2maJr2i98Wu5KYO78Wj7QD3hgYtI7O5nDu1rq7JNrno= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769595882; c=relaxed/simple; bh=CpItbGuqViNDVOKjF5OYL74vl8pZDCV7rH9gUThemMI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=R757WFLaSd8M3IpDQ51zD8SyTICMmcW13ClFLMvy0iy2+W/9rY9L82NTlNXV5UAD6gtfdc646FIoksxEo42QLY8zFQQIG+S83IDunyjq/zIZ+OHpuq4U0o+fcsY+8bjBOhqbsWtaQ4XrYml1q1mGn6Q/HPcQbtRIujktav82pcY= 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=XNGRnSh0; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=YYQLmdP5; 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="XNGRnSh0"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="YYQLmdP5" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1769595879; 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=Q0+KrQzgL1kAPuD4kd5PpMOSsltIHrny4Tn1/dEXzlk=; b=XNGRnSh0+7+hKsYV8RTaJPf5GgNjVGA4Z6VkjilJ7rOgaW9WKRvxkahGfn0bukv+L6/nx6 iA7t22HOm/GhQ7MSXzJUsuTlkmRBloJ1s2BotcbUF8VSmjKLTHoRt9QMC9VPsTaVbAuGlj GL+2gQl86xbA0eP/xf64Cr7t/NSyAVOj18kH5YUXp/Fj4mGJAhEZpXcDtjTqmB4XTdb1gP z+FbZZpTtEMOMJSSkIauLd8wYGe6GM3LMhzg6lok8saui0Gxyjkcgx5+lRqQm6mm8KKf6n BrixNb1dzJPezdFKc6TPEu0QRBfApqmXenHYVdLx7YVdplhxFeg1eRophgTFQQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1769595879; 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=Q0+KrQzgL1kAPuD4kd5PpMOSsltIHrny4Tn1/dEXzlk=; b=YYQLmdP5xh+dydSzykG9unsL61UJrmRSxf2mENSrKE6rtgmJmc0CNEXWcJNUHq+hUlLctk hOKhXiuzsGRwJADQ== Date: Wed, 28 Jan 2026 11:24:37 +0100 Subject: [PATCH 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: <20260128-kselftest-harness-v1-5-cb259fa81cd0@linutronix.de> References: <20260128-kselftest-harness-v1-0-cb259fa81cd0@linutronix.de> In-Reply-To: <20260128-kselftest-harness-v1-0-cb259fa81cd0@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=1769595876; l=4451; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=CpItbGuqViNDVOKjF5OYL74vl8pZDCV7rH9gUThemMI=; b=FiNajDX/RN+zC3U5VW/VM8RA3z9ZFUACWJt5ru4l6Fo2la6ViiQjAiD3QL6azARVMQT3sFoYG ojSX2rwIDYkC2SNj2nZchalzUI3T7ru8kZAQiRe8Hn7wDolIcAOL3zW 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.52.0