llvm-6502/test/Bindings/Ocaml/target.ml
Daniel Dunbar 0a248bf714 [PR11606] ocaml bindings tests produce binaries in source dir
- Workaround for ocamlopt producing outputs adjacent to its source inputs, by
   having the tests copy the inputs into temporary directories in the output
   paths before building.

 - Patch by edward-san.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189081 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-23 00:55:32 +00:00

63 lines
1.7 KiB
OCaml

(* RUN: rm -rf %t.builddir
* RUN: mkdir -p %t.builddir
* RUN: cp %s %t.builddir
* RUN: %ocamlopt -warn-error A llvm.cmxa llvm_target.cmxa %t.builddir/target.ml -o %t
* RUN: %t %t.bc
* XFAIL: vg_leak
*)
(* Note: It takes several seconds for ocamlopt to link an executable with
libLLVMCore.a, so it's better to write a big test than a bunch of
little ones. *)
open Llvm
open Llvm_target
let context = global_context ()
let i32_type = Llvm.i32_type context
let i64_type = Llvm.i64_type context
(* Tiny unit test framework - really just to help find which line is busted *)
let print_checkpoints = false
let suite name f =
if print_checkpoints then
prerr_endline (name ^ ":");
f ()
(*===-- Fixture -----------------------------------------------------------===*)
let filename = Sys.argv.(1)
let m = create_module context filename
(*===-- Target Data -------------------------------------------------------===*)
let test_target_data () =
let td = DataLayout.create (target_triple m) in
let sty = struct_type context [| i32_type; i64_type |] in
ignore (DataLayout.as_string td);
ignore (byte_order td);
ignore (pointer_size td);
ignore (intptr_type td);
ignore (size_in_bits td sty);
ignore (store_size td sty);
ignore (abi_size td sty);
ignore (stack_align td sty);
ignore (preferred_align td sty);
ignore (preferred_align_of_global td (declare_global sty "g" m));
ignore (element_at_offset td sty (Int64.of_int 1));
ignore (offset_of_element td sty 1);
DataLayout.dispose td
(*===-- Driver ------------------------------------------------------------===*)
let _ =
suite "target data" test_target_data;
dispose_module m