Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp20958lqh; Mon, 6 May 2024 10:00:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVy3589O61r2FICVAYXV5xZyV8zZfQycLbN/pYaimMxpxq/ULkdAvbIyoeV3A6So2qyyIq0T5Pft+kGaBxh8TTVMFwnd9G2fbHnO+FD9g== X-Google-Smtp-Source: AGHT+IFiGFEe7wIx040iodj6P/iEwqqq/jBgHzOTO/np4jw7ZUAWyU5ymUD+gFu5U2OJMaQseXs0 X-Received: by 2002:a05:6a20:5601:b0:1af:7180:494f with SMTP id ir1-20020a056a20560100b001af7180494fmr11224421pzc.41.1715014801041; Mon, 06 May 2024 10:00:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715014801; cv=pass; d=google.com; s=arc-20160816; b=wq+bHeDm2GydpAp5VwA7KyZdHi1e7ZElsHKu7CG6LYdh9B02B4QX2tiLeRxvImHElA oqkFhoTyHjJVayIRfeAV4gwx4sag6vn71R4ca/QSS5zzAd92Ahhj1uZKQzCFxyl1wVln gOOKn0Ro+Rwf96bZPB/Z2jpJekVJ0leDLx4RDCOokXcjcV15Kn7x20AYbyLQAoPHDIiK G98i6gyg/nXvOB1XoYBY8hsubgftZfie6t7N55KEtqDqDwDmGmauDF3XCGNiFn6DnOnX 6s4oBgowNNNVsIjJYhECCYP/uaZIaqQwYAQ9F9R3ntGHM5T+ercdD8okblUv4mGzV1nO 74JA== 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=kAOOTpcCumth1XYqw+RDxD3qgvrcwrUOAiIEjDP28nI=; fh=h2xHIZSGiUwuZyladnT9pE6uX086qy42ByZk41PjzSs=; b=MFu22nFomRsz01RkN6K/1A6b0jvzZnIM9R6XN1kPBQN3mQ5CmHBkxeDysG6XWtVY37 w3R7YoEl2yRM6NH/HIBIhj01kDKxJTw+M76hlIw0/StgXKlUxVu9SwIHj6jgjzdOGfPL feOqttwzTF0780hAno38KgB+c3gAZznOAktwgeVgOzk5cuC10IciizxrO3B3J64H8XRS OfYxPR4ngy6gXAjzXU2POOhCXRFlb1zVSAOevFMoy7om3zJP9nNHRxvNN/4KW83R9kBi x8qoheSqTCNB+G++M0eZfylEfNkoZ7h0Fq46aSdfLcZTKo+Y4rNoNXaIrgAM5/d1BMsq w2lQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=e6NUSV71; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-170207-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170207-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id lm12-20020a170903298c00b001e09c56e7a1si8618961plb.151.2024.05.06.10.00.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 10:00:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170207-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=e6NUSV71; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-170207-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170207-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 46E88280FA3 for ; Mon, 6 May 2024 16:59:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76A1615ADA8; Mon, 6 May 2024 16:55:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="e6NUSV71" Received: from smtp-190b.mail.infomaniak.ch (smtp-190b.mail.infomaniak.ch [185.125.25.11]) (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 994B81598E4; Mon, 6 May 2024 16:55:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.25.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715014544; cv=none; b=h5P7TU1jR1yeRgqf4uSVwfeEmBiqIGEBnnO/fimXeoezjw0c1PhedooDRYiydCEVJoZDTly4Tbd1eejk+1kh8mXXbpevs7VjC0Dx/QVXsAgH38icYOuCrBe1BLPbAakuZxk5lZl4ypkSYNz6j7wAMhQPx64c9oUB/i9GM1+93q4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715014544; c=relaxed/simple; bh=BB/R9QYU0sTJD/1/5meoYUG98o9LfMjjjUh7AtLA7CI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KkTuLRKaHsmDkUmIUnPje32XJHMduf0bcMzK/CO8NXELXnMkFFyZBLQ33PjxYnHFr0VjW7IG50ZlM6eBYVdQIr0eCFqeWI0Ufwo122IxSMYUYNuR5CYBXoAH5viHJ/teOWkmDD1ke25tMZqUCXuNvbl/ie1boPma/VnlSRKqYUA= 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=e6NUSV71; arc=none smtp.client-ip=185.125.25.11 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-4-0000.mail.infomaniak.ch (smtp-4-0000.mail.infomaniak.ch [10.7.10.107]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4VY6wl1VG5z1Bk; Mon, 6 May 2024 18:55:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1715014535; bh=BB/R9QYU0sTJD/1/5meoYUG98o9LfMjjjUh7AtLA7CI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e6NUSV71Lz/Uw6XNJ1YY0EqMg/NSMSyRlEW7pkzFFN6aS6aP5RxHA7QtQno4Eoh6r cUvygZdyOVRmsrEg7/+nOw5Gd98pntS23YuZat1jPEk8GF38dTjaAuMRr9Hc7Y9Gc8 JyGMERUFVwtKcCOxMAnbs31XXbE6KH1T5K5j291o= Received: from unknown by smtp-4-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4VY6wk4fKRzRPx; Mon, 6 May 2024 18:55:34 +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 v6 10/10] selftests/harness: Handle TEST_F()'s explicit exit codes Date: Mon, 6 May 2024 18:55:18 +0200 Message-ID: <20240506165518.474504-11-mic@digikod.net> In-Reply-To: <20240506165518.474504-1-mic@digikod.net> References: <20240506165518.474504-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/20240506165518.474504-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 eb25f7c11949..7612bf09c5f8 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 void __attribute__((constructor)) \ -- 2.45.0