Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1414934lqm; Thu, 2 May 2024 14:14:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVOtpIqnKlTHY2/dInRthZ7HWVZKaVjawS56JJr83BzCquQwSY9DtL4icD+aiEsSeh0NN2Rl15hvgBV0VP+oxpv0qIEqIme9Wr4eg7NhA== X-Google-Smtp-Source: AGHT+IEpaSbBwVVFGdSuSzouPLa6t4gzGiOjbRHWMF5mzugqKjyptMzePox80ehxGHxMWdAeRmo+ X-Received: by 2002:a05:6a20:975b:b0:1a7:53f5:4e01 with SMTP id hs27-20020a056a20975b00b001a753f54e01mr965229pzc.22.1714684477855; Thu, 02 May 2024 14:14:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714684477; cv=pass; d=google.com; s=arc-20160816; b=HvIEUwQfcl4Ii8muMF7X/H+V/rbO2nyBL2lBebm5KwLYp6UraaiDVbVvsLrSwKqiek +pypZx/OqVgQucJw/evYCpt2pYax7MEzI2KneHwVrSqP8Umpu0EJWDEoYv61O0c39fwJ EXtSwFz3id9GVPYawlGdOR2LoLzX9SZb2nY4SBJzbGIRYCI2wN/9SNhd2scNFU4zv+tv rxvJfbQGbrJWyL3GAH6vt1BRcn/exXE9xNLis7Nc9Ng9gYE7jGxpobZtU5L5k2w+WhZ8 lx2zL5jYaApsSbELOBgSXiJZpNhwZRKgsDGHnFqqScSQdvFZ9AGxhpjd3DrQL+pjK48A k5bQ== 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=8ok5jBQZc65Av1cOiCkWrGII0a6nL9mbw6rPiBNP/i8=; fh=Xv8vsRY1NXL+T1KrRTbY6br3ySvwj5ozCgvxkAtZGgs=; b=0XS31aBpLYAuP6nfs3ZeExLvvWBYGjFTqo7gyvNEJ4hqAhRQpEMawlDqGh4D95+r7w 2SocxyeF+yWW66tmpt5rkfShyyHBjY1HfdecVTgFqzWl40Ui1UEkbhr+aGkKlFhUhHqE l/3URBjYaZOWE5ScSO7WzIfxXsTt+ecW55OcLD6wFBQeshdgAsnZpXF6SFLtjfOGveHn VeSDm7hZh+erNw/UzTpUgd0fGRdzVkMmWlmP5rNrpDdliIctDKFT1Is1IW7B7r7HYmMg BOVEZS3eaWBftX6W8qXAz800miUAsVzVCMVlPi3kDBBrbsfxNJOk3CvNCn7FOM2t7O9D fAsg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=Y6QJwMwP; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-166922-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166922-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 cl19-20020a056a02099300b005f76c60e2ddsi1812503pgb.246.2024.05.02.14.14.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 14:14:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166922-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=Y6QJwMwP; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-166922-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166922-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 BCD1FB2336F for ; Thu, 2 May 2024 21:12:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 620A81C8FD4; Thu, 2 May 2024 21:10:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="Y6QJwMwP" Received: from smtp-bc0f.mail.infomaniak.ch (smtp-bc0f.mail.infomaniak.ch [45.157.188.15]) (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 5F48A1C2310; Thu, 2 May 2024 21:09:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.157.188.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714684201; cv=none; b=oQ7MLlDCUiTkG5sfRuAe43GyR5Stkol+LaiXLNirdoQLliNkr5PePjlEKC29v5uBrGUsfIjDUCgdiRoGHBXwqJiFIWl+acVaA3U1Z0utM0KBJyIvWdlyR1em1Wd+4ybYeFEuud9MmH3kgQQgbH7X2aKrR23WBsCu56cjig1AzmY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714684201; c=relaxed/simple; bh=KqEsjBjuhpsjwrbJBGS/A9dvVAlJ3/nK7tVCR3svPG8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eMWT/hwgTlD7J+cWFTfe89uOv+IYG+JkJaGo3HJL24rKG0HuhMxJdiVfBY/tA7a7ShbxtxEOB7MRXP6oCMF3p8Zd16XNRNZVfPCnm0eSkqnphNTsUW0NEnURiKSGmpVGLQ/2hTSrrhl7++eEcge/uwIQsQouHFLjg+0EIt3Z2cM= 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=Y6QJwMwP; arc=none smtp.client-ip=45.157.188.15 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-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4VVmm03jwczL5X; Thu, 2 May 2024 23:09:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1714684192; bh=KqEsjBjuhpsjwrbJBGS/A9dvVAlJ3/nK7tVCR3svPG8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y6QJwMwPh4Vk1yiDX75N9NqUtxGjQbcqVDnJJwMC+pksry1GXyClOGQ3GYzXMUgZO HgLgI1GKJocjJZMQo+kHGoQzfFTMTkDLfiAqNYUgFcIeKUQaZgU7TW8RfojFaD2C32 8h9VOq5brlKrfatEcHyD+/ITP9JwPb9ac502cs2c= Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4VVmlz3TX3zqTH; Thu, 2 May 2024 23:09:51 +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 Subject: [PATCH v4 10/10] selftests/harness: Fix TEST_F()'s exit codes Date: Thu, 2 May 2024 23:09:26 +0200 Message-ID: <20240502210926.145539-11-mic@digikod.net> In-Reply-To: <20240502210926.145539-1-mic@digikod.net> References: <20240502210926.145539-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 Always forward grandchild's exit codes to its parent. This fixes KVM_ONE_VCPU_TEST(). 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/20240502210926.145539-11-mic@digikod.net --- Changes since v3: * New patch mainly from Sean Christopherson. --- tools/testing/selftests/kselftest_harness.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h index d3837a3a584e..77d4fac8d0c0 100644 --- a/tools/testing/selftests/kselftest_harness.h +++ b/tools/testing/selftests/kselftest_harness.h @@ -442,7 +442,7 @@ static inline pid_t clone3_vfork(void) fixture_name##_setup(_metadata, self, variant->data); \ /* Let setup failure terminate early. */ \ if (_metadata->exit_code) \ - _exit(0); \ + _exit(_metadata->exit_code); \ _metadata->setup_completed = true; \ fixture_name##_##test_name(_metadata, self, variant->data); \ } else if (child < 0 || child != waitpid(child, &status, 0)) { \ @@ -454,7 +454,7 @@ static inline pid_t clone3_vfork(void) if (_metadata->setup_completed && !fixture_name##_teardown_parent && \ __sync_bool_compare_and_swap(teardown, false, true)) \ fixture_name##_teardown(_metadata, self, variant->data); \ - _exit(0); \ + _exit(_metadata->exit_code); \ } \ if (_metadata->setup_completed && fixture_name##_teardown_parent && \ __sync_bool_compare_and_swap(teardown, false, true)) \ @@ -462,8 +462,10 @@ 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)) \ - /* Forward signal to __wait_for_test(). */ \ + /* Forward exit codes and signals to __wait_for_test(). */ \ + if (WIFEXITED(status)) \ + _exit(_metadata->exit_code); \ + if (WIFSIGNALED(status)) \ kill(getpid(), WTERMSIG(status)); \ __test_check_assert(_metadata); \ } \ -- 2.45.0