From patchwork Fri Jun 30 14:46:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114746 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10426450vqr; Fri, 30 Jun 2023 07:52:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5JjL+qSRwaqXETPlKwOlwQeeFUadW/a6RxMwdtgA+dC4WPATXMKd8Mtqm4kXEH/940hqZe X-Received: by 2002:a05:6808:b28:b0:3a3:660c:bdb0 with SMTP id t8-20020a0568080b2800b003a3660cbdb0mr2534684oij.54.1688136732831; Fri, 30 Jun 2023 07:52:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688136732; cv=none; d=google.com; s=arc-20160816; b=0u8H0IFZMF9JIxj7jB0Fk1xYDCdemKBw5EYHLHn2MxMsrwSfwF3xJysN+ilfa4NOdb qyTY9kUSFke84fw9ryJvaX8c1ZJkTORG5N5ZuDiPDDvI9r+vrZGrEC5yxDaJ5i9btgLO 2VSok1yNfktuxUnQ/U+ta0o7iAe2JwYbWtsGiFi3piHeTTXCxlSG/8SHwZS7nzldCMsM DKPAjyqdsJ16LgTybalG6VRCT2F4WluwYOg3ytmsHpefB3eDWThXvF3+COiY5rmAIwXw 9qFKbZ1/u/PrXrEp4bgUVI0p17QWPWjqDI5Ic6Ltql1wIJL6MovwhYK8XM1/x413ak3R t1ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=OxX/rDLYTfYnXy36bLvyCxoObRr7MrSGyukFwxQfGyM=; fh=49fx4+cYYT2jkB1G9v6CSOY1nO+RV0JwAuF3mNCzENI=; b=nsuqZPRzP2an+HyN3h0H2uCNCqssNB7RMP2CjzcHxGva1tGwWrZMBVNPRrfDjgjBjE JHz9QZLZJpHaoDaKB6Q40g4+n3r2YR8H9Gg7GZkXhBTg7iNBaJLKvuzYW8GUshskbNbZ 7CXvc2Lkseo1lbY/DDUKds3Bky0A4J3nfGhE5OxnbdS8tTZVsbcsfysALfkUwnCn94cE fXweVU7KWMpKZI4YfmdqmRg54r9HHNOuE3lT3Emn7iAyzeLl+ndcO8R0yXjm2B9VqP6s lXtr6AQK9XTBFwvIC28d4EyqPv52MEXI+1P9NXbWnbbbYE/B9QLtfXii3BI2BzWwoAmV jtkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b14-20020a17090a5a0e00b002636ac73ffdsi2350575pjd.63.2023.06.30.07.51.56; Fri, 30 Jun 2023 07:52:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232278AbjF3OqZ (ORCPT + 99 others); Fri, 30 Jun 2023 10:46:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232292AbjF3OqW (ORCPT ); Fri, 30 Jun 2023 10:46:22 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08F27E4C; Fri, 30 Jun 2023 07:46:20 -0700 (PDT) X-QQ-mid: bizesmtp88t1688136371tgmgq7hg Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 22:46:10 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: 0laiA9+vjACjfigCT6n4FbL5nW8/jNpLSvoQkIDyLgOgBYBSUrlxcH7cnsPU+ JNB/Hh2ZH4ZY4LYZnTxLLi6KnhREVwWhLMTzcfjzSbfu/xOKHtF+25gTAl3QJJFdUIh8Pt+ vgGudIqnS4erVtv75UKjIJu1sl5FHOsP8/K/tLTgxyYA1PquKa5zjkttPYZxhmpUEMMByET kMgN9iBOae9NC62iooXvUpOP8uy8WejN4EjGxWAjVTW26TXgoPIq6JferQDHtFDyGmMShy6 1yW5n7fJlFrgRIZRC7lwjPCb4R0tbndTVHmKpanNjhPmqES+8Vy6MgPGN1lAAwgwlzZeGLk rl7hbIsnFvABzmn5YLi9YhCvwi6xqOqe5cnSkShP1WeFyVF8nBhLgjZm54OYDHCa5npU7rn wZ0kYSsMQ5E= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 4395302546129479556 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Subject: [PATCH v3 04/14] selftests/nolibc: fix up int_fast16/32_t test cases for musl Date: Fri, 30 Jun 2023 22:46:07 +0800 Message-Id: <8b47bb0d7ff4c24d99e8e3c9e03f747664d3465a.1688134400.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770139662817570535?= X-GMAIL-MSGID: =?utf-8?q?1770139662817570535?= musl limits the fast signed int in 32bit, but glibc and nolibc don't, to let such test cases work on musl, let's provide the type based SINT_MAX_OF_TYPE(type) and SINT_MIN_OF_TYPE(type). Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/lkml/bc635c4f-67fe-4e86-bfdf-bcb4879b928d@t-8ch.de/ Reviewed-by: Thomas Weißschuh Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index d9644244fc95..290b43c7dc72 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -41,6 +41,10 @@ #endif #endif +/* for the type of int_fast16_t and int_fast32_t, musl differs from glibc and nolibc */ +#define SINT_MAX_OF_TYPE(type) (((type)1 << (sizeof(type) * 8 - 2)) - (type)1 + ((type)1 << (sizeof(type) * 8 - 2))) +#define SINT_MIN_OF_TYPE(type) (-SINT_MAX_OF_TYPE(type) - 1) + /* will be used by nolibc by getenv() */ char **environ; @@ -818,11 +822,11 @@ int run_stdlib(int min, int max) CASE_TEST(limit_int_fast8_max); EXPECT_EQ(1, INT_FAST8_MAX, (int_fast8_t) 0x7f); break; CASE_TEST(limit_int_fast8_min); EXPECT_EQ(1, INT_FAST8_MIN, (int_fast8_t) 0x80); break; CASE_TEST(limit_uint_fast8_max); EXPECT_EQ(1, UINT_FAST8_MAX, (uint_fast8_t) 0xff); break; - CASE_TEST(limit_int_fast16_min); EXPECT_EQ(1, INT_FAST16_MIN, (int_fast16_t) INTPTR_MIN); break; - CASE_TEST(limit_int_fast16_max); EXPECT_EQ(1, INT_FAST16_MAX, (int_fast16_t) INTPTR_MAX); break; + CASE_TEST(limit_int_fast16_min); EXPECT_EQ(1, INT_FAST16_MIN, (int_fast16_t) SINT_MIN_OF_TYPE(int_fast16_t)); break; + CASE_TEST(limit_int_fast16_max); EXPECT_EQ(1, INT_FAST16_MAX, (int_fast16_t) SINT_MAX_OF_TYPE(int_fast16_t)); break; CASE_TEST(limit_uint_fast16_max); EXPECT_EQ(1, UINT_FAST16_MAX, (uint_fast16_t) UINTPTR_MAX); break; - CASE_TEST(limit_int_fast32_min); EXPECT_EQ(1, INT_FAST32_MIN, (int_fast32_t) INTPTR_MIN); break; - CASE_TEST(limit_int_fast32_max); EXPECT_EQ(1, INT_FAST32_MAX, (int_fast32_t) INTPTR_MAX); break; + CASE_TEST(limit_int_fast32_min); EXPECT_EQ(1, INT_FAST32_MIN, (int_fast32_t) SINT_MIN_OF_TYPE(int_fast32_t)); break; + CASE_TEST(limit_int_fast32_max); EXPECT_EQ(1, INT_FAST32_MAX, (int_fast32_t) SINT_MAX_OF_TYPE(int_fast32_t)); break; CASE_TEST(limit_uint_fast32_max); EXPECT_EQ(1, UINT_FAST32_MAX, (uint_fast32_t) UINTPTR_MAX); break; CASE_TEST(limit_int_fast64_min); EXPECT_EQ(1, INT_FAST64_MIN, (int_fast64_t) INT64_MIN); break; CASE_TEST(limit_int_fast64_max); EXPECT_EQ(1, INT_FAST64_MAX, (int_fast64_t) INT64_MAX); break;