summaryrefslogtreecommitdiff
path: root/testsuite/tests/lib-dynlink-initializers/test4_main.ml
blob: d24880e0737031523cd66c071801f05114d89593 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
(* TEST
 include dynlink;
 readonly_files = "test4_plugin_a.ml test4_plugin_b.ml";
 libraries = "";
 shared-libraries;
 {
   setup-ocamlc.byte-build-env;
   {
     module = "test4_main.ml";
     ocamlc.byte;
   }{
     module = "test4_plugin_b.ml";
     ocamlc.byte;
   }{
     module = "test4_plugin_a.ml";
     ocamlc.byte;
   }{
     program = "test4_plugin.cma";
     flags = "-a";
     all_modules = "test4_plugin_a.cmo test4_plugin_b.cmo";
     ocamlc.byte;
   }{
     program = "${test_build_directory}/test4.byte";
     libraries = "dynlink";
     all_modules = "test4_main.cmo";
     ocamlc.byte;
     run;
   }
 }{
   native-dynlink;
   setup-ocamlopt.byte-build-env;
   {
     module = "test4_main.ml";
     ocamlopt.byte;
   }{
     module = "test4_plugin_b.ml";
     ocamlopt.byte;
   }{
     module = "test4_plugin_a.ml";
     ocamlopt.byte;
   }{
     program = "test4_plugin.cmxs";
     flags = "-shared";
     all_modules = "test4_plugin_a.cmx test4_plugin_b.cmx";
     ocamlopt.byte;
   }{
     program = "${test_build_directory}/test4.exe";
     libraries = "dynlink";
     all_modules = "test4_main.cmx";
     ocamlopt.byte;
     run;
   }
 }
*)

(* Check that a module in a shared library cannot refer to another
   module in the same shared library if it has not yet been loaded. *)

let () =
  try
    if Dynlink.is_native then begin
      Dynlink.loadfile "test4_plugin.cmxs"
    end else begin
      Dynlink.loadfile "test4_plugin.cma"
    end;
    assert false
  with
  | Dynlink.Error (
      Dynlink.Linking_error (_,
        Dynlink.Uninitialized_global "Test4_plugin_b")) -> ()