From patchwork Sat Jul 27 14:37:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13743740 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 599F017E90E; Sat, 27 Jul 2024 14:38:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722091111; cv=none; b=sz2UjvD0HHk9eofp1xagA608/WwapD0fT8MGVMssBXnMjyiOQxK0TWHPhx/kTIf0k70bnLRsh+wW5sZRg1uMRAwev7fp8t+SEO4KZUqI9nYRrG/eUadi9XIE0GVh3wS+eKfyYBDMmpnJnWofNLNtxwYTeLBBjPBRNAURJPFDt5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722091111; c=relaxed/simple; bh=OORvz1p6c5sw+iASbygPZWG8lUlzKGxuAMKBsz9Ee0M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OpGYKIhZVjPq1jP6Dow2P6gsVPMpeDGD4Vi5V/tFeAeIRCHkla7E5eZCF2iOmDUScEKx7n9wKBLj1NsDrH8CyNarAy4AkQFijOQJIzXWza9pdHRvzpQG4VSBMH1ha3oObk34JVeOC91yzidttFqISTI41dMZwTIXzzgHM10Dnrw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=c+O0csl3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="c+O0csl3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C43E1C32781; Sat, 27 Jul 2024 14:38:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722091111; bh=OORvz1p6c5sw+iASbygPZWG8lUlzKGxuAMKBsz9Ee0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c+O0csl3ADdcbuH6DGczsDr8AmpFty5TaD6DN9rdtptjp3r5ewhmsV+FVkQIvq7Jx 0882aa09i6r8wVcSTM8OJllfTIZgb0wioAyabrFbkmQIxN9ctDpYCd9ReGd3q5UNpQ VejMhjLp0WcbjsIKbtotXM1awtkev5UdwxHQsCJ4ynF4mI8Rn0M/xWqQQ/PINaqFnk Ugb8JUrG581z/v7WAtj0LjbeOFHeRKZb+5dsquRxnmKOZUvhWjNHd4+Q8KoEee4cXW YIz1FzWmoED9C10N0LLjyxX+NeDTSGkr+MlJOjF3dVEMeqjRMba6oGIHu18DDBDs1b tbtEdCIWQ0PWQ== From: Masahiro Yamada To: Kees Cook , Andy Lutomirski , Will Drewry Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Alexandre Belloni , Benjamin Tissoires , Christian Borntraeger , Claudio Imbrenda , David Hildenbrand , Janosch Frank , Jiri Kosina , Shuah Khan , bpf@vger.kernel.org, kvm@vger.kernel.org, linux-input@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-rtc@vger.kernel.org Subject: [PATCH v2 1/2] selftests: harness: remove unneeded __constructor_order_last() Date: Sat, 27 Jul 2024 23:37:36 +0900 Message-ID: <20240727143816.1808657-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240727143816.1808657-1-masahiroy@kernel.org> References: <20240727143816.1808657-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 __constructor_order_last() is unneeded. If __constructor_order_last() is not called on backward-order systems, __constructor_order will remain 0 instead of being set to _CONSTRUCTOR_ORDER_BACKWARD (= -1). __LIST_APPEND() will still take the 'else' branch, so there is no difference in the behavior. Signed-off-by: Masahiro Yamada --- Changes in v2: - reword "reverse-order" to "backward-order" in commit description .../selftests/drivers/s390x/uvdevice/test_uvdevice.c | 6 ------ tools/testing/selftests/hid/hid_bpf.c | 6 ------ tools/testing/selftests/kselftest_harness.h | 10 +--------- tools/testing/selftests/rtc/rtctest.c | 7 ------- 4 files changed, 1 insertion(+), 28 deletions(-) diff --git a/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c b/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c index ea0cdc37b44f..7ee7492138c6 100644 --- a/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c +++ b/tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c @@ -257,12 +257,6 @@ TEST_F(attest_fixture, att_inval_addr) att_inval_addr_test(&self->uvio_attest.meas_addr, _metadata, self); } -static void __attribute__((constructor)) __constructor_order_last(void) -{ - if (!__constructor_order) - __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD; -} - int main(int argc, char **argv) { int fd = open(UV_PATH, O_ACCMODE); diff --git a/tools/testing/selftests/hid/hid_bpf.c b/tools/testing/selftests/hid/hid_bpf.c index dc0408a831d0..f2bd20ca88bb 100644 --- a/tools/testing/selftests/hid/hid_bpf.c +++ b/tools/testing/selftests/hid/hid_bpf.c @@ -1331,12 +1331,6 @@ static int libbpf_print_fn(enum libbpf_print_level level, return 0; } -static void __attribute__((constructor)) __constructor_order_last(void) -{ - if (!__constructor_order) - __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD; -} - int main(int argc, char **argv) { /* Use libbpf 1.0 API mode */ diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h index 40723a6a083f..71648d2102cb 100644 --- a/tools/testing/selftests/kselftest_harness.h +++ b/tools/testing/selftests/kselftest_harness.h @@ -488,12 +488,6 @@ * Use once to append a main() to the test file. */ #define TEST_HARNESS_MAIN \ - static void __attribute__((constructor)) \ - __constructor_order_last(void) \ - { \ - if (!__constructor_order) \ - __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD; \ - } \ int main(int argc, char **argv) { \ return test_harness_run(argc, argv); \ } @@ -891,7 +885,6 @@ static struct __fixture_metadata *__fixture_list = &_fixture_global; static int __constructor_order; #define _CONSTRUCTOR_ORDER_FORWARD 1 -#define _CONSTRUCTOR_ORDER_BACKWARD -1 static inline void __register_fixture(struct __fixture_metadata *f) { @@ -1337,8 +1330,7 @@ static int test_harness_run(int argc, char **argv) static void __attribute__((constructor)) __constructor_order_first(void) { - if (!__constructor_order) - __constructor_order = _CONSTRUCTOR_ORDER_FORWARD; + __constructor_order = _CONSTRUCTOR_ORDER_FORWARD; } #endif /* __KSELFTEST_HARNESS_H */ diff --git a/tools/testing/selftests/rtc/rtctest.c b/tools/testing/selftests/rtc/rtctest.c index 63ce02d1d5cc..9647b14b47c5 100644 --- a/tools/testing/selftests/rtc/rtctest.c +++ b/tools/testing/selftests/rtc/rtctest.c @@ -410,13 +410,6 @@ TEST_F_TIMEOUT(rtc, alarm_wkalm_set_minute, 65) { ASSERT_EQ(new, secs); } -static void __attribute__((constructor)) -__constructor_order_last(void) -{ - if (!__constructor_order) - __constructor_order = _CONSTRUCTOR_ORDER_BACKWARD; -} - int main(int argc, char **argv) { switch (argc) { From patchwork Sat Jul 27 14:37:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13743741 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 94A0117A91B; Sat, 27 Jul 2024 14:38:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722091113; cv=none; b=sLvPYbinnLQSix9RiLigb2hTZHC22lONWV8B4IK14WnoYB8uHIipFX7ra2iUOOsRjt/xfW89buUZcSKWOZMnt84Lrkm5Wz6PDuQJW79CbwwCb2DT5UHzNWvu7n+kUF90xatlviiVIVaU0Zhm/0fIm/Xp6zVsugE7FfAQr9eN03s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722091113; c=relaxed/simple; bh=8y5f1zxNiODm4UXL4eX5MjelZjB7Y2NyylWPMZ1tbag=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ihYAVicRtL0YC1Bl+r3d+4f8hSfTt7i6nMRVtYVlTtbNjQMkiXzHbjtEnFSQiSWDl48XRKGAP3boT2vseoCSW7NGNaN1SxPnIq96jReAVlqWie7vBFtboJPx0LyKAwY0XZG3GN/hDPtM5jkppVCxK4I5bsNQnQ50mkcVhLC0HSE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pVJ8IIEz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pVJ8IIEz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABA9FC4AF0A; Sat, 27 Jul 2024 14:38:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722091113; bh=8y5f1zxNiODm4UXL4eX5MjelZjB7Y2NyylWPMZ1tbag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pVJ8IIEzH/I0l/gaMh1csDBJt6zM3aQWBVZLnJmi0spUCIHCjXMvDxNoroxuEELCg Xaj1yrlThXOwSAU+h54gFP1DRc/V61gGQeCd4J4YpNKGSn0HUZkfY8uDBp0/3OaE5t q4knupyV9yXB877qLLId9Pa+qmFEQORW4XtXOH7mLskM+UHq28CwOEoY9mEL3cYckg en1IRUjV7vtVdmlxBTevkn2LEFq+l7XNieQ61VVrCzEkk/bUGRhiCIAj2aEHd8W2Ye ljT9aLlhh0lxUx0X1bo02vvMqf8aado/yQRBmxUAAX3+XNCh6ZKfcQ8MP3Y+ibZIC2 OY9kTCi/JG4yw== From: Masahiro Yamada To: Kees Cook , Andy Lutomirski , Will Drewry Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Shuah Khan , linux-kselftest@vger.kernel.org Subject: [PATCH v2 2/2] selftests: harness: rename __constructor_order for clarification Date: Sat, 27 Jul 2024 23:37:37 +0900 Message-ID: <20240727143816.1808657-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240727143816.1808657-1-masahiroy@kernel.org> References: <20240727143816.1808657-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now, __constructor_order is boolean; 1 for forward-order systems, 0 for backward-order systems while parsing __LIST_APPEND(). Change it into a bool variable, and rename it for clarification. Signed-off-by: Masahiro Yamada --- Changes in v2: - reword "reverse-order" to "backward-order" in commit description tools/testing/selftests/kselftest_harness.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h index 71648d2102cb..a5a72415e37b 100644 --- a/tools/testing/selftests/kselftest_harness.h +++ b/tools/testing/selftests/kselftest_harness.h @@ -818,7 +818,7 @@ item->prev = item; \ return; \ } \ - if (__constructor_order == _CONSTRUCTOR_ORDER_FORWARD) { \ + if (__constructor_order_forward) { \ item->next = NULL; \ item->prev = head->prev; \ item->prev->next = item; \ @@ -882,9 +882,7 @@ struct __test_xfail { } static struct __fixture_metadata *__fixture_list = &_fixture_global; -static int __constructor_order; - -#define _CONSTRUCTOR_ORDER_FORWARD 1 +static bool __constructor_order_forward; static inline void __register_fixture(struct __fixture_metadata *f) { @@ -935,7 +933,7 @@ static inline bool __test_passed(struct __test_metadata *metadata) * list so tests are run in source declaration order. * https://gcc.gnu.org/onlinedocs/gccint/Initialization.html * However, it seems not all toolchains do this correctly, so use - * __constructor_order to detect which direction is called first + * __constructor_order_foward to detect which direction is called first * and adjust list building logic to get things running in the right * direction. */ @@ -1330,7 +1328,7 @@ static int test_harness_run(int argc, char **argv) static void __attribute__((constructor)) __constructor_order_first(void) { - __constructor_order = _CONSTRUCTOR_ORDER_FORWARD; + __constructor_order_forward = true; } #endif /* __KSELFTEST_HARNESS_H */