public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] Mount /tmp as tmpfs in test-container and run utime tests in it
@ 2021-03-09 22:54 Arjun Shankar
  2021-03-10  1:32 ` DJ Delorie
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Arjun Shankar @ 2021-03-09 22:54 UTC (permalink / raw)
  To: libc-alpha
  Cc: Florian Weimer, Lukasz Majewski, Adhemerval Zanella,
	Mike Frysinger, DJ Delorie

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(-)

diff --git a/elf/tst-ldconfig-ld_so_conf-update.c b/elf/tst-ldconfig-ld_so_conf-update.c
index e8bd4c3598..7462516f59 100644
--- a/elf/tst-ldconfig-ld_so_conf-update.c
+++ b/elf/tst-ldconfig-ld_so_conf-update.c
@@ -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);
 
diff --git a/support/test-container.c b/support/test-container.c
index 28cc44d9f1..0924bdc2e7 100644
--- a/support/test-container.c
+++ b/support/test-container.c
@@ -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);
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index e42bc7f13b..cdbeb81f9c 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -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)
-- 
2.29.2


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2021-03-11 22:58 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09 22:54 [PATCH v2] Mount /tmp as tmpfs in test-container and run utime tests in it Arjun Shankar
2021-03-10  1:32 ` DJ Delorie
2021-03-10 12:33   ` Adhemerval Zanella
2021-03-10 14:13     ` Arjun Shankar
2021-03-10 14:56       ` Adhemerval Zanella
2021-03-10 15:21         ` Siddhesh Poyarekar
2021-03-10 14:32     ` Mike Frysinger
2021-03-10 18:31     ` DJ Delorie
2021-03-10 18:53       ` Adhemerval Zanella
2021-03-10 19:00         ` DJ Delorie
2021-03-10 19:12           ` Adhemerval Zanella
2021-03-11 16:38         ` Carlos O'Donell
2021-03-11 17:16           ` Adhemerval Zanella
2021-03-11 17:26             ` Carlos O'Donell
2021-03-11 18:59             ` Mike Frysinger
2021-03-11 22:58               ` Carlos O'Donell
2021-03-11  1:18 ` DJ Delorie
2021-03-11  2:27 ` DJ Delorie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).