|
|
b1dca6 |
commit 033362cfd7e0e1dccd6c9a2642710d6e3a7e7007
|
|
|
b1dca6 |
Author: Carlos O'Donell <carlos@redhat.com>
|
|
|
b1dca6 |
Date: Thu Jan 23 09:45:00 2020 -0500
|
|
|
b1dca6 |
|
|
|
b1dca6 |
test-container: Support $(complocaledir) and mkdirp.
|
|
|
b1dca6 |
|
|
|
b1dca6 |
Expand the support infrastructure:
|
|
|
b1dca6 |
- Create $(complocaledir) in the testroot.pristine to support localedef.
|
|
|
b1dca6 |
- Add the variable $complocaledir to script support.
|
|
|
b1dca6 |
- Add the script command 'mkdirp'.
|
|
|
b1dca6 |
|
|
|
b1dca6 |
All localedef tests which run with default paths need to have the
|
|
|
b1dca6 |
$(complocaledir) created in testroot.pristine. The localedef binary
|
|
|
b1dca6 |
will not by itself create the default path, but it will write into
|
|
|
b1dca6 |
the path. By adding this we can simplify the localedef tests.
|
|
|
b1dca6 |
|
|
|
b1dca6 |
The variable $complocaledir is the value of the configured
|
|
|
b1dca6 |
$(complocaledir) which is the location of the compiled locales that
|
|
|
b1dca6 |
will be searched by the runtime by default.
|
|
|
b1dca6 |
|
|
|
b1dca6 |
The command mkdirp will be available in script setup and will
|
|
|
b1dca6 |
be equivalent to running `mkdir -p`.
|
|
|
b1dca6 |
|
|
|
b1dca6 |
The variable and command can be used to write more complex tests.
|
|
|
b1dca6 |
|
|
|
b1dca6 |
Reviewed-by: DJ Delorie <dj@redhat.com>
|
|
|
b1dca6 |
|
|
|
b1dca6 |
diff --git a/Makefile b/Makefile
|
|
|
b1dca6 |
index ae44b9cdd29fb0e3..3748d6f7cfb6223b 100644
|
|
|
b1dca6 |
--- a/Makefile
|
|
|
b1dca6 |
+++ b/Makefile
|
|
|
b1dca6 |
@@ -371,6 +371,9 @@ $(objpfx)testroot.pristine/install.stamp :
|
|
|
b1dca6 |
# We need a working /bin/sh for some of the tests.
|
|
|
b1dca6 |
test -d $(objpfx)testroot.pristine/bin || \
|
|
|
b1dca6 |
mkdir $(objpfx)testroot.pristine/bin
|
|
|
b1dca6 |
+ # We need the compiled locale dir for localedef tests.
|
|
|
b1dca6 |
+ test -d $(objpfx)testroot.pristine/$(complocaledir) || \
|
|
|
b1dca6 |
+ mkdir -p $(objpfx)testroot.pristine/$(complocaledir)
|
|
|
b1dca6 |
cp $(objpfx)support/shell-container $(objpfx)testroot.pristine/bin/sh
|
|
|
b1dca6 |
cp $(objpfx)support/echo-container $(objpfx)testroot.pristine/bin/echo
|
|
|
b1dca6 |
cp $(objpfx)support/true-container $(objpfx)testroot.pristine/bin/true
|
|
|
b1dca6 |
diff --git a/support/test-container.c b/support/test-container.c
|
|
|
b1dca6 |
index 9eff8baeef0e9d8a..9fcc91e478038232 100644
|
|
|
b1dca6 |
--- a/support/test-container.c
|
|
|
b1dca6 |
+++ b/support/test-container.c
|
|
|
b1dca6 |
@@ -72,6 +72,10 @@ int verbose = 0;
|
|
|
b1dca6 |
|
|
|
b1dca6 |
* mkdir $buildroot/testroot.pristine/
|
|
|
b1dca6 |
* install into it
|
|
|
b1dca6 |
+ * default glibc install
|
|
|
b1dca6 |
+ * create /bin for /bin/sh
|
|
|
b1dca6 |
+ * create $(complocaledir) so localedef tests work with default paths.
|
|
|
b1dca6 |
+ * install /bin/sh, /bin/echo, and /bin/true.
|
|
|
b1dca6 |
* rsync to $buildroot/testroot.root/
|
|
|
b1dca6 |
|
|
|
b1dca6 |
"Per-test" actions:
|
|
|
b1dca6 |
@@ -97,9 +101,23 @@ int verbose = 0;
|
|
|
b1dca6 |
rm FILE
|
|
|
b1dca6 |
cwd PATH
|
|
|
b1dca6 |
exec FILE
|
|
|
b1dca6 |
- FILE must start with $B/, $S/, $I/, $L/, or /
|
|
|
b1dca6 |
- (expands to build dir, source dir, install dir, library dir
|
|
|
b1dca6 |
- (in container), or container's root)
|
|
|
b1dca6 |
+ mkdirp MODE DIR
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+ variables:
|
|
|
b1dca6 |
+ $B/ build dir, equivalent to $(common-objpfx)
|
|
|
b1dca6 |
+ $S/ source dir, equivalent to $(srcdir)
|
|
|
b1dca6 |
+ $I/ install dir, equivalent to $(prefix)
|
|
|
b1dca6 |
+ $L/ library dir (in container), equivalent to $(libdir)
|
|
|
b1dca6 |
+ $complocaledir/ compiled locale dir, equivalent to $(complocaledir)
|
|
|
b1dca6 |
+ / container's root
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+ If FILE begins with any of these variables then they will be
|
|
|
b1dca6 |
+ substituted for the described value.
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+ The goal is to expose as many of the runtime's configured paths
|
|
|
b1dca6 |
+ via variables so they can be used to setup the container environment
|
|
|
b1dca6 |
+ before execution reaches the test.
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
details:
|
|
|
b1dca6 |
- '#': A comment.
|
|
|
b1dca6 |
- 'su': Enables running test as root in the container.
|
|
|
b1dca6 |
@@ -108,6 +126,8 @@ int verbose = 0;
|
|
|
b1dca6 |
- 'rm': A minimal remove files command.
|
|
|
b1dca6 |
- 'cwd': set test working directory
|
|
|
b1dca6 |
- 'exec': change test binary location (may end in /)
|
|
|
b1dca6 |
+ - 'mkdirp': A minimal "mkdir -p FILE" command.
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
* mytest.root/postclean.req causes fresh rsync (with delete) after
|
|
|
b1dca6 |
test if present
|
|
|
b1dca6 |
|
|
|
b1dca6 |
@@ -859,6 +879,7 @@ main (int argc, char **argv)
|
|
|
b1dca6 |
int nt = tokenize (the_line, the_words, 3);
|
|
|
b1dca6 |
int i;
|
|
|
b1dca6 |
|
|
|
b1dca6 |
+ /* Expand variables. */
|
|
|
b1dca6 |
for (i = 1; i < nt; ++i)
|
|
|
b1dca6 |
{
|
|
|
b1dca6 |
if (memcmp (the_words[i], "$B/", 3) == 0)
|
|
|
b1dca6 |
@@ -875,6 +896,10 @@ main (int argc, char **argv)
|
|
|
b1dca6 |
the_words[i] = concat (new_root_path,
|
|
|
b1dca6 |
support_libdir_prefix,
|
|
|
b1dca6 |
the_words[i] + 2, NULL);
|
|
|
b1dca6 |
+ else if (memcmp (the_words[i], "$complocaledir/", 15) == 0)
|
|
|
b1dca6 |
+ the_words[i] = concat (new_root_path,
|
|
|
b1dca6 |
+ support_complocaledir_prefix,
|
|
|
b1dca6 |
+ the_words[i] + 14, NULL);
|
|
|
b1dca6 |
/* "exec" and "cwd" use inside-root paths. */
|
|
|
b1dca6 |
else if (strcmp (the_words[0], "exec") != 0
|
|
|
b1dca6 |
&& strcmp (the_words[0], "cwd") != 0
|
|
|
b1dca6 |
@@ -892,6 +917,9 @@ main (int argc, char **argv)
|
|
|
b1dca6 |
the_words[2] = concat (the_words[2], the_words[1], NULL);
|
|
|
b1dca6 |
}
|
|
|
b1dca6 |
|
|
|
b1dca6 |
+ /* Run the following commands in the_words[0] with NT number of
|
|
|
b1dca6 |
+ arguments (including the command). */
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
if (nt == 2 && strcmp (the_words[0], "so") == 0)
|
|
|
b1dca6 |
{
|
|
|
b1dca6 |
the_words[2] = concat (new_root_path, support_libdir_prefix,
|
|
|
b1dca6 |
@@ -961,6 +989,14 @@ main (int argc, char **argv)
|
|
|
b1dca6 |
{
|
|
|
b1dca6 |
be_su = 1;
|
|
|
b1dca6 |
}
|
|
|
b1dca6 |
+ else if (nt == 3 && strcmp (the_words[0], "mkdirp") == 0)
|
|
|
b1dca6 |
+ {
|
|
|
b1dca6 |
+ long int m;
|
|
|
b1dca6 |
+ errno = 0;
|
|
|
b1dca6 |
+ m = strtol (the_words[1], NULL, 0);
|
|
|
b1dca6 |
+ TEST_COMPARE (errno, 0);
|
|
|
b1dca6 |
+ xmkdirp (the_words[2], m);
|
|
|
b1dca6 |
+ }
|
|
|
b1dca6 |
else if (nt > 0 && the_words[0][0] != '#')
|
|
|
b1dca6 |
{
|
|
|
b1dca6 |
fprintf (stderr, "\033[31minvalid [%s]\033[0m\n", the_words[0]);
|