From patchwork Thu Jun 29 23:25:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114482 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9981781vqr; Thu, 29 Jun 2023 16:35:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlEd+XcKHyfhYTm1gBDcOFRSTnYQs6Dqnj3yMPKN8RgEWAo4+yGkwdO8dKRM4yj58jT4BOAS X-Received: by 2002:a17:902:e5c5:b0:1b8:17e8:5472 with SMTP id u5-20020a170902e5c500b001b817e85472mr716277plf.1.1688081739533; Thu, 29 Jun 2023 16:35:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688081739; cv=none; d=google.com; s=arc-20160816; b=W2eRTuN5MHdjNCDRnJT5Hsl8JPrsV4HlnrQa4/N+SBN198brm0JCsmB2g5rGQ3ZlrQ zBtyq3nFCbdBHP+cyxLQctvKYoroZV1Ib9NzcW8fxnFMlYa/qCwvk8OgJuoT/lXKzcuv bXyWJvcsLR46lJMa5pAUbZSfj5xCqDvVrS5vGQsJWTIIZQtHEGUROPw6DIteb5Fi9EF+ edSiRp1JlfePOfjJdxNayflnQRfuA9nf8ziTnlxkDb3qWbkrd0+m1KIb2rL1UHY5wFzl 60EKfQIOvuI/5yEan+iSXoeDOoedW7sultikNiThIQPkG5HJuE/t71RL8Kdb1KGYDv6D RlhA== 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=BGCm4ip//KLyY26801dAv0VNbwdQYmdx5DU+JsGL53Y=; fh=GzghTQzqgly4pZn8BwQ4U8bZ8zCadAK8Sl/utskeyEs=; b=NzOAA6xCn70c3I+ql7t4zeyZxsgOyXIx8DXn5xMjKNMj5wJZH3BRZyeiCfl+c0dUNY 2boCzWjFBozQGuI/n10nRcynJ2ct0nyQES86gO3M99cwg0cZ1BomellSzpjzu+0LhLLY FWLaekKknvDT37nsLl7+lqWRQX5a3mcRG0T04STzPqgM9Hk9NUDmL4FD6d1KCsF6nZKD KMWrx2Ms0YYv/4SPPEh/sI3MQ5Fd9l6qo/fXHiUep2iFGtMPerIsHg/QC9RizHcUkmMW jv1rCP2JFOzP+JfJDm5xXPQZyiRGa+785iY2/A+qkCjdFuBlo/WGlcuneibNWoFXkd7Z 8rqg== 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 a1-20020a170902ecc100b001b5585f945asi2185654plh.352.2023.06.29.16.35.24; Thu, 29 Jun 2023 16:35:39 -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 S231508AbjF2X0L (ORCPT + 99 others); Thu, 29 Jun 2023 19:26:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231953AbjF2X0F (ORCPT ); Thu, 29 Jun 2023 19:26:05 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A66FD1FE4; Thu, 29 Jun 2023 16:26:03 -0700 (PDT) X-QQ-mid: bizesmtp91t1688081154tyi55hnf Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 07:25:52 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: 6aXALTFZqPuZikFTnD0XtTrqnijJVdsBQ+fxB4J0aSCn27CFnCwO6LrrmluGc rpV/PikWplX1NtR6o5wbyCcv6WlYJCsSsHhUrWWybJrEciGHc9kgBfM70mFeFNYeglnMGaR 8kBS1WA6Q4/vvjTcUxQL//bO5Mn1EJTJzocmcqmGvmgq8MovuFny2kYrND2di0t/ae2si6k 109qlRNSTq5XbQJp2wTmaL7ZX5Rjgx+UyLcnaw17iJFrYU343Cyv7rqi6hV2Y2LZVOQSE7e eCT6Z5+JLR3XMhW7o4gCnAQAkgPr6qWY9aNtjTcvynXUgcu82JGWCvCw6lg1FETscw+rksp 6s6sRAan4j8fts6W6DRZYa0tWkZ42qJoAMsqUqJ/6sX6qmg4pm+krnciMniTQ== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 12284148764811659706 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 02/15] selftests/nolibc: gettid: restore for glibc and musl Date: Fri, 30 Jun 2023 07:25:14 +0800 Message-Id: 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_H5, 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?1770081998182058298?= X-GMAIL-MSGID: =?utf-8?q?1770081998182058298?= As the gettid manpage [1] shows, glibc 2.30 has gettid support, so, let's enable the test for glibc >= 2.30. gettid works on musl too. [1]: https://man7.org/linux/man-pages/man2/gettid.2.html Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index a2eacd6436d0..785b1f4cbdc5 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -659,6 +659,7 @@ int run_syscall(int min, int max) int tmp; int ret = 0; void *p1, *p2; + int has_gettid = 1; /* indicates whether or not /proc is mounted */ proc = stat("/proc", &stat_buf) == 0; @@ -666,6 +667,11 @@ int run_syscall(int min, int max) /* this will be used to skip certain tests that can't be run unprivileged */ euid0 = geteuid() == 0; + /* from 2.30, glibc provides gettid() */ +#if defined(__GLIBC_MINOR__) && defined(__GLIBC__) + has_gettid = __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 30); +#endif + for (test = min; test >= 0 && test <= max; test++) { int llen = 0; /* line length */ @@ -675,9 +681,7 @@ int run_syscall(int min, int max) switch (test + __LINE__ + 1) { CASE_TEST(getpid); EXPECT_SYSNE(1, getpid(), -1); break; CASE_TEST(getppid); EXPECT_SYSNE(1, getppid(), -1); break; -#ifdef NOLIBC - CASE_TEST(gettid); EXPECT_SYSNE(1, gettid(), -1); break; -#endif + CASE_TEST(gettid); EXPECT_SYSNE(has_gettid, gettid(), -1); break; CASE_TEST(getpgid_self); EXPECT_SYSNE(1, getpgid(0), -1); break; CASE_TEST(getpgid_bad); EXPECT_SYSER(1, getpgid(-1), -1, ESRCH); break; CASE_TEST(kill_0); EXPECT_SYSZR(1, kill(getpid(), 0)); break;