diff options
-rw-r--r-- | testsuite/Makefile | 5 | ||||
-rw-r--r-- | testsuite/tests/lib-dynlink-csharp/Makefile | 58 | ||||
-rw-r--r-- | testsuite/tests/lib-dynlink-csharp/bytecode.reference | 7 | ||||
-rwxr-xr-x | testsuite/tests/lib-dynlink-csharp/entry.c | 13 | ||||
-rwxr-xr-x | testsuite/tests/lib-dynlink-csharp/main.cs | 11 | ||||
-rwxr-xr-x | testsuite/tests/lib-dynlink-csharp/main.ml | 23 | ||||
-rw-r--r-- | testsuite/tests/lib-dynlink-csharp/native.reference | 7 | ||||
-rwxr-xr-x | testsuite/tests/lib-dynlink-csharp/plugin.ml | 4 |
8 files changed, 128 insertions, 0 deletions
diff --git a/testsuite/Makefile b/testsuite/Makefile index 6f5571972..a9e4b6c66 100644 --- a/testsuite/Makefile +++ b/testsuite/Makefile @@ -41,6 +41,11 @@ clean: FORCE (cd $$file && $(MAKE) BASEDIR=$(BASEDIR) clean && cd ../..); \ fi \ done + @for file in interactive/*; do \ + if [ -d $$file ]; then \ + (cd $$file && $(MAKE) BASEDIR=$(BASEDIR) clean && cd ../..); \ + fi \ + done report: FORCE @if [ ! -f _log ]; then echo "No '_log' file."; exit 1; fi diff --git a/testsuite/tests/lib-dynlink-csharp/Makefile b/testsuite/tests/lib-dynlink-csharp/Makefile new file mode 100644 index 000000000..774eaacac --- /dev/null +++ b/testsuite/tests/lib-dynlink-csharp/Makefile @@ -0,0 +1,58 @@ +CSC=csc + +default: prepare bytecode bytecode-dll native native-dll + +prepare: + @$(OCAMLC) -c plugin.ml + @$(OCAMLOPT) -o plugin.cmxs -shared plugin.ml + +bytecode: + @printf " ... testing 'bytecode':" + @if [ ! `which $(CSC) > /dev/null` ]; then \ + echo " => passed"; \ + else \ + $(OCAMLC) -output-obj -o main.dll dynlink.cma main.ml entry.c; \ + $(CSC) /out:main.exe main.cs; \ + ./main.exe > bytecode.result; \ + diff -q bytecode.reference bytecode.result > /dev/null && echo " => passed" || echo " => failed"; \ + fi + +bytecode-dll: + @printf " ... testing 'bytecode-dll':" + @if [ ! `which $(CSC) > /dev/null` ]; then \ + echo " => passed"; \ + else \ + $(OCAMLC) -output-obj -o main_obj.$(O) dynlink.cma entry.c main.ml; \ + $(MKDLL) -maindll -o main.dll main_obj.$(O) entry.$(O) ../../byterun/libcamlrun.$(A) $(BYTECCLIBS) -v; \ + $(CSC) /out:main.exe main.cs; \ + ./main.exe > bytecode.result; \ + diff -q bytecode.reference bytecode.result > /dev/null && echo " => passed" || echo " => failed"; \ + fi + +native: + @printf " ... testing 'native':" + @if [ ! `which $(CSC) > /dev/null` ]; then \ + echo " => passed"; \ + else \ + $(OCAMLOPT) -output-obj -o main.dll dynlink.cmxa entry.c main.ml; \ + $(CSC) /out:main.exe main.cs; \ + ./main.exe > native.result; \ + diff -q native.reference native.result > /dev/null && echo " => passed" || echo " => failed"; \ + fi + +native-dll: + @printf " ... testing 'native-dll':" + @if [ ! `which $(CSC) > /dev/null` ]; then \ + echo " => passed"; \ + else \ + $(OCAMLOPT) -output-obj -o main_obj.$(O) dynlink.cmxa entry.c main.ml; \ + $(MKDLL) -maindll -o main.dll main_obj.$(O) entry.$(O) ../../asmrun/libasmrun.lib -v; \ + $(CSC) /out:main.exe main.cs; \ + ./main.exe > native.result; \ + diff -q native.reference native.result > /dev/null && echo " => passed" || echo " => failed"; \ + fi + +clean: defaultclean + @rm -f *.result *.exe *.dll + +include ../../makefiles/Makefile.common diff --git a/testsuite/tests/lib-dynlink-csharp/bytecode.reference b/testsuite/tests/lib-dynlink-csharp/bytecode.reference new file mode 100644 index 000000000..65592193a --- /dev/null +++ b/testsuite/tests/lib-dynlink-csharp/bytecode.reference @@ -0,0 +1,7 @@ +Now starting the Caml engine. +Main is running. +Loading ../../../otherlibs/bigarray/bigarray.cma +I'm the plugin. +Loading plugin.cmo +I'm the plugin. +OK. diff --git a/testsuite/tests/lib-dynlink-csharp/entry.c b/testsuite/tests/lib-dynlink-csharp/entry.c new file mode 100755 index 000000000..13ecd73df --- /dev/null +++ b/testsuite/tests/lib-dynlink-csharp/entry.c @@ -0,0 +1,13 @@ +#include <caml/memory.h> +#include <caml/alloc.h> +#include <caml/mlvalues.h> +#include <caml/callback.h> +#include <caml/custom.h> +#include <caml/fail.h> + +__declspec(dllexport) void __stdcall start_caml_engine() { + char * argv[2]; + argv[0] = "--"; + argv[1] = NULL; + caml_startup(argv); +} diff --git a/testsuite/tests/lib-dynlink-csharp/main.cs b/testsuite/tests/lib-dynlink-csharp/main.cs new file mode 100755 index 000000000..a03bfd60a --- /dev/null +++ b/testsuite/tests/lib-dynlink-csharp/main.cs @@ -0,0 +1,11 @@ +using System.Runtime.InteropServices; + +public class M { + [DllImport("main.dll")] + public static extern void start_caml_engine(); + + public static void Main() { + System.Console.WriteLine("Now starting the Caml engine."); + start_caml_engine(); + } +} diff --git a/testsuite/tests/lib-dynlink-csharp/main.ml b/testsuite/tests/lib-dynlink-csharp/main.ml new file mode 100755 index 000000000..fd48914a6 --- /dev/null +++ b/testsuite/tests/lib-dynlink-csharp/main.ml @@ -0,0 +1,23 @@ +let load s = + Printf.printf "Loading %s\n%!" s; + try + Dynlink.loadfile s + with Dynlink.Error e -> + print_endline (Dynlink.error_message e) + +let () = + print_endline "Main is running."; + Dynlink.init (); + Dynlink.allow_unsafe_modules true; + let s1,s2 = + if Dynlink.is_native then + "../../../otherlibs/bigarray/bigarray.cmxs", + "plugin.cmxs" + else + "../../../otherlibs/bigarray/bigarray.cma", + "plugin.cmo" + in + load s1; + load s2; + print_endline "OK." + diff --git a/testsuite/tests/lib-dynlink-csharp/native.reference b/testsuite/tests/lib-dynlink-csharp/native.reference new file mode 100644 index 000000000..b6c9e5c43 --- /dev/null +++ b/testsuite/tests/lib-dynlink-csharp/native.reference @@ -0,0 +1,7 @@ +Now starting the Caml engine. +Main is running. +Loading ../../../otherlibs/bigarray/bigarray.cmxs +I'm the plugin. +Loading plugin.cmxs +I'm the plugin. +OK. diff --git a/testsuite/tests/lib-dynlink-csharp/plugin.ml b/testsuite/tests/lib-dynlink-csharp/plugin.ml new file mode 100755 index 000000000..39c46f3a1 --- /dev/null +++ b/testsuite/tests/lib-dynlink-csharp/plugin.ml @@ -0,0 +1,4 @@ +let f x = x.{2} + +let () = + print_endline "I'm the plugin." |