Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1172164lqo; Sat, 11 May 2024 10:18:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWRf6A/Web8LG+5DCb8M8Z9FKGWCOL7YooqXwEFU9+7LqlX8cJ3Zr7MysgWVuiNyv7A7AcXw21SBCBExECf3N15QG+1EeWoy+qj9GvMcQ== X-Google-Smtp-Source: AGHT+IHpRKiI2hsYySq4V0tDDYDYq5KQ5f5WqP4DIi5z2tkahnTwkvDiCcSqX4BubEqZM5bSTNMD X-Received: by 2002:a17:90a:5146:b0:2af:3821:8764 with SMTP id 98e67ed59e1d1-2b6cc3404a1mr5193015a91.5.1715447939207; Sat, 11 May 2024 10:18:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715447939; cv=pass; d=google.com; s=arc-20160816; b=c1ovpyhT3Td1Xb6k+yAJYODS9lUklSdnYPeWXpfiYp63rWAQSLB+2paVSqQWIawl1H Bto3SHkY7wMZihBKBIxwKK+nxY4GcSd3T8mhRZjIjtTVAO2SS7oBe71Tkdly3P00d7IK xMWQG5Rw0ct8amIhCWbubnAo2B3n5zzapgCWBCO5ElE/CbeX1TPmJOeLSQXf3uVnweUN eWZ0c0mok8L6fKWkE1EzWJ+HXiMiJ6TAha1zJHw13gf3Er7PaN3yRcmXsqcx7r9TAikQ +hS4HFosl3t0s9/qwWJVlLw1+H7SqwTlV/eDpu+psI6eoGx2Fdu5m4j7FuLe0oU0pO1q 8FoQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=iC1DSJl1PeqWX6x9aSS4+KXcksdR90artpUmueb/AB0=; fh=h2xHIZSGiUwuZyladnT9pE6uX086qy42ByZk41PjzSs=; b=Z6wghXQK+pL67O2ZTUqnFmLKMQO+Q3CQDk4FY/8PkJgxuf0U6coKca17K8dhAbEbRo i9YIuRThxJX0BpCxyIQwqO5t4rDOhhnTP4Fkd7UA3zVYUxAyalkuenx1NTIpzOuRkpwe 1vChvk9pTJLLfpnQ6SYpO/HrJh8QRGf/GPUs9a4nXXcC6IuxMcMRr13PU7cb+RhDNAFX Kt0ifA5XnQzb8gKgJOPOVdz2TXV/xD/poGfvGR/a4OYvMMnP0yo+i6WuH4btivygxzp4 DlObd5sfZcCxDl/ltpda/BNj1rok79mB4wo0mNAk8pB3Ohv1iYkrquj1V79SiW9cKuYQ 7vOw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b="U/jljERU"; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-176663-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176663-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b67177e75bsi5907649a91.185.2024.05.11.10.18.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 10:18:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176663-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b="U/jljERU"; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-176663-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176663-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id BF801B21518 for ; Sat, 11 May 2024 17:18:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 361CC78285; Sat, 11 May 2024 17:15:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="U/jljERU" Received: from smtp-42ad.mail.infomaniak.ch (smtp-42ad.mail.infomaniak.ch [84.16.66.173]) (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 7000467A14 for ; Sat, 11 May 2024 17:15:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=84.16.66.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715447713; cv=none; b=gDPCGE2I3dlkIZcOaBWfg+xNrzMgURPJhrlR4OiPkDzxE1+wznU6ANd+sSkAjPQ1bc0hrcRqC76A+AyXKN5RV529uWrqLvDX14a/yxOtIkydJHQ2UmgkXO5WsSEgRG124xbKi6b4/bQbbOyt8EnDqUkJn8h7bjFJSVPYNKazBWA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715447713; c=relaxed/simple; bh=788u9Ll57Ys8HanKTUXYX18fyulkHMSJMNamEoiF3dE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tZewLUPZOwHmKhT9La7D2whoAssqqFQJuPC4pnwImVReSpM18MS/pMV3WIrZRkCHWg+6FvCi6/OQHR3qpKFFM0iiP+snPmc9fRgykn0CtXtlskwsSHSn/q0xtKWh9SmgCN01Rs4k6lVSeUO8Zjd7E+CY+DGo2IGxuqtT42ay4Ro= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b=U/jljERU; arc=none smtp.client-ip=84.16.66.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Received: from smtp-3-0000.mail.infomaniak.ch (smtp-3-0000.mail.infomaniak.ch [10.4.36.107]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4VcC6v6TSMzkr2; Sat, 11 May 2024 19:15:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digikod.net; s=20191114; t=1715447703; bh=iC1DSJl1PeqWX6x9aSS4+KXcksdR90artpUmueb/AB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U/jljERUOqe/Z4nt3Hwt5Pj28zTqnanMqp8O9vWLFujZOzL7mXfibxaPV2aInBVjt jn4aAQ9WNxHiiwOzj/TWzTYsRS2Ywi1OmWkqiPP2Y+N8A7mY8xxG56gbmoSpvKIwZs r+QLALDEbqltuGI3sqESUbU/71VJtaTh1bj9WBCU= Received: from unknown by smtp-3-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4VcC6v0xg5z82q; Sat, 11 May 2024 19:15:03 +0200 (CEST) From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: Christian Brauner , Greg Kroah-Hartman , Jakub Kicinski , Kees Cook , Linus Torvalds , Mark Brown , Sasha Levin , Sean Christopherson , Shengyu Li , Shuah Khan , Shuah Khan Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Bagas Sanjaya , Brendan Higgins , David Gow , "David S . Miller" , Florian Fainelli , =?UTF-8?q?G=C3=BCnther=20Noack?= , Jon Hunter , Ron Economos , Ronald Warsow , Stephen Rothwell , Will Drewry , kernel test robot , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v7 10/10] selftests/harness: Handle TEST_F()'s explicit exit codes Date: Sat, 11 May 2024 19:14:45 +0200 Message-ID: <20240511171445.904356-11-mic@digikod.net> In-Reply-To: <20240511171445.904356-1-mic@digikod.net> References: <20240511171445.904356-1-mic@digikod.net> 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: 8bit X-Infomaniak-Routing: alpha If TEST_F() explicitly calls exit(code) with code different than 0, then _metadata->exit_code is set to this code (e.g. KVM_ONE_VCPU_TEST()). We need to keep in mind that _metadata->exit_code can be KSFT_SKIP while the process exit code is 0. Cc: Jakub Kicinski Cc: Kees Cook Cc: Mark Brown Cc: Shuah Khan Cc: Will Drewry Reported-by: Sean Christopherson Tested-by: Sean Christopherson Closes: https://lore.kernel.org/r/ZjPelW6-AbtYvslu@google.com Fixes: 0710a1a73fb4 ("selftests/harness: Merge TEST_F_FORK() into TEST_F()") Signed-off-by: Mickaël Salaün Link: https://lore.kernel.org/r/20240511171445.904356-11-mic@digikod.net --- Changes since v5: * Update commit message as suggested by Sean. Changes since v4: * Check abort status when the grandchild exited. * Keep the _exit(0) calls because _metadata->exit_code is always checked. * Only set _metadata->exit_code to WEXITSTATUS() if it is not zero. Changes since v3: * New patch mainly from Sean Christopherson. --- tools/testing/selftests/kselftest_harness.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h index cbedb4a6cf7b..3c8f2965c285 100644 --- a/tools/testing/selftests/kselftest_harness.h +++ b/tools/testing/selftests/kselftest_harness.h @@ -462,9 +462,13 @@ static inline pid_t clone3_vfork(void) munmap(teardown, sizeof(*teardown)); \ if (self && fixture_name##_teardown_parent) \ munmap(self, sizeof(*self)); \ - if (!WIFEXITED(status) && WIFSIGNALED(status)) \ + if (WIFEXITED(status)) { \ + if (WEXITSTATUS(status)) \ + _metadata->exit_code = WEXITSTATUS(status); \ + } else if (WIFSIGNALED(status)) { \ /* Forward signal to __wait_for_test(). */ \ kill(getpid(), WTERMSIG(status)); \ + } \ __test_check_assert(_metadata); \ } \ static struct __test_metadata *_##fixture_name##_##test_name##_object; \ -- 2.45.0