Discussion:
[PATCH] test-container: Add $i18ndir, $complocaledir, and mkdirp.
(too old to reply)
Carlos O'Donell
2018-12-11 01:20:43 UTC
Permalink
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 <***@redhat.com>
---
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 <***@redhat.com>
+
+ * 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 <***@redhat.com>

* 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]);
--
2.19.2
--
Cheers,
Carlos.
Loading...