[commit: testsuite] master: Fix egregious pathchar business in linker_unload. (4423f10)

git at git.haskell.org git at git.haskell.org
Sat Sep 14 07:47:26 CEST 2013


Repository : ssh://git@git.haskell.org/testsuite

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/4423f10bb605947fc96041c3fb5d7259e4f4c36e/testsuite

>---------------------------------------------------------------

commit 4423f10bb605947fc96041c3fb5d7259e4f4c36e
Author: Edward Z. Yang <ezyang at mit.edu>
Date:   Fri Sep 13 22:45:02 2013 -0700

    Fix egregious pathchar business in linker_unload.
    
    Signed-off-by: Edward Z. Yang <ezyang at mit.edu>


>---------------------------------------------------------------

4423f10bb605947fc96041c3fb5d7259e4f4c36e
 tests/rts/Makefile        |    2 +-
 tests/rts/linker_unload.c |   27 +++++++++++++++++++++++----
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/tests/rts/Makefile b/tests/rts/Makefile
index 9fbf7de..0a11a2f 100644
--- a/tests/rts/Makefile
+++ b/tests/rts/Makefile
@@ -95,5 +95,5 @@ linker_unload:
 	$(RM) Test.o Test.hi
 	"$(TEST_HC)" $(TEST_HC_OPTS) -c Test.hs -v0
 	# -rtsopts causes a warning
-	"$(TEST_HC)" $(filter-out -rtsopts, $(TEST_HC_OPTS)) linker_unload.c -o linker_unload -no-hs-main
+	"$(TEST_HC)" $(filter-out -rtsopts, $(TEST_HC_OPTS)) linker_unload.c -o linker_unload -no-hs-main -optc-Werror
 	./linker_unload $(BASE) $(GHC_PRIM) $(INTEGER_GMP)
diff --git a/tests/rts/linker_unload.c b/tests/rts/linker_unload.c
index 859dd4d..e9a9bbc 100644
--- a/tests/rts/linker_unload.c
+++ b/tests/rts/linker_unload.c
@@ -1,15 +1,19 @@
 #include <stdio.h>
+#include <stdlib.h>
+#include <malloc.h>
 #include "Rts.h"
 
 #define ITERATIONS 10000
+
+#if defined(mingw32_HOST_OS)
+#define OBJPATH L"Test.o"
+#else
 #define OBJPATH "Test.o"
+#endif
 
 typedef int testfun(int);
 
-#define BASE "/home/simon/code-all/work/ghc-validate/libraries/base/dist-install/build/libHSbase-4.7.0.0.a"
-#define GHCPRIM "/home/simon/code-all/work/ghc-validate/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.3.1.0.a"
-
-void loadPkg(char *path)
+void loadPkg(pathchar *path)
 {
     int r;
 
@@ -30,7 +34,22 @@ int main (int argc, char *argv[])
     initLinker();
 
     for (i=1; i < argc; i++) {
+#if defined(mingw32_HOST_OS)
+        size_t len = mbstowcs(NULL, argv[i], 0) + 1;
+        if (len == -1) {
+            errorBelch("invalid multibyte sequence in argument %d: %s", i, argv[i]);
+            exit(1);
+        }
+        wchar_t *buf = (wchar_t*)_alloca(len * sizeof(wchar_t));
+        size_t len2 = mbstowcs(buf, argv[i], len);
+        if (len != len2 + 1) {
+            errorBelch("something fishy is going on in argument %d: %s", i, argv[i]);
+            exit(1);
+        }
+        loadPkg(buf);
+#else
         loadPkg(argv[i]);
+#endif
     }
 
     for (i=0; i < ITERATIONS; i++) {




More information about the ghc-commits mailing list