From patchwork Wed Oct 16 21:58:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 99058 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2FE50385841D for ; Wed, 16 Oct 2024 22:21:27 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 83F383858D33 for ; Wed, 16 Oct 2024 22:21:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 83F383858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 83F383858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729117266; cv=none; b=LxVkx9LF4+u4mGaprzj1ZS1QW2cFgiyGyQ8o4Q6YI+6v6igM2cM74fWYP8NT2ZlMXF6mVSfVL3VZDWxmnApV/79FsyuoYE4Qv2iXyrOnyldKyJ4wGQ4iCWhdeAP4oUjwbCSD+sQVL3J08/RqyJQYfu9SukGkm2DdnPVVQeLb7x4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729117266; c=relaxed/simple; bh=gV0L6ZIQcbN2dZWVONzTOdbrq0HXXzbIW/OcIGOmHMg=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=NR9zC3GzVNG2FBI+mcqOC6ouJtDQOBN5Xm/R8xzQ4kTn1aa+q/WKSoB8lDbwNWrrfBUoivBcgif3mqc+mDjLwnVwVFaMjzUxITM80kLwjI/kft9vK475vyjAMtHFOAmIGCzn8svmJwp47n4qCmUp+fAXVPsvSwt/g4UuW4AEKHg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729117262; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=/jYMqVa2WmLlPWJJxHK4f2oZJog19thRgEeckTd5qZ4=; b=R0t/cWffVnaW8FD8heuXv5QiKGdSZ2wLjT8ehmJv91E4ynMVvUZGITne7EdiGJ54XUlHEM FrUx12nZ6OKb8GyyocEiz2119SV6h6DTUvj7HMZg3r9LL9dVtDmeNrhXnfG0QNJ6f5gqNb 7qQx3BhJOiEh8i3WD48K4lEKNulEiYU= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-315-xtN1DLh0MkiSWHbYOwEiHQ-1; Wed, 16 Oct 2024 17:58:23 -0400 X-MC-Unique: xtN1DLh0MkiSWHbYOwEiHQ-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-37d49887a2cso113489f8f.0 for ; Wed, 16 Oct 2024 14:58:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729115902; x=1729720702; h=mime-version:message-id:subject:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=/jYMqVa2WmLlPWJJxHK4f2oZJog19thRgEeckTd5qZ4=; b=clrsFLfjzOfPY6lT+zTERFzr6UGeggGDjrYPnJ8jzOU6JjzUCUXwQK6xc9NBnyOY27 ijAnSL1mQK87Ebl5tXKZ2l/r1OehlX6/OXWprj/IasR8qj/gpD+2Sv7uytzgaQsZr2w9 66MhHpsXhEr7J3rSMEmnaGQ7GUtoeRw7IKdP0k5NdN0ylyjjehDthspv0ODZ34oGbvNp 0n49yrqZ57Fk5gvRqUkUor/+fBb0NJX1ngfJGloX8jVzQAQ797POfZeoXJ9ylMvl0H5y i+t0506zohr+Quqgh1InURgOBibkm8mZF4vRcAbPuf94oRhsbLRYN/ZSTVr9oH1VDMWf dirA== X-Gm-Message-State: AOJu0YwvkkysR+P/CTkc1dDc8z8QnVyhQhhZrRqrdpKKUNurb/3WqMkK 6ooGzmSDI+OtZLnN6vbIpSRN1qjLsr/M/izAPThRCrP9Z2vI3BfXXGCwsnY47XUwmrgas9dWwCb EqNuxpGEP9ztT20LtOnNdMd+n1NPqFO7BoYyz9HE/aE3KkWAKaVkVxS/6KyUYbAI+glexA00Fya SnXC9Pn8GJKhgdhHj/bUvi+ABoaLZpPhgDtlQZ/CAx+w== X-Received: by 2002:adf:cf02:0:b0:377:94b:4f51 with SMTP id ffacd0b85a97d-37d93e3d357mr667250f8f.22.1729115902283; Wed, 16 Oct 2024 14:58:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmIMLnlYc6vrccNAjRCCmR81SDUOyIFn3dSMCyGR0vK5s7rnb+4P1G/10ueZ5c1cLpYryoDw== X-Received: by 2002:adf:cf02:0:b0:377:94b:4f51 with SMTP id ffacd0b85a97d-37d93e3d357mr667238f8f.22.1729115901625; Wed, 16 Oct 2024 14:58:21 -0700 (PDT) Received: from digraph.polyomino.org.uk (digraph.polyomino.org.uk. [2001:8b0:bf73:93f7::51bb:e332]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d7fc45297sm5372253f8f.115.2024.10.16.14.58.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 14:58:20 -0700 (PDT) Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.97) (envelope-from ) id 1t1C27-000000063pK-083J for libc-alpha@sourceware.org; Wed, 16 Oct 2024 21:58:19 +0000 Date: Wed, 16 Oct 2024 21:58:19 +0000 (UTC) From: Joseph Myers To: libc-alpha@sourceware.org Subject: Add more tests of pthread attributes initial values Message-ID: <441c3d7f-2bd8-50bf-12f0-6eb0ce9a9b48@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org There are various existing tests that call pthread_attr_init and then verify properties of the resulting initial values retrieved with pthread_attr_get* functions. However, those are missing coverage of the initial values retrieved with pthread_attr_getschedparam and pthread_attr_getstacksize. Add testing for initial values from those functions as well. (tst-attr2 covers pthread_attr_getdetachstate, pthread_attr_getguardsize, pthread_attr_getinheritsched, pthread_attr_getschedpolicy, pthread_attr_getscope. tst-attr3 covers some of those together with pthread_attr_getaffinity_np. tst-pthread-attr-sigmask covers pthread_attr_getsigmask_np. pthread_attr_getstack has unspecified results if called before the relevant attributes have been set, while pthread_attr_getstackaddr is deprecated.) Tested for x86_64. diff --git a/nptl/Makefile b/nptl/Makefile index bf4c29b6ed..ceb91afafc 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -276,6 +276,7 @@ LDLIBS-tst-minstack-throw = -lstdc++ tests = \ tst-attr2 \ tst-attr3 \ + tst-attr4 \ tst-cancel4_1 \ tst-cancel4_2 \ tst-cancel7 \ diff --git a/nptl/tst-attr4.c b/nptl/tst-attr4.c new file mode 100644 index 0000000000..9ee8821d8c --- /dev/null +++ b/nptl/tst-attr4.c @@ -0,0 +1,60 @@ +/* Test initial values of pthread attributes. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#include +#include +#include + + +int +do_test (void) +{ + pthread_attr_t a; + int ret; + + xpthread_attr_init (&a); + + size_t stacksize = 0; + verbose_printf ("testing default stack size\n"); + ret = pthread_attr_getstacksize (&a, &stacksize); + TEST_VERIFY_EXIT (ret == 0); + TEST_VERIFY (stacksize >= PTHREAD_STACK_MIN); + TEST_VERIFY (stacksize <= SIZE_MAX / 2); + + int policy; + verbose_printf ("testing default scheduler parameters\n"); + ret = pthread_attr_getschedpolicy (&a, &policy); + TEST_VERIFY_EXIT (ret == 0); + struct sched_param param; + ret = pthread_attr_getschedparam (&a, ¶m); + TEST_VERIFY_EXIT (ret == 0); + int min = sched_get_priority_min (policy); + TEST_VERIFY (min != -1); + int max = sched_get_priority_max (policy); + TEST_VERIFY (max != -1); + TEST_VERIFY (param.sched_priority >= min); + TEST_VERIFY (param.sched_priority <= max); + + return 0; +} + +#include