Expose ExecutionEngine::getTargetData() to c and ocaml bindings.
[oota-llvm.git] / test / Bindings / Ocaml / executionengine.ml
index d2ba147c1638f7351cbca75c0a8a7917af59b24b..d238076a06541fb7a1a19df6082040ac0b5b735d 100644 (file)
@@ -1,9 +1,10 @@
-(* RUN: %ocamlc -warn-error A llvm.cma llvm_executionengine.cma %s -o %t
+(* RUN: %ocamlc -warn-error A llvm.cma llvm_target.cma llvm_executionengine.cma %s -o %t
  * RUN: ./%t %t.bc
  *)
 
 open Llvm
 open Llvm_executionengine
+open Llvm_target
 
 (* Note that this takes a moment to link, so it's best to keep the number of
    individual tests low. *)
@@ -40,14 +41,14 @@ let test_genericvalue () =
   let intgv = GenericValue.of_int i32_type 3 in
   assert (3  = GenericValue.as_int intgv);
   
-  let i32gv = GenericValue.of_int32 i32_type 4l in
-  assert (4l = GenericValue.as_int32 i32gv);
+  let i32gv = GenericValue.of_int32 i32_type (Int32.of_int 4) in
+  assert ((Int32.of_int 4) = GenericValue.as_int32 i32gv);
   
-  let nigv = GenericValue.of_nativeint i32_type 5n in
-  assert (5n = GenericValue.as_nativeint nigv);
+  let nigv = GenericValue.of_nativeint i32_type (Nativeint.of_int 5) in
+  assert ((Nativeint.of_int 5) = GenericValue.as_nativeint nigv);
   
-  let i64gv = GenericValue.of_int64 i64_type 6L in
-  assert (6L = GenericValue.as_int64 i64gv)
+  let i64gv = GenericValue.of_int64 i64_type (Int64.of_int 6) in
+  assert ((Int64.of_int 6) = GenericValue.as_int64 i64gv)
 
 let test_executionengine () =
   (* create *)
@@ -92,6 +93,13 @@ let test_executionengine () =
   
   (* run_static_dtors *)
   ExecutionEngine.run_static_dtors ee;
+
+  (* Show that the target data binding links and runs.*)
+  let td = ExecutionEngine.target_data ee in
+
+  (* Demonstrate that a garbage pointer wasn't returned. *)
+  let ty = intptr_type td in
+  if ty != i32_type && ty != i64_type then bomb "target_data did not work";
   
   (* dispose *)
   ExecutionEngine.dispose ee