Merge commit '58147d67806e1f54c447d7eabac35b1a5086c3a6'
[bpt/guile.git] / test-suite / standalone / test-unwind.c
index 2d6894d..3aa3e15 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004, 2005, 2008, 2009, 2010 Free Software Foundation, Inc.
+/* Copyright (C) 2004, 2005, 2008, 2009, 2010, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -129,7 +129,7 @@ check_flag1 (const char *tag, void (*func)(void), int val)
   if (flag1 != val)
     {
       printf ("%s failed\n", tag);
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 }
 
@@ -170,7 +170,7 @@ check_cont (int rewindable)
       if (rewindable)
        return;
       printf ("continuation not blocked\n");
-      exit (1);
+      exit (EXIT_FAILURE);
     }
   else
     {
@@ -178,7 +178,7 @@ check_cont (int rewindable)
       if (!rewindable)
        return;
       printf ("continuation didn't work\n");
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 }
 
@@ -200,9 +200,20 @@ check_ports ()
 #define FILENAME_TEMPLATE "/check-ports.XXXXXX"
   char *filename;
   const char *tmpdir = getenv ("TMPDIR");
+#ifdef __MINGW32__
+  extern int mkstemp (char *);
 
+  /* On Windows neither $TMPDIR nor /tmp can be relied on.  */
+  if (tmpdir == NULL)
+    tmpdir = getenv ("TEMP");
+  if (tmpdir == NULL)
+    tmpdir = getenv ("TMP");
+  if (tmpdir == NULL)
+    tmpdir = "/";
+#else
   if (tmpdir == NULL)
     tmpdir = "/tmp";
+#endif
 
   filename = alloca (strlen (tmpdir) + sizeof (FILENAME_TEMPLATE) + 1);
   strcpy (filename, tmpdir);
@@ -211,7 +222,7 @@ check_ports ()
   /* Sanity check: Make sure that `filename' is actually writeable.
      We used to use mktemp(3), but that is now considered a security risk.  */
   if (0 > mkstemp (filename))
-    exit (1);
+    exit (EXIT_FAILURE);
 
   scm_dynwind_begin (0);
   {
@@ -239,7 +250,7 @@ check_ports ()
     if (scm_is_false (scm_equal_p (res, scm_version ())))
       {
        printf ("ports didn't work\n");
-       exit (1);
+       exit (EXIT_FAILURE);
       }
   }
   scm_dynwind_end ();
@@ -262,13 +273,13 @@ check_fluid ()
   if (!scm_is_eq (x, scm_from_int (13)))
     {
       printf ("setting fluid didn't work\n");
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 
   if (!scm_is_eq (scm_fluid_ref (f), scm_from_int (12)))
     {
       printf ("resetting fluid didn't work\n");
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 }
 
@@ -287,7 +298,7 @@ inner_main (void *data, int argc, char **argv)
 
   check_fluid ();
 
-  exit (0);
+  exit (EXIT_SUCCESS);
 }
 
 int