public inbox for
help / color / mirror / Atom feed
From: Jon TURNEY <>
Subject: [newlib-cygwin] Cygwin: Ensure temporary directory used by tests exists
Date: Sun,  8 Nov 2020 15:21:53 +0000 (GMT)	[thread overview]
Message-ID: <> (raw);h=f3ed5f2fe029d74372aca68b18936e164ff47cf7

commit f3ed5f2fe029d74372aca68b18936e164ff47cf7
Author: Jon Turney <>
Date:   Thu Oct 29 14:43:32 2020 +0000

    Cygwin: Ensure temporary directory used by tests exists
    By default, libltp tests will create temporary files in a subdirectory
    of /tmp, which will (nowadays) be located relative to the test DLL (by
    assuming that it is in /bin).  This will evaluate to the directory
    $target_builddir/winsup/tmp, which doesn't exist.
    The location used for these temporary files can be explicitly controlled
    by setting the TDIRECTORY env var.  Arrange to set that env var to the
    /cygdrive path of a tmp subdirectory of the build directory.
    Unfortunately, libltp doesn't clean the temporary directory if
    TDIRECTORY is set, and some tests assume they are started in a clean
    directory, so we need to do that in tcl.

 winsup/testsuite/           | 10 ++++++++--
 winsup/testsuite/cygrun.c              |  5 ++++-
 winsup/testsuite/winsup.api/winsup.exp |  4 +++-
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/winsup/testsuite/ b/winsup/testsuite/
index b77961878..3b5a251b2 100644
--- a/winsup/testsuite/
+++ b/winsup/testsuite/
@@ -97,7 +97,8 @@ force:
-	-rm -f *.o *.dll *.a *.exp junk *.bak *.base *.exe testsuite/* *.d *.dat
+	-rm -f *.o *.dll *.a *.exp junk *.bak *.base *.exe *.d *.dat
+	-rm -rf testsuite
 maintainer-clean realclean: clean
 	@echo "This command is intended for maintainers to use;"
@@ -123,6 +124,11 @@ $(RUNTIME) : $(cygwin_build)/Makefile
 # Set to $(target_alias)/ for cross.
 target_subdir = @target_subdir@
+# temporary directory to be used for files created by tests (as an absolute,
+# /cygdrive path, so it can be understood by the test DLL, which will have
+# different mount table)
+tmpdir = $(shell cygpath -ma $(objdir)/testsuite/tmp/ | sed -e 's#^\([A-Z]\):#/cygdrive/\L\1#')
 site.exp: ./config.status Makefile
 	@echo "Making a new config file..."
 	-@rm -f ./tmp?
@@ -142,7 +148,7 @@ site.exp: ./config.status Makefile
 # CFLAGS is set even though it's empty to show we reserve the right to set it.
 	@echo "set CFLAGS \"$(ALL_CFLAGS)\"" >> ./tmp0
 	@echo "set MINGW_CXX \"$(MINGW_CXX)\"" >> ./tmp0
-	echo "set tmpdir $(objdir)/testsuite" >> ./tmp0
+	@echo "set tmpdir $(tmpdir)" >> ./tmp0
 	@echo "set ltp_includes \"$(realpath $(libltp_srcdir))/include\"" >> ./tmp0
 	@echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0
 	@cat ./tmp0 > site.exp
diff --git a/winsup/testsuite/cygrun.c b/winsup/testsuite/cygrun.c
index d1f53aad3..65d859d59 100644
--- a/winsup/testsuite/cygrun.c
+++ b/winsup/testsuite/cygrun.c
@@ -25,10 +25,13 @@ main (int argc, char **argv)
   if (argc < 2)
-      fprintf (stderr, "Usage: cygrun [program]\n");
+      fprintf (stderr, "Usage: cygrun [program] [tmpdir]\n");
       exit (0);
+  if (argc >= 3)
+    SetEnvironmentVariable ("TDIRECTORY", argv[2]);
   SetEnvironmentVariable ("CYGWIN_TESTING", "1");
   if ((p = getenv ("CYGWIN")) == NULL || (strstr (p, "ntsec") == NULL))
diff --git a/winsup/testsuite/winsup.api/winsup.exp b/winsup/testsuite/winsup.api/winsup.exp
index 1550b9445..cd5964d47 100644
--- a/winsup/testsuite/winsup.api/winsup.exp
+++ b/winsup/testsuite/winsup.api/winsup.exp
@@ -68,7 +68,9 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/$subdir/*/*.{cc
 	    } else {
 	       set redirect_output /dev/null
-	    ws_spawn "$rootme/cygrun ./$base.exe > $redirect_output"
+	    file mkdir $tmpdir/$base
+	    ws_spawn "$rootme/cygrun ./$base.exe $tmpdir/$base > $redirect_output"
+	    file delete -force $tmpdir/$base
 	    if { $rv } {
 		fail "$testcase (execute)"
 		if { $xfail_expected } {

                 reply	other threads:[~2020-11-08 15:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).