From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 8DA683986438 for ; Fri, 13 May 2022 20:21:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8DA683986438 Received: by mail-ot1-x32e.google.com with SMTP id l9-20020a056830268900b006054381dd35so5702545otu.4 for ; Fri, 13 May 2022 13:21:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=IFW03GD8DE3/+VkTLMmuwvRsjrttqsAfE6GJk5lMelQ=; b=m1vpaUj0ZiEP4j3XafcQMu6ZuLWlSBmMArEHkSaguKYZLF/WIg7yIKYgLANJSaF4N3 6vq33Odp2CK7DmPm/AIVL4jw4uChdUXxSKQBkPWTArujIJCe5FINfvjqD93REjWE2td+ gP5VUEQqC8e3xNbwEVr7rT3gj1ZOn88DnkFv1fs+aH6Y3Prb7mwACOUuokawuvJtJCG2 TtU1A4KgZY1uONjm17yC66cuLhRaOPNTGYV083tVGz5CYSzzMlZVxnhkVsloo66EWcvO MS3vS1LgMLPMBAGVypeMHS3dA9tyf4xjoXNNhmokqWOpvvosy0oFAhqnYVusEXSOaBfX rBSA== X-Gm-Message-State: AOAM5330/kCRNBF7T5MaTfnZ3t4wjKjHjz1+gOI0TxcT73UchEY5HSPq 9MlKJ8Q//A1ZMc3L02rXAd7XFldFhYJTWw== X-Google-Smtp-Source: ABdhPJx4lkMugcnEVyU4cdnW2Ya9hCm2KIHY5I1cebfSn7oeQ1MMEL/QaA+/AghBqM39rQNQHp9L6Q== X-Received: by 2002:a05:6830:4182:b0:606:5bc9:e01 with SMTP id r2-20020a056830418200b006065bc90e01mr2515720otu.340.1652473292559; Fri, 13 May 2022 13:21:32 -0700 (PDT) Received: from ?IPV6:2804:431:c7ca:5fbd:b7af:daa5:1bf0:c543? ([2804:431:c7ca:5fbd:b7af:daa5:1bf0:c543]) by smtp.gmail.com with ESMTPSA id 60-20020a9d0642000000b0060603221259sm1401924otn.41.2022.05.13.13.21.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 May 2022 13:21:31 -0700 (PDT) Message-ID: Date: Fri, 13 May 2022 17:21:28 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v6 3/4] linux: Add a getauxval test [BZ #23293] Content-Language: en-US To: libc-alpha@sourceware.org, Szabolcs Nagy , Florian Weimer References: <7b79ffb5ec178813653763651aa46403afd49cc2.1651757640.git.szabolcs.nagy@arm.com> From: Adhemerval Zanella In-Reply-To: <7b79ffb5ec178813653763651aa46403afd49cc2.1651757640.git.szabolcs.nagy@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-14.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, 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 server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 May 2022 20:21:35 -0000 On 05/05/2022 10:59, Szabolcs Nagy via Libc-alpha wrote: > This is for bug 23293 and it relies on the glibc test system running > tests via explicit ld.so invokation by default. I think it is 'invocation'. > > Reviewed-by: Florian Weimer LGTM as well. Reviewed-by: Adhemerval Zanella > > --- > v4: > - New patch. > --- > sysdeps/unix/sysv/linux/Makefile | 1 + > sysdeps/unix/sysv/linux/tst-getauxval.c | 74 +++++++++++++++++++++++++ > 2 files changed, 75 insertions(+) > create mode 100644 sysdeps/unix/sysv/linux/tst-getauxval.c > > diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile > index ca953804d0..89cb005c7d 100644 > --- a/sysdeps/unix/sysv/linux/Makefile > +++ b/sysdeps/unix/sysv/linux/Makefile > @@ -126,6 +126,7 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \ > tst-prctl \ > tst-scm_rights \ > tst-epoll \ > + tst-getauxval \ > # tests > > # For +depfiles in Makerules. > diff --git a/sysdeps/unix/sysv/linux/tst-getauxval.c b/sysdeps/unix/sysv/linux/tst-getauxval.c > new file mode 100644 > index 0000000000..c4b6195743 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/tst-getauxval.c > @@ -0,0 +1,74 @@ > +/* Basic test for getauxval. > + Copyright (C) 2022 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 > + > +static int missing; > +static int mismatch; > + > +static void > +check_nonzero (unsigned long t, const char *s) > +{ > + unsigned long v = getauxval (t); > + printf ("%s: %lu (0x%lx)\n", s, v, v); > + if (v == 0) > + missing++; > +} > + > +static void > +check_eq (unsigned long t, const char *s, unsigned long want) > +{ > + unsigned long v = getauxval (t); > + printf ("%s: %lu want: %lu\n", s, v, want); > + if (v != want) > + mismatch++; > +} > + > +#define NZ(x) check_nonzero (x, #x) > +#define EQ(x, want) check_eq (x, #x, want) > + > +static int > +do_test (void) > +{ > + /* These auxv entries should be non-zero on Linux. */ > + NZ (AT_PHDR); > + NZ (AT_PHENT); > + NZ (AT_PHNUM); > + NZ (AT_PAGESZ); > + NZ (AT_ENTRY); > + NZ (AT_CLKTCK); > + NZ (AT_RANDOM); > + NZ (AT_EXECFN); > + if (missing) > + FAIL_EXIT1 ("Found %d missing auxv entries.\n", missing); > + > + /* Check against syscalls. */ > + EQ (AT_UID, getuid ()); > + EQ (AT_EUID, geteuid ()); > + EQ (AT_GID, getgid ()); > + EQ (AT_EGID, getegid ()); > + if (mismatch) > + FAIL_EXIT1 ("Found %d mismatching auxv entries.\n", mismatch); > + > + return 0; > +} > + > +#include