From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (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 0F9F915358B for ; Fri, 3 May 2024 14:17:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714745840; cv=none; b=dZKK30Cn5mCmt3OmtwXNEMb36IEud3HJKUfO7Vn49k7wdNhLjPAooLM2wUkSoYYwEG5mdg7oP8I9tG+bcqL7jwsk19djfABk/jwdZ3hYytlQ5T+dtjeEEKBQWSmErPt+MNhKJx0AGws5XDwualKpjd9ixW4OEMMcOolxagEu+1U= 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.214.201 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ADcoalrC" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-1ed057cc183so17678445ad.2 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=KsDax7YwigR1hnytRNvu3/7M+8AYxBoeSbSV2fbzXaOmPx8CwgEaa7nfhCjL53w10D 3p7KnW3yV7O6AsmdkCSAWrCLy3mvXZKr1ds+cpYkMI+Ug48WRAjGP0qju1SsU0SGYEax 68Gf/7mLaPV5hUZIEo0VzUKmP7zTFanh65GTzzyYjZtnkclVorhG6Ir1gUg7oSoVZHjO hxNNreZSXE1ZyoN6301vTs5b4T/lYgupVmLkRRiqVNeuEPIP+xilJY+TJNpQsxbo8w7C hX73ncJgji9h+SPO+qtLy2x0Mu+rLzSBYXfDwX+Val18HUz1B2e2PccqYylsdWwkUxCS vXFg== X-Forwarded-Encrypted: i=1; AJvYcCX4wb015s/VjoMObVaJpmPMAi47xhHpkYmheGZo/JJhM2gXLWTweWpcy9zFXSLktuscBhqDZCpqdX/uF7h3I4PSxuMGP2U2 X-Gm-Message-State: AOJu0YwNpS4398Yc/LPFs7C5J8+gFpToyEVdRoVxESdPDgdl6TFjQ5bc Ybqf9C8YFQ5onEkfd+i5bjZvrqZzruUs2i6b1TMLnCcJuLt4PP7bEYsaUdn3gq6C5WqJPxw9vn8 iUg== X-Google-Smtp-Source: AGHT+IFXmNX8BI/5OInh9uFJfx5hH/VOCZeejP86ugVK83ToSLHsemrYMRjQmBhAQcz5sMlxtgdDcmPXGNw= 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: netdev@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