diff --git a/test/tinytest.c b/test/tinytest.c index d0b77f74..87d1fc3b 100644 --- a/test/tinytest.c +++ b/test/tinytest.c @@ -67,7 +67,7 @@ const char *cur_test_name = NULL; #ifdef WIN32 /** Pointer to argv[0] for win32. */ -static const char *commandname = NULL; +static char *commandname = NULL; #endif static void usage(struct testgroup_t *groups, int list_groups) @@ -291,7 +291,19 @@ 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], '.'); + if (0 != sp) { + if (0 != stricmp (sp, ".exe")) { /* not exe extension */ + sp = 0; + } + } + if (0 == sp) { + commandname = (char*) malloc (strlen(v[0]) + 5); + strcpy (commandname, v[0]); + strcat (commandname, ".exe"); + } + else + commandname = strdup (v[0]); #endif for (i=1; i= 1) printf("%d tests ok. (%d skipped)\n", n_ok, n_skipped); + free (commandname); + return (n_bad == 0) ? 0 : 1; }