Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1696674lqm; Fri, 3 May 2024 04:01:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW+kzNBvcgf+2MIK2HhDGPoZxuiGsv7F21sEM93kRoslwWNoS2qVSxzWLR6NKOYhnjjpHvQOJo9Pn0XIeE4swFFCb0fb9JsTgP8bLy3dQ== X-Google-Smtp-Source: AGHT+IHvnA3GpF3mk7+HXZZ/VATRfPiEUvCIm9d3nxRIPo88zNYribSEyFZ8G+mKv7iff4NNVLJ9 X-Received: by 2002:a05:6122:1dab:b0:4da:c699:de98 with SMTP id gg43-20020a0561221dab00b004dac699de98mr2361430vkb.16.1714734101404; Fri, 03 May 2024 04:01:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714734101; cv=pass; d=google.com; s=arc-20160816; b=r7RR9mJyBe8HEM9McD0jzGoHeTouk+qBS1y8BvuXIkAadBwD4nzI0sVhM5E9cOyiDM PGf1U86Vg480jbHBQKKfbwETP0a4jyPxMjVJxlJhaf8cBWwcw2RkK++zYTxNOqDPJuxA PK58tQDmLRmljHan70xpyUw6AFfglHPvg8Z5J2o/6wNzonWhbp0hujAUYa/ZpBU/h9fA BlGEDT7cVfNIrIWSWIJJjZCKInxhzuXVobfalCPcgNuWAk1RGqAdhVB9oI/9XXyeztiQ yni031dcxFPyd/jm/Om6eKsSj4YcU+PUnjjueCxjg4kbE5fvc9KI2dSysycafaNKx5z1 eFmg== 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=mVs4KEfznmbkTg5aN2BdDlG7QsT5cXSjEOcwOVvlqns=; fh=siSkyeuTkzLUvvmYOCEsHOQyZbylO5CVG0oIjh590fE=; b=B4KTwYmswL5X/6vbqdtiY1hcFag/xz6HJnByfVUkHEsgbW+o0PSg5/ey71iWItHURB XA1wLRGLMj1hRQc3Y9bdVotjISI98Y19wFTzm0ehQw78z6t9nxmjFFLPCk5D6AZVnazm O06LgIPRrk57zD+xbA8saKO8Z1GgwLpcOUcXk9E5KQvKJtSCO5FHnTKW1BWXr8gznHAh VDBht9jJ1UsESUv11mtRLsZc/pygkzCJ5q6a/nFMi4NzbvYX6UgboyliVqe/DE00iZYE RfFG+y24w1B0ArgWtSRergzBethiR4TW/ht6ftsKoC88WTRC3QGO4by/t+afwDIDDBRR vnSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=u3RuLMfl; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-167557-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167557-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t20-20020a0561020a1400b0047c337990fbsi481918vsa.419.2024.05.03.04.01.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 04:01:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167557-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=u3RuLMfl; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-167557-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167557-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 20BA81C2105E for ; Fri, 3 May 2024 11:01:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2CE6C156235; Fri, 3 May 2024 10:58:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="u3RuLMfl" Received: from smtp-bc0c.mail.infomaniak.ch (smtp-bc0c.mail.infomaniak.ch [45.157.188.12]) (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 7A73A154433 for ; Fri, 3 May 2024 10:58:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.157.188.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714733926; cv=none; b=YKA7yiH0Vr80lgau0dmIh4lhdGv0/gtYYuqzW1rQjdI8kstcsT52EjXi2kjMw6u/TxW9MwUfErbAdCl8OaSPsiMdRGXvKQ3G5sfbGytmXTgvMygJ1WSquX+O0T9/A11asCU4k8yuGdTnLgyS9T3I2+qww1tyTK4E7ynahgD9i8o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714733926; c=relaxed/simple; bh=6KlePIHjh/F0rwXAtm5wVQtdAF3T8pKIS+NqlOPteLM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gBdqep40lAploL35aUTXVAXMhusUzT9xtQaJrwL4eqyGMGop6XYFppmA0vjYb4taoHHiorgro/Cq29c2Yf2nc0Z5SMalH0ucfpOvpMajc01moI1Xti42Y+ZRfHnSNSdWWWd5iTBbQa+sVpiGRzvSOKjSDeh/3HLX11bKv4Rmw5k= 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=u3RuLMfl; arc=none smtp.client-ip=45.157.188.12 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-0001.mail.infomaniak.ch (smtp-3-0001.mail.infomaniak.ch [10.4.36.108]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4VW78K3mspzPNb; Fri, 3 May 2024 12:58:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1714733921; bh=6KlePIHjh/F0rwXAtm5wVQtdAF3T8pKIS+NqlOPteLM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u3RuLMfl4d1/sSvej3lawnt1ZSVCPWY173dYy3g+BPuBi1ca1seVVKZQZLqJkarRz 6+jU6Ziqro+AbKmWEmsQXDb568J8msUDsipuKT9lYi4rnfiszNhVgoCWJ/nRvihgVV mYl8W7ehIrR5vqTyCRlD1YXcTfAWnOA2WFMuGocg= Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4VW78K0CSSz111K; Fri, 3 May 2024 12:58:41 +0200 (CEST) From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: Christian Brauner , Jakub Kicinski , Kees Cook , Mark Brown , Sean Christopherson , Shengyu Li , Shuah Khan Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , "David S . Miller" , =?UTF-8?q?G=C3=BCnther=20Noack?= , Will Drewry , kernel test robot , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v5 10/10] selftests/harness: Handle TEST_F()'s explicit exit codes Date: Fri, 3 May 2024 12:58:20 +0200 Message-ID: <20240503105820.300927-11-mic@digikod.net> In-Reply-To: <20240503105820.300927-1-mic@digikod.net> References: <20240503105820.300927-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. Initial patch written by Sean Christopherson [1]. Cc: Jakub Kicinski Cc: Kees Cook Cc: Mark Brown Cc: Sean Christopherson Cc: Shuah Khan Cc: Will Drewry Link: https://lore.kernel.org/r/ZjPelW6-AbtYvslu@google.com [1] Fixes: 0710a1a73fb4 ("selftests/harness: Merge TEST_F_FORK() into TEST_F()") Signed-off-by: Mickaël Salaün Link: https://lore.kernel.org/r/20240503105820.300927-11-mic@digikod.net --- 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