From patchwork Fri Jun 30 14:43:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 114758 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10443255vqr; Fri, 30 Jun 2023 08:12:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlEj71UQak2ei5kiMMUShFRA3HHTFgOvW3P1oYrhv1LRD8KlzXvnVvCjx0f7XnW0KklYNP09 X-Received: by 2002:a17:90a:341:b0:263:4308:b4eb with SMTP id 1-20020a17090a034100b002634308b4ebmr2731614pjf.1.1688137947898; Fri, 30 Jun 2023 08:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688137947; cv=none; d=google.com; s=arc-20160816; b=SI4xg2WHhPlyTYBGN68JVne2sDh930jr7CDPobOIuzwKlPx1KtlFZZiaQfCCvdzbxX DmYOO3qckfpyx4t/7MHzD+kSPvSsk4oYjKJZnQcu04a9V1HSvo3vBcBTNYKrftVgBlw6 1nQNSNyqIodmFmQmWJcfGCRJwi4fOsf3cekDZjEuiEcSzTujx0kBvaWACLVSWB8fMkoA MGQhDCkO+n+CiX5mZ68+8WjyXFiIiqMFeWL1g9V8Uw1g2y/MUW27LMfVKHibK8a2q4Vm yIT9jxom1M0wxRoH88AdjduhNwVkvNITk5qB4ANRt2DeQLgGk4uA7OmGNfLWzPKgVfxu AzsQ== 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=BJ0Zvf+cPAqX6Y1i5AJbx1kLFSuyGwo59d3larzIIE8=; fh=49fx4+cYYT2jkB1G9v6CSOY1nO+RV0JwAuF3mNCzENI=; b=0iGL52aAGsFYVBVw66lD2JAmS06w2badfCunvGBepPLxBKVRzhol265ruGez3S9AJg 7sFePsFCQe9WQKv7sOVjgNz1A8Y+uBBcmKVTBert1ju+0r9GSKdeoJiFjZZPJ6jr7zv9 P/AqqJ9iZDdD4ON6Yk9qDvS70je4wHqXNEwmeEc6Khp6/aDoWmZiRDbIZWGnNAtmZY5h yFN/n3hxEIyTQYM7HAoBkQ9h/ItSsqjUp3Zmfj7suXnhr223S0l1x6YkkndYbqyPWhlq 3sK4RbzuHhwESa5sA0W96/i/z8ZeZYXW4jSONQmWyTaKPf43wyzcHi9F2LTPiBU/VaQW cW1g== 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 oo4-20020a17090b1c8400b00262e629f543si11264583pjb.80.2023.06.30.08.12.11; Fri, 30 Jun 2023 08:12:27 -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 S232022AbjF3OoY (ORCPT + 99 others); Fri, 30 Jun 2023 10:44:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232382AbjF3OoK (ORCPT ); Fri, 30 Jun 2023 10:44:10 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 163724223; Fri, 30 Jun 2023 07:44:02 -0700 (PDT) X-QQ-mid: bizesmtp62t1688136233td32r9qm Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 22:43:51 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: ILHsT53NKPiH69hHrQvaiwgA2zlFoZJKtxC3fQVf7xOa2i8JFvEi+l7cutDAu NdSKTsbC9yjEhA6vmXFk52zYQc0pKbNiELQlyjNzuftlI2+C5S6KjlV6ZmpgxTNZYbbmwT3 XBAqH3DVlvcmqCIlVUIQ5tDSiIc5s7ZO4aw6x3P4BEFHP5IW5xWN3d5R8h6EhyakVqszTjH d8c4U4zRgluYH95UaAUrzK8gOV5JlyhGb75ONtswumgTLcvBBAIqAkIu6QFvtT1qjDkNOju +dz7qfMaSdRefLXOxX7PKtAZNQA4/zrDxOlVVDC/qI93jjoPyE8OBFOf6PRsrdlBK0gvPQf K1pD2PxV9e1EJdrEsOsdraPfpcPBiMHBJo7H6KsMY6+eQIZpiJGyL/KQ1VYkY3uPthpY+tq P65JLNq7VMo= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 16227406883335655901 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 02/14] selftests/nolibc: gettid: restore for glibc and musl Date: Fri, 30 Jun 2023 22:43:49 +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_DNSWL_NONE, 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?1770140937012940820?= X-GMAIL-MSGID: =?utf-8?q?1770140937012940820?= 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 ffef0ff921bf..be7614c897b4 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;