From 3b47a11654e4a4fe4931cb7fdce08b75ac667be1 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 13 Feb 2012 17:28:15 -0500 Subject: [PATCH] Synchronize with upstream tinytest. 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 | 4 ++++ src/test/tinytest.c | 20 ++++++++++++-------- src/test/tinytest.h | 2 +- src/test/tinytest_demo.c | 2 +- src/test/tinytest_macros.h | 2 +- 5 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 changes/tinytest_update diff --git a/changes/tinytest_update b/changes/tinytest_update new file mode 100644 index 0000000000..069fc5a2b2 --- /dev/null +++ b/changes/tinytest_update @@ -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. diff --git a/src/test/tinytest.c b/src/test/tinytest.c index 8caa4f5453..27fa94c2ca 100644 --- a/src/test/tinytest.c +++ b/src/test/tinytest.c @@ -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 @@ -22,16 +22,15 @@ * (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 #include #include #include -#ifdef TINYTEST_LOCAL -#include "tinytest_local.h" -#endif - #ifdef _WIN32 #include #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