source: icGREP/icgrep-devel/llvm-3.8.0.src/test/Bindings/OCaml/linker.ml @ 5027

Last change on this file since 5027 was 5027, checked in by cameron, 3 years ago

Upgrade to llvm 3.8

File size: 1.5 KB
Line 
1(* RUN: cp %s %T/linker.ml
2 * RUN: %ocamlc -g -w +A -package llvm.linker -linkpkg %T/linker.ml -o %t
3 * RUN: %t
4 * RUN: %ocamlopt -g -w +A -package llvm.linker -linkpkg %T/linker.ml -o %t
5 * RUN: %t
6 * XFAIL: vg_leak
7 *)
8
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
11         little ones. *)
12
13open Llvm
14open Llvm_linker
15
16let context = global_context ()
17let void_type = Llvm.void_type context
18
19(* Tiny unit test framework - really just to help find which line is busted *)
20let print_checkpoints = false
21
22let suite name f =
23  if print_checkpoints then
24    prerr_endline (name ^ ":");
25  f ()
26
27
28(*===-- Linker -----------------------------------------------------------===*)
29
30let test_linker () =
31  let fty = function_type void_type [| |] in
32
33  let make_module name =
34    let m = create_module context name in
35    let fn = define_function ("fn_" ^ name) fty m in
36    ignore (build_ret_void (builder_at_end context (entry_block fn)));
37    m
38  in
39
40  let m1 = make_module "one"
41  and m2 = make_module "two" in
42  link_modules' m1 m2;
43  dispose_module m1;
44
45  let m1 = make_module "one"
46  and m2 = make_module "two" in
47  link_modules' m1 m2;
48  dispose_module m1;
49
50  let m1 = make_module "one"
51  and m2 = make_module "one" in
52  try
53    link_modules' m1 m2;
54    failwith "must raise"
55  with Error _ ->
56    dispose_module m1
57
58(*===-- Driver ------------------------------------------------------------===*)
59
60let _ =
61  suite "linker" test_linker
Note: See TracBrowser for help on using the repository browser.