]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Synchronize with upstream tinytest.
authorNick Mathewson <nickm@torproject.org>
Mon, 13 Feb 2012 22:28:15 +0000 (17:28 -0500)
committerNick Mathewson <nickm@torproject.org>
Mon, 13 Feb 2012 22:29:31 +0000 (17:29 -0500)
The big change here is a patch (first added to Libevent by Ed Day)
to make sure that the CreateProcess forked-test trick works even
when the main test program is invoked without its .exe suffix.

changes/tinytest_update [new file with mode: 0644]
src/test/tinytest.c
src/test/tinytest.h
src/test/tinytest_demo.c
src/test/tinytest_macros.h

diff --git a/changes/tinytest_update b/changes/tinytest_update
new file mode 100644 (file)
index 0000000..069fc5a
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor bugfixes:
+    - Update to the latest version of the tinytest unit testing framework.
+      This includes a couple of bugfixes that can be relevant for running
+      forked unit tests on Windows.
index 8caa4f5453dc5ce6a682e3a898b67267e4f5962c..27fa94c2cab273dfad0c150ab44c8852392951cd 100644 (file)
@@ -1,4 +1,4 @@
-/* tinytest.c -- Copyright 2009-2010 Nick Mathewson
+/* tinytest.c -- Copyright 2009-2012 Nick Mathewson
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+#ifdef TINYTEST_LOCAL
+#include "tinytest_local.h"
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
 
-#ifdef TINYTEST_LOCAL
-#include "tinytest_local.h"
-#endif
-
 #ifdef _WIN32
 #include <windows.h>
 #else
@@ -66,8 +65,8 @@ const char *cur_test_prefix = NULL; /**< prefix of the current test group */
 const char *cur_test_name = NULL;
 
 #ifdef _WIN32
-/** Pointer to argv[0] for win32. */
-static const char *commandname = NULL;
+/* Copy of argv[0] for win32. */
+static char commandname[MAX_PATH+1];
 #endif
 
 static void usage(struct testgroup_t *groups, int list_groups)
@@ -291,7 +290,12 @@ tinytest_main(int c, const char **v, struct testgroup_t *groups)
        int i, j, n=0;
 
 #ifdef _WIN32
-       commandname = v[0];
+       const char *sp = strrchr(v[0], '.');
+       const char *extension = "";
+       if (!sp || stricmp(sp, ".exe"))
+               extension = ".exe"; /* Add an exe so CreateProcess will work */
+       snprintf(commandname, sizeof(commandname), "%s%s", v[0], extension);
+       commandname[MAX_PATH]='\0';
 #endif
        for (i=1; i<c; ++i) {
                if (v[i][0] == '-') {
index cbe28b7f512ce5dedc5c1d6737ae72718d0841b9..7ce7858e6423b6ccc18b9f4fd584b0b77f9dfba2 100644 (file)
@@ -1,4 +1,4 @@
-/* tinytest.h -- Copyright 2009-2010 Nick Mathewson
+/* tinytest.h -- Copyright 2009-2012 Nick Mathewson
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
index 98cb773d1a8259acf5bfd966befc2276b54d898d..be95ce4c1db57285d03ea8f707d092cb1f4e0f72 100644 (file)
@@ -1,4 +1,4 @@
-/* tinytest_demo.c -- Copyright 2009-2010 Nick Mathewson
+/* tinytest_demo.c -- Copyright 2009-2012 Nick Mathewson
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
index 032393ccf762500228c6f9647e123cf8a7cec0fa..1a07ad147bdc828142eaf5dd896f2f95fd2e43f6 100644 (file)
@@ -1,4 +1,4 @@
-/* tinytest_macros.h -- Copyright 2009-2010 Nick Mathewson
+/* tinytest_macros.h -- Copyright 2009-2012 Nick Mathewson
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions