Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1812285lqm; Fri, 3 May 2024 07:17:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV7L+9CzySU8r4Mq+/hnIQcidmXXC/HNlFyi5GCpcEuj5cEyCX0R928yreZwGNC4t/A00cwhwHWe59K5IGp7RdIaeTO4OpTPzPwP79G3g== X-Google-Smtp-Source: AGHT+IHa+YmcGowbkw7YVaw3rf8NuVVzbdEnohdvtN5thkd4cz2iWKNABY2qQRqb5FYpX+oz5N4C X-Received: by 2002:a05:6214:20ea:b0:6a0:cb7c:68c7 with SMTP id 10-20020a05621420ea00b006a0cb7c68c7mr2822565qvk.65.1714745854232; Fri, 03 May 2024 07:17:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714745854; cv=pass; d=google.com; s=arc-20160816; b=sef04sGSaYZVfE6fr5xLtnBEYxuhgjjns388a/DxFJ14tC0XNrI2Tr+nlwj7FpUqax a0eecP+Lv/dmSrydbhGvCjIa9oJmQB0VmWAxtsNKBxuy/QN5poVFrE2jrxNiLsz51bMk 4ib3yV9xg0QeW9PD8a2GWVFwvr+FUhfXsqB9Fx1dGzMNRtxUetPv83+xTQuP5TXqhQgt 5LSw5qaPeJGME0uY3l9927iQ95lUdr9/6dcgu/Mx1xZ1jPAtYenAQTAtg1Di5C3v7XCz OGeAktV5Imjg6sb90ihYLfFNgS3w95mQ6/1kUYeYrv08qN5ukuIjCAbcv7wG10AzYdOy 8Hiw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:date:dkim-signature; bh=euaWG2d1xrAd5eW72Lhyga6K2ICgPg5ZdZZkZnwoCG8=; fh=MUzpLkW7VpBj/iSiqU9EZM8HUfthWK35JpQ54BvVAzY=; b=IxMJlR319jyvdqyjYh9kjp1vcHGeOs6eBgh7A285UGOFxxtjk+gz/y6+FMP5P6qxMh PzoM7ZjO/IKT8AxRHDX6JK+q7jJyR+65j6TVp3zPPH+xpCZXwgBpnUZAOkW0JpkK+M9a 5Ey8c3SS6aoqNe8kVXcQqX9bJLZZ+dDpXZwBHwp+otEUajQqbOwbj9S0VDcc0FlWv4hV fgLDMlP6vSzP2A1KfOg+ow8lZBpwDwDhdbpGhDl2FArg1kWRiQYcquErvJ3lINOSPdR2 nLwXPxQE8Dw6liwVnwmqFWvvzFB3hBq209zrM1z48MHQ6W7lsndtwIYxpwsK5ulawmyb X8wg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ADcoalrC; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-167753-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167753-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 9-20020a0562140d0900b006a0d5990b99si2843763qvh.122.2024.05.03.07.17.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 07:17:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167753-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=@google.com header.s=20230601 header.b=ADcoalrC; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-167753-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167753-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 D6D7E1C21879 for ; Fri, 3 May 2024 14:17:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 309EC1552E4; Fri, 3 May 2024 14:17:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ADcoalrC" Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3F291BF31 for ; Fri, 3 May 2024 14:17:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714745840; cv=none; b=MleOkFJLdlpzdL+m8xjqSyjrZr+OwlkZNBC7Mc2RhITo1HE6E6N1REjt7Z1TeOW4VuQ6SjdUYjSAUV3Z6fFfXd7B4s9OhidFX9JS2gCFgXZnH7GDHDP4zoRbjWtorogNpWRjbkhUbODPngnsO6316uKFQEsovxYHHj6tSEuFSFY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714745840; c=relaxed/simple; bh=Tw2mHGCJBZondqE0Nbp48iklfjoW+xXMxK0fvzgsi4M=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=nzwFA8I6uqEAXFUIFLkt+stU5euvdkfnzKP6IG20fj5ob42mIxACD5Nc8d0E/3mPIq5CiGP8bICVzGcRE6XU08N9lQugOp842kAz5LYuxaqUcNG7fGc1hEpGcYHU5hQYCU7Ijf0RC01Mc6LR5BJVNEY92D5M0jcmyvN8lKYvpws= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ADcoalrC; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-61eea13e924so253481a12.0 for ; Fri, 03 May 2024 07:17:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1714745838; x=1715350638; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=euaWG2d1xrAd5eW72Lhyga6K2ICgPg5ZdZZkZnwoCG8=; b=ADcoalrCktZfm9wwMo8gYx9SYC7zLL5WOagtw8vpTsMTMkDbDzwn95quOU8z6A+z1U w3TcXHWTbmcVuYw4tep1j7zpQqyxRgG8Zmy0i2amxcPEcPB7me4Miuzh4DLRxlcMO7nQ ueorGKQaj4HmY+AFj9YvipJgTu56gqJsy1E8TAj6ATM2MT3SuR07pTfXyVj/cJtQwsjW djpTznxnz05V/o6pRcmmqjoJ8q/lYDziFUKM1xTnYnGKW4ptJbezWxRVqvNt80w0JtSa Mm/qsQFB/dc0+ut/dR1mnRuPDNfp+8HOB7OmHUIUiB4DZ2kYIsguNl3LjkgyyeyNAudn J87w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714745838; x=1715350638; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=euaWG2d1xrAd5eW72Lhyga6K2ICgPg5ZdZZkZnwoCG8=; b=wzkJ7z+hsBIsU5gBpvHUZ8uoGFKrDJm3kcnrxMfYFOpO6eFV3r4qq8NuDKtbNBpORu /EI2MTOsAjDEk9CaYjqpzWLO6diunvWM3ktad9dUpBNO+S0oPB0Db39tAVa+i3ptndwP NN3NQMjcHP95liUIOmKeiz1iGjBdUaD7L8FE+JL8KpACRt7utRf2k83rmdEGx/bsYpcc xw14U0E9dEM1mfkNZ9Pac71+RLUJ9zAxnEQ9Lg/n5ftQ1p2eA/0XbMIAFCS6HYyoZyBI yfmUooBVgVRbNxAVuMRyb+LAW+2terw46ReIxMCLA7SbzE/VpdAdZI198TCWay+tpeDS cDeg== X-Forwarded-Encrypted: i=1; AJvYcCXuip7VHEjTqgYT8s8m2irifeaRsDCk8zkCiKIZVXld7DIMyEYxce2Rzd7GAJP4FKphiyfRdK0bVSjIWyXmRsPa6ajeLsBzBBOuRUGM X-Gm-Message-State: AOJu0YwZlNvmhXfYO5R1KpXFDkPMDBK9S0yRs5jPpUCOXboCOgINVtXk jZlWXgZax/SnphiMgbLLIwLy4pZuIUqhmCzAF6QGuZfHsFFpCyH/N0Awj36E+9O2z5xANEMtI+j fQg== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:d2d0:b0:1e2:97f1:87c0 with SMTP id n16-20020a170902d2d000b001e297f187c0mr247114plc.1.1714745838315; Fri, 03 May 2024 07:17:18 -0700 (PDT) Date: Fri, 3 May 2024 07:17:16 -0700 In-Reply-To: <20240503105820.300927-11-mic@digikod.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240503105820.300927-1-mic@digikod.net> <20240503105820.300927-11-mic@digikod.net> Message-ID: Subject: Re: [PATCH v5 10/10] selftests/harness: Handle TEST_F()'s explicit exit codes From: Sean Christopherson To: "=?utf-8?Q?Micka=C3=ABl_Sala=C3=BCn?=" Cc: Christian Brauner , Jakub Kicinski , Kees Cook , Mark Brown , Shengyu Li , Shuah Khan , "David S . Miller" , "=?utf-8?Q?G=C3=BCnther?= Noack" , Will Drewry , kernel test robot , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Fri, May 03, 2024, Micka=C3=ABl Sala=C3=BCn wrote: > 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. >=20 > Initial patch written by Sean Christopherson [1]. Heh, my pseudo patch barely has any relevance at this point. How about rep= lacing that with: Reported-by: Sean Christopherson Closes: https://lore.kernel.org/r/ZjPelW6-AbtYvslu@google.com > 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=C3=ABl Sala=C3=BCn > Link: https://lore.kernel.org/r/20240503105820.300927-11-mic@digikod.net > --- >=20 > 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. >=20 > Changes since v3: > * New patch mainly from Sean Christopherson. > --- > tools/testing/selftests/kselftest_harness.h | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) >=20 > 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 =3D WEXITSTATUS(status); \ Ah, IIUC, this works because __run_test() effectively forwards the exit_cod= e? } else if (t->pid =3D=3D 0) { setpgrp(); t->fn(t, variant); _exit(t->exit_code); } Tested-by: Sean Christopherson > + } else if (WIFSIGNALED(status)) { \ > /* Forward signal to __wait_for_test(). */ \ > kill(getpid(), WTERMSIG(status)); \ > + } \ > __test_check_assert(_metadata); \ > } \ > static void __attribute__((constructor)) \ > --=20 > 2.45.0 >=20