[v2] Mount /tmp as tmpfs in test-container and run utime tests in it
Commit Message
From: Arjun Shankar <arjun@redhat.com>
tst-utime.c, tst-utimes.c, and tst-futimens.c create a temporary file in
/tmp to test Y2038 support in the corresponding functions. This causes
the tests to fail when /tmp is mounted as a filesystem that has a Y2038
bug; e.g. XFS.
This commit changes test-container.c to mount /tmp as a tmpfs filesystem
and moves the utime tests to the tests-container target so that they run
in a container against a known-good filesystem.
The test-container change of mounting /tmp as tmpfs led to one of the
existing container tests, elf/tst-ldconfig-ld_so_conf-update, to fail.
This commit also adjusts the test to not use /tmp any more.
---
Notes:
v1 ("Prefer /dev/shm over /tmp in utime family tests") here:
https://sourceware.org/pipermail/libc-alpha/2021-March/123486.html
I went a different way this time. Since we cannot touch /dev/shm and since
/tmp is not guaranteed to be tmpfs every time, I containerised the tests.
This meant modifying test-container to mount /tmp as tmpfs and adjusting one
existing container test that failed due to /tmp being a mount point.
---
elf/tst-ldconfig-ld_so_conf-update.c | 4 ++--
support/test-container.c | 4 +++-
sysdeps/unix/sysv/linux/Makefile | 5 +++--
3 files changed, 8 insertions(+), 5 deletions(-)
Comments
Another patchwork test, ignore or not at your peril ;-)
@@ -32,7 +32,7 @@
#define DSO "libldconfig-ld-mod.so"
-#define DSO_DIR "/tmp/tst-ldconfig"
+#define DSO_DIR "/tst-ldconfig"
#define CONF "/etc/ld.so.conf"
@@ -73,7 +73,7 @@ do_test (void)
"lib" (for regular shared libraries) or "ld-" (for ld-linux-*). */
char *mod_src_path = xasprintf ("%s/tst-ldconfig-ld-mod.so",
support_libdir_prefix);
- if (rename (mod_src_path, "/tmp/tst-ldconfig/libldconfig-ld-mod.so"))
+ if (rename (mod_src_path, DSO_DIR "/libldconfig-ld-mod.so"))
FAIL_EXIT1 ("Renaming/moving the DSO failed: %m");
free (mod_src_path);
@@ -1160,7 +1160,9 @@ main (int argc, char **argv)
sprintf (pid_buf, "%lu", (long unsigned)child);
setenv ("PID_OUTSIDE_CONTAINER", pid_buf, 0);
- maybe_xmkdir ("/tmp", 0755);
+ maybe_xmkdir ("/tmp", 1777);
+ if (mount ("none", "/tmp", "tmpfs", MS_NOEXEC | MS_NOSUID | MS_NODEV, NULL) < 0)
+ FAIL_EXIT1 ("can't mount tmpfs onto /tmp\n");
/* Now that we're pid 1 (effectively "root") we can mount /proc */
maybe_xmkdir ("/proc", 0777);
@@ -107,8 +107,9 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
test-errno-linux tst-memfd_create tst-mlock2 tst-pkey \
tst-rlimit-infinity tst-ofdlocks tst-gettid tst-gettid-kill \
tst-tgkill tst-sysvsem-linux tst-sysvmsg-linux tst-sysvshm-linux \
- tst-timerfd tst-ppoll tst-futimens tst-utime tst-utimes \
- tst-clock_adjtime tst-adjtimex tst-ntp_adjtime
+ tst-timerfd tst-ppoll tst-clock_adjtime tst-adjtimex tst-ntp_adjtime
+
+tests-container += tst-futimens tst-utime tst-utimes
# Test for the symbol version of fcntl that was replaced in glibc 2.28.
ifeq ($(have-GLIBC_2.27)$(build-shared),yesyes)