public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Fix testing with read-only source directory
@ 2017-12-15 20:51 Joseph Myers
  2017-12-15 22:36 ` Jonathan Nieder
  0 siblings, 1 reply; 2+ messages in thread
From: Joseph Myers @ 2017-12-15 20:51 UTC (permalink / raw)
  To: libc-alpha

Three tests fail with a read-only source directory because they try to
write into the source directory.  None of these write into it in a way
that should actually be problematic for concurrent builds sharing the
same writable source directory, but avoiding any writing into the
source directory (from testing, or from building glibc if the source
timestamps are properly ordered) is still a good idea, as being able
to build with read-only sources helps make sure there isn't anything
that could cause problems for concurrent builds.

This patch changes the tests in question to use either /tmp or the
build directory to write their temporary files (or to test O_TMPFILE,
as applicable).

Tested for x86_64.

2017-12-15  Joseph Myers  <joseph@codesourcery.com>

	* io/Makefile (tst-open-tmpfile-ARGS): New variable.
	* posix/tst-mmap-offset.c (fname): Use /tmp.
	* stdlib/tst-setcontext3.sh (tempfile): Use ${objpfx}.

diff --git a/io/Makefile b/io/Makefile
index b3ee5ae..c725195 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -109,6 +109,8 @@ test-stat2-ARGS = Makefile . $(objpfx)test-stat2
 
 tst-statvfs-ARGS = $(objpfx)tst-statvfs tst-statvfs.c /tmp
 
+tst-open-tmpfile-ARGS = --test-dir=$(objpfx)
+
 ifeq ($(run-built-tests),yes)
 $(objpfx)ftwtest.out: ftwtest-sh $(objpfx)ftwtest
 	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
diff --git a/posix/tst-mmap-offset.c b/posix/tst-mmap-offset.c
index 5bb88aa..5e940c8 100644
--- a/posix/tst-mmap-offset.c
+++ b/posix/tst-mmap-offset.c
@@ -29,7 +29,7 @@
 
 static int fd;
 static long int page_shift;
-static char fname[] = "tst-mmap-offset-XXXXXX";
+static char fname[] = "/tmp/tst-mmap-offset-XXXXXX";
 
 static void
 do_prepare (int argc, char **argv)
diff --git a/stdlib/tst-setcontext3.sh b/stdlib/tst-setcontext3.sh
index 158d0dc..014e7cf 100644
--- a/stdlib/tst-setcontext3.sh
+++ b/stdlib/tst-setcontext3.sh
@@ -34,7 +34,7 @@ cleanup() {
 }
 trap cleanup 0
 
-tempfile=$(mktemp "tst-setcontext3.XXXXXXXXXX")
+tempfile=$(mktemp "${objpfx}tst-setcontext3.XXXXXXXXXX")
 
 # We want to run the test program and see if secontext called
 # exit() and wrote out the test file we specified.  If the

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: Fix testing with read-only source directory
  2017-12-15 20:51 Fix testing with read-only source directory Joseph Myers
@ 2017-12-15 22:36 ` Jonathan Nieder
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Nieder @ 2017-12-15 22:36 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

Joseph Myers wrote:

> Three tests fail with a read-only source directory because they try to
> write into the source directory.  None of these write into it in a way
> that should actually be problematic for concurrent builds sharing the
> same writable source directory, but avoiding any writing into the
> source directory (from testing, or from building glibc if the source
> timestamps are properly ordered) is still a good idea, as being able
> to build with read-only sources helps make sure there isn't anything
> that could cause problems for concurrent builds.
>
> This patch changes the tests in question to use either /tmp or the
> build directory to write their temporary files (or to test O_TMPFILE,
> as applicable).
>
> Tested for x86_64.
>
> 2017-12-15  Joseph Myers  <joseph@codesourcery.com>
>
> 	* io/Makefile (tst-open-tmpfile-ARGS): New variable.
> 	* posix/tst-mmap-offset.c (fname): Use /tmp.
> 	* stdlib/tst-setcontext3.sh (tempfile): Use ${objpfx}.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Thanks for fixing it.

[...]
> --- a/posix/tst-mmap-offset.c
> +++ b/posix/tst-mmap-offset.c
> @@ -29,7 +29,7 @@
>  
>  static int fd;
>  static long int page_shift;
> -static char fname[] = "tst-mmap-offset-XXXXXX";
> +static char fname[] = "/tmp/tst-mmap-offset-XXXXXX";

It would be nice if this kind of test respected $TMPDIR, but that's an
orthogonal problem --- what this patch does is consistent with the
other tests in this dir.

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

end of thread, other threads:[~2017-12-15 22:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-15 20:51 Fix testing with read-only source directory Joseph Myers
2017-12-15 22:36 ` Jonathan Nieder

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