1 (* RUN: rm -rf %t && mkdir -p %t && cp %s %t/irreader.ml
2 * RUN: %ocamlc -g -w +A -package llvm.irreader -linkpkg %t/irreader.ml -o %t/executable
4 * RUN: %ocamlopt -g -w +A -package llvm.irreader -linkpkg %t/irreader.ml -o %t/executable
9 (* Note: It takes several seconds for ocamlopt to link an executable with
10 libLLVMCore.a, so it's better to write a big test than a bunch of
16 let context = global_context
()
18 (* Tiny unit test framework - really just to help find which line is busted *)
19 let print_checkpoints = false
22 if print_checkpoints then
23 prerr_endline
(name ^
":");
27 Printexc.record_backtrace
true
30 if not cond
then failwith
"insist"
33 (*===-- IR Reader ---------------------------------------------------------===*)
35 let test_irreader () =
37 let buf = MemoryBuffer.of_string
"@foo = global i32 42" in
38 let m = parse_ir
context buf in
39 match lookup_global
"foo" m with
41 insist ((global_initializer foo
) = (const_int
(i32_type
context) 42))
47 let buf = MemoryBuffer.of_string
"@foo = global garble" in
49 ignore
(parse_ir
context buf);
51 with Llvm_irreader.Error
_ ->
56 (*===-- Driver ------------------------------------------------------------===*)
59 suite "irreader" test_irreader