From patchwork Fri Jul 7 18:25:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 117240 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3461667vqx; Fri, 7 Jul 2023 11:30:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlEX5lUDUIH4qUx122dSu8SxNp3xHAhJTk1cEpKKCvoyt6tY4PrY/m6AIPH6/IB6/Xr/6tI6 X-Received: by 2002:a17:907:1693:b0:987:fe18:1c56 with SMTP id hc19-20020a170907169300b00987fe181c56mr5920052ejc.47.1688754626566; Fri, 07 Jul 2023 11:30:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688754626; cv=none; d=google.com; s=arc-20160816; b=ofSynWsLaCFuRBNMM/P5U7Zqsy4Y70c2hWap34mJtHnXgWIJbuOjk3O0k8ghyzKZh1 qehiuiErxP5WAZ8rsUiqXpoQBin4CbULXOAbW2WHGjhYs8ESDQgCoMK2RL6TzSYOrOMx xGG9YMKZTtnGY1FTVWtOwRC4UG4/y6vcMVdw+ti6lSd3thXhkeCaU97UOiHwqrNFeinX Ua3L0YQxd7DyIHkj1YaqviB07QtLB/WOWCHccJ3F95IxI+U8so2ixqKrf/+aauMK7vEu SWQ13xGZ/HE7UQJYfaybHQgTCcHRXSE6Il4S4+QwjG3a3h8wu0iDUt4GWtVyIAEmULBS ppNA== 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=DycDJSpMFqxyjLrLZ6lGPz9Hzc+IiarHt7153fRbf/c=; fh=+UJGAEU2Zd20Ffzlyw2DOtwfBiThnaWweXJeIpZW2cQ=; b=PuLzh23UZOQJnN3F+eF4tYMbpQT4PsloR0UtZaTjJyeRolqi9Lf+U+HASG5dwOcxHe fYaHIBITRj55UaiM1pxmSZM5O2Y9PDfGbZDa4ERZBU1CfjOsb2nK1j2kkNbNTttIf6mu CC2FyQaLvTqzNg7G2GuRrO2HzmOmC4kijObLJnzWwia7/Mec5ynbAwM6nTuxolcUnwtr rF/uTVqN4iDqXFABAPijZWJfh9GJeBEtPtiI2FwxRCBFSMU6xf8i0gOOMXlL7RnqHesB IaE4ddVFCxbTfYvpm1KbeVZPkNaQoDZuyh89yIcSNRfcTX5xZlvOs7F7HVetx9JUiCot Wd6g== 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 s14-20020a170906284e00b00993690d17a2si498350ejc.5.2023.07.07.11.30.02; Fri, 07 Jul 2023 11:30:26 -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 S229665AbjGGSZe (ORCPT + 99 others); Fri, 7 Jul 2023 14:25:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229502AbjGGSZd (ORCPT ); Fri, 7 Jul 2023 14:25:33 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A1951FEF; Fri, 7 Jul 2023 11:25:31 -0700 (PDT) X-QQ-mid: bizesmtp70t1688754321tmaef10w Received: from linux-lab-host.localdomain ( [116.30.131.119]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 08 Jul 2023 02:25:20 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: eCJvJF4ptHAtnbbaPwc47aTRbhYkkrfXtqT9G41b5rpNHFwk2Vwq29QTGN+1N QhHOU4ekwfeupUA5ICP/pbXkF1za1ckb77bO4HdRm88TKxiykufqnCu4oVIlXNNUCviQvjz /Nk6ToRqvIw0rn+n9mR6Bzrkil92rYxg3PLnb+AdgzS0uTMx8jQi+gjZSBE4pfspWtYf4G7 vyTtV9RA+mhar+9xk8A17WOp15ObCy4Va0A8I+9++PangUMrTVKZyfMRXZaWR9/Q4xRVVmF V00caUFP00VVnetlMH4kw2/nnJZtmC4JmPoZOT2as/Qh4oEJHsNROofRUoB39ouPIR4670+ e4me1glggNeMnMemhMx10tGgI5ArASsCaCdBsgEyDcJmqGFn3AxxyH8vh+H96UpptOOUtsf X-QQ-GoodBg: 0 X-BIZMAIL-ID: 10722182004068960664 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, thomas@t-8ch.de, =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= Subject: [PATCH v4 03/18] selftests/nolibc: gettid: restore for glibc and musl Date: Sat, 8 Jul 2023 02:25:11 +0800 Message-Id: <879d87ac5eccbaa08bb471f88f5253d4b9d496cf.1688750763.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_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1770787570993691997?= X-GMAIL-MSGID: =?utf-8?q?1770787570993691997?= 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 Reviewed-by: Thomas Weißschuh 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 b4b64125d418..b63afe1975c4 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -668,6 +668,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; @@ -675,6 +676,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 */ @@ -684,9 +690,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;