From patchwork Tue Dec 11 01:20:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos O'Donell X-Patchwork-Id: 30618 Received: (qmail 112925 invoked by alias); 11 Dec 2018 01:20:52 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 112893 invoked by uid 89); 11 Dec 2018 01:20:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=sk:support, fresh X-HELO: mail-qk1-f196.google.com Return-Path: To: GNU C Library , DJ Delorie From: Carlos O'Donell Subject: [PATCH] test-container: Add $i18ndir, $complocaledir, and mkdirp. Openpgp: preference=signencrypt Message-ID: <6b2e7a6c-b7a0-e7b8-de00-1699a504e671@redhat.com> Date: Mon, 10 Dec 2018 20:20:43 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In order to test localedef in the test-container framework it was necessary to add support for two new variables and one new command. The variables $i18ndir and $complocaledir allow the test-container scripts to directly reference configurable locations for the build wihtout hard-coding them. For example the script needs to copy character maps into the rootfs for testing, and for that you need $i18ndir/charmaps as a path. Likewise for localedef to install a compiled locale in the default location the directory needs to be created e.g. mkdir -p $complocaledir/dir. This last command requires both the new command 'mkdirp' e.g. mkdir -p, and the new variable $complocaledir. While documenting these three additions we also document the 'so' and 'chmod' commands. These new features will be used by the new tst-localedef-hardlinks test. Signed-off-by: Carlos O'Donell --- ChangeLog | 16 ++++++++++++++++ support/Makefile | 4 +++- support/support.h | 4 ++++ support/support_paths.c | 14 ++++++++++++++ support/test-container.c | 36 ++++++++++++++++++++++++++++++++---- 5 files changed, 69 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0fd6dfc224..e538327f59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2018-12-10 Carlos O'Donell + + * support/Makefile (CFLAGS-support_paths.c): Add -DI18NDIR_PATH + and -DCOMPLOCALEDIR_PATH. + * support/support.h: Declare support_i18ndir_prefix, and + support_complocaledir_prefix. + * support/support_paths.c [I18NDIR_PATH]: Define + support_i18ndir_prefix. + [!I18NDIR_PATH]: Error. + [COMPLOCALEDIR_PATH]: Define support_complocaledir_prefix. + [!COMPLOCALEDIR_PATH]: Error. + * support/test-container.c: Document 'so', 'chmod' and new 'mkdirp' + command. + (main): Add comments. Expand $i18ndir, and $complocaledir variables. + Implement 'mkdirp' command. + 2018-12-10 Carlos O'Donell * locale/programs/localedef.c (construct_output_path): Use diff --git a/support/Makefile b/support/Makefile index 93a5143016..6b2a011f52 100644 --- a/support/Makefile +++ b/support/Makefile @@ -166,7 +166,9 @@ CFLAGS-support_paths.c = \ -DOBJDIR_PATH=\"`cd $(objpfx)/..; pwd`\" \ -DOBJDIR_ELF_LDSO_PATH=\"`cd $(objpfx)/..; pwd`/elf/$(rtld-installed-name)\" \ -DINSTDIR_PATH=\"$(prefix)\" \ - -DLIBDIR_PATH=\"$(libdir)\" + -DLIBDIR_PATH=\"$(libdir)\" \ + -DI18NDIR_PATH=\"$(i18ndir)\" \ + -DCOMPLOCALEDIR_PATH=\"$(complocaledir)\" ifeq (,$(CXX)) LINKS_DSO_PROGRAM = links-dso-program-c diff --git a/support/support.h b/support/support.h index c3ad76901e..4b648ffb8f 100644 --- a/support/support.h +++ b/support/support.h @@ -104,6 +104,10 @@ extern const char support_objdir_elf_ldso[]; extern const char support_install_prefix[]; /* Corresponds to the install's lib/ or lib64/ directory. */ extern const char support_libdir_prefix[]; +/* Corresponds to the install's i18ndir/ directory. */ +extern const char support_i18ndir_prefix[]; +/* Corresponds to the install's compiled locale directory. */ +extern const char support_complocaledir_prefix[]; extern ssize_t support_copy_file_range (int, off64_t *, int, off64_t *, size_t, unsigned int); diff --git a/support/support_paths.c b/support/support_paths.c index 6d0beb102c..a0dc32f8fb 100644 --- a/support/support_paths.c +++ b/support/support_paths.c @@ -57,3 +57,17 @@ const char support_libdir_prefix[] = LIBDIR_PATH; #else # error please -DLIBDIR_PATH=something in the Makefile #endif + +#ifdef I18NDIR_PATH +/* Corresponds to the install's i18ndir/ directory. */ +const char support_i18ndir_prefix[] = I18NDIR_PATH; +#else +# error please -DI18NDIR_PATH=something in the Makefile +#endif + +#ifdef COMPLOCALEDIR_PATH +/* Corresponds to the install's compiled locale directory. */ +const char support_complocaledir_prefix[] = COMPLOCALEDIR_PATH; +#else +# error please -DCOMPLOCALEDIR_PATH=something in the Makefile +#endif diff --git a/support/test-container.c b/support/test-container.c index df450adfdb..869d2f5572 100644 --- a/support/test-container.c +++ b/support/test-container.c @@ -91,19 +91,30 @@ int verbose = 0; * mytest.root/mytest.script has a list of "commands" to run: syntax: # comment - su + su + so FILE mv FILE FILE cp FILE FILE rm 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) + chmod MODE FILE + mkdirp MODE DIR + + FILE must start with $B/, $S/, $I/, $L/, $i18ndir/, + $complocaledir/ or / (expands to build dir, source dir, + install dir, library dir (in container), I18NPATH + (in container), compiled locale dir (in container), + or container's root) + details: - '#': A comment. - 'su': Enables running test as root in the container. + - 'so': A shortcut for "cp $PWD/FILE $L/FILE" - 'mv': A minimal move files command. - 'cp': A minimal copy files command. - 'rm': A minimal remove files command. + - 'chmod': A minimal chmod command. + - 'mkdirp': A minimal "mkdir -p FILE" command. + * mytest.root/postclean.req causes fresh rsync (with delete) after test if present @@ -848,6 +859,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) @@ -864,6 +876,14 @@ 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], "$i18ndir/", 9) == 0) + the_words[i] = concat (new_root_path, + support_i18ndir_prefix, + the_words[i] + 8, 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); else if (the_words[i][0] == '/') the_words[i] = concat (new_root_path, the_words[i], NULL); @@ -878,6 +898,8 @@ main (int argc, char **argv) the_words[2] = concat (the_words[2], the_words[1], NULL); } + /* Run the command 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, @@ -912,6 +934,12 @@ main (int argc, char **argv) { be_su = 1; } + else if (nt == 3 && strcmp (the_words[0], "mkdirp") == 0) + { + long int m; + m = strtol (the_words[1], NULL, 0); + xmkdirp (the_words[2], m); + } else if (nt > 0 && the_words[0][0] != '#') { printf ("\033[31minvalid [%s]\033[0m\n", the_words[0]);