From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id BB253395BC29 for ; Wed, 29 Apr 2020 21:32:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BB253395BC29 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-318-nJy58kauNH22ClvBS7iXIQ-1; Wed, 29 Apr 2020 17:31:59 -0400 X-MC-Unique: nJy58kauNH22ClvBS7iXIQ-1 Received: by mail-qk1-f197.google.com with SMTP id 30so4140171qkp.21 for ; Wed, 29 Apr 2020 14:31:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=a/cFcVz+N0Ly+OwO12Ebrkm8G+PzH+9En9iv0aK7b48=; b=U/6AXECgrxafs9UDYG3iXZVZk2u1QfkvHUr3brCTeppnbC7EoEpkxwpg0He5thOZ/i upxB6UZDXW2+GxXn6nmqnr7M3Jpflx9p+JKYP4qZuQ2fA+W9HD10PZmOZBCzYuGALKPh fjFHroV0/ruZMzN78pSGQ5XA6GEASV0e+aBzkDPWe5DBoZkpznrVOO4ajq7LGVKoy0XL H1MSByDxPdbknT0YXHg4pZMLNFulVMX8xivFE/pM9DTqCJKxiaDTvJoZadAQRxuASEup ol5kAHxYwQlS00fuLpEqMquvl/4zoz6fl8Ubmh5FxiS94se56N0e7LtgWwf4OLaq4u/w JSOQ== X-Gm-Message-State: AGi0PuaLqJgZbeZ6/quzP9QiZpU36mx5PF5qCsdggNmjQPHEMZvcTQh+ QGEAySwqoF5k4lYh9qIwtUZsYalOy0XH7iUXH96wjI6WgqGLRFf4P8t39pNC1rzOnQeQv/86T8i hhpqEnmVm0WfTwf66XfSE X-Received: by 2002:ac8:36e9:: with SMTP id b38mr372771qtc.234.1588195918180; Wed, 29 Apr 2020 14:31:58 -0700 (PDT) X-Google-Smtp-Source: APiQypKQRdpKtRY8HFOA5pcpmOYWwp8Gjt3gUmzJqNIxktwgVzZinXE9ii+V0hSJRG4eU2xfxq/BrA== X-Received: by 2002:ac8:36e9:: with SMTP id b38mr372745qtc.234.1588195917889; Wed, 29 Apr 2020 14:31:57 -0700 (PDT) Received: from [192.168.1.4] (198-84-170-103.cpe.teksavvy.com. [198.84.170.103]) by smtp.gmail.com with ESMTPSA id b10sm371269qtj.30.2020.04.29.14.31.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Apr 2020 14:31:57 -0700 (PDT) Subject: [PATCH v3] test-container: Support $(complocaledir) and mkdirp. To: DJ Delorie Cc: libc-alpha@sourceware.org References: From: Carlos O'Donell Organization: Red Hat Message-ID: Date: Wed, 29 Apr 2020 17:31:56 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-22.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Wed, 29 Apr 2020 21:32:02 -0000 On 4/29/20 1:57 PM, DJ Delorie wrote: > "Carlos O'Donell" writes: >> My goal is this: >> >> * Have the variables mirror the configure variables. >> - If in configure we call it 'complocaledir' then internally we always >> use 'complocaledir'. >> >> We have strayed from this somewhat with 'support_complocaledir_prefix', >> and if anything I'd suggest we would just rename all of these to match >> the configure names e.g. complocaledir instead of support_complocaledir_prefix. > > I think the only part that's important is that the Makefile variables > match the $variables in the script. Internally, since they're global > scope, adding some decoration like support_{variable}_value (or _prefix > or _path, whatever) makes sense to avoid namespace collision. > >> (c) When a container test needs a specific locale, we look for it in the >> special place, and copy it into place as required (without locale-archive >> support). >> - Container tests just copy the locales required into the testroot.root so >> no additional compilation is required. > > As much as we're complaining about the speed of compiling these, I think > doing it any way other than how the user would install them should be a > non-starter, unless we CLEARLY outline how to test the user-path and > cache-path code seperately. > > Although some hackery that *does* the user-path into the testroot, then > caches the results (rsync?) would meet both needs. > >> This patch doesn't make this worse because I'm only compiling test locales >> not the real locales for testing. > > Yup :-) > >>>> + m = strtol (the_words[1], NULL, 0); >>> >>> Error handling? >> >> It's in xmkdirp, where we do this: > > strtol("Carlos", ...) returns 0. You'll silently create an unusable > directory. You need to check errno here, with the usual clear/call/test > code. v3 - Check errno for strtol. OK for master? >From fb6e2305ae421e42566acf7008367f45f4035d30 Mon Sep 17 00:00:00 2001 From: Carlos O'Donell Date: Thu, 23 Jan 2020 09:45:00 -0500 Subject: [PATCH] test-container: Support $(complocaledir) and mkdirp. Expand the support infrastructure: - Create $(complocaledir) in the testroot.pristine to support localedef. - Add the variable $complocaledir to script support. - Add the script command 'mkdirp'. All localedef tests which run with default paths need to have the $(complocaledir) created in testroot.pristine. The localedef binary will not by itself create the default path, but it will write into the path. By adding this we can simplify the localedef tests. The variable $complocaledir is the value of the configured $(complocaledir) which is the location of the compiled locales that will be searched by the runtime by default. The command mkdirp will be available in script setup and will be equivalent to running `mkdir -p`. The variable and command can be used to write more complex tests. Reviewed-by: DJ Delorie --- Makefile | 3 +++ support/test-container.c | 42 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 8f0a93aceb..6dcfe40c25 100644 --- a/Makefile +++ b/Makefile @@ -588,6 +588,9 @@ $(objpfx)testroot.pristine/install.stamp : # We need a working /bin/sh for some of the tests. test -d $(objpfx)testroot.pristine/bin || \ mkdir $(objpfx)testroot.pristine/bin + # We need the compiled locale dir for localedef tests. + test -d $(objpfx)testroot.pristine/$(complocaledir) || \ + mkdir -p $(objpfx)testroot.pristine/$(complocaledir) cp $(objpfx)support/shell-container $(objpfx)testroot.pristine/bin/sh cp $(objpfx)support/echo-container $(objpfx)testroot.pristine/bin/echo cp $(objpfx)support/true-container $(objpfx)testroot.pristine/bin/true diff --git a/support/test-container.c b/support/test-container.c index dff2ff379e..08d5195b7e 100644 --- a/support/test-container.c +++ b/support/test-container.c @@ -72,6 +72,10 @@ int verbose = 0; * mkdir $buildroot/testroot.pristine/ * install into it + * default glibc install + * create /bin for /bin/sh + * create $(complocaledir) so localedef tests work with default paths. + * install /bin/sh, /bin/echo, and /bin/true. * rsync to $buildroot/testroot.root/ "Per-test" actions: @@ -97,9 +101,23 @@ int verbose = 0; rm FILE cwd PATH exec FILE - FILE must start with $B/, $S/, $I/, $L/, or / - (expands to build dir, source dir, install dir, library dir - (in container), or container's root) + mkdirp MODE DIR + + variables: + $B/ build dir, equivalent to $(common-objpfx) + $S/ source dir, equivalent to $(srcdir) + $I/ install dir, equivalent to $(prefix) + $L/ library dir (in container), equivalent to $(libdir) + $complocaledir/ compiled locale dir, equivalent to $(complocaledir) + / container's root + + If FILE begins with any of these variables then they will be + substituted for the described value. + + The goal is to expose as many of the runtime's configured paths + via variables so they can be used to setup the container environment + before execution reaches the test. + details: - '#': A comment. - 'su': Enables running test as root in the container. @@ -108,6 +126,8 @@ int verbose = 0; - 'rm': A minimal remove files command. - 'cwd': set test working directory - 'exec': change test binary location (may end in /) + - 'mkdirp': A minimal "mkdir -p FILE" command. + * mytest.root/postclean.req causes fresh rsync (with delete) after test if present @@ -859,6 +879,7 @@ main (int argc, char **argv) int nt = tokenize (the_line, the_words, 3); int i; + /* Expand variables. */ for (i = 1; i < nt; ++i) { if (memcmp (the_words[i], "$B/", 3) == 0) @@ -875,6 +896,10 @@ main (int argc, char **argv) the_words[i] = concat (new_root_path, support_libdir_prefix, the_words[i] + 2, NULL); + else if (memcmp (the_words[i], "$complocaledir/", 15) == 0) + the_words[i] = concat (new_root_path, + support_complocaledir_prefix, + the_words[i] + 14, NULL); /* "exec" and "cwd" use inside-root paths. */ else if (strcmp (the_words[0], "exec") != 0 && strcmp (the_words[0], "cwd") != 0 @@ -892,6 +917,9 @@ main (int argc, char **argv) the_words[2] = concat (the_words[2], the_words[1], NULL); } + /* Run the following commands in the_words[0] with NT number of + arguments (including the command). */ + if (nt == 2 && strcmp (the_words[0], "so") == 0) { the_words[2] = concat (new_root_path, support_libdir_prefix, @@ -961,6 +989,14 @@ main (int argc, char **argv) { be_su = 1; } + else if (nt == 3 && strcmp (the_words[0], "mkdirp") == 0) + { + long int m; + errno = 0; + m = strtol (the_words[1], NULL, 0); + TEST_COMPARE (errno, 0); + xmkdirp (the_words[2], m); + } else if (nt > 0 && the_words[0][0] != '#') { fprintf (stderr, "\033[31minvalid [%s]\033[0m\n", the_words[0]); -- 2.21.1 -- Cheers, Carlos.