aboutsummaryrefslogtreecommitdiffstats
path: root/test/Bindings
diff options
context:
space:
mode:
authorGordon Henriksen <gordonhenriksen@mac.com>2007-12-19 22:30:40 +0000
committerGordon Henriksen <gordonhenriksen@mac.com>2007-12-19 22:30:40 +0000
commitda1435f86ebc9886dd7704294e01d192d79e069c (patch)
tree6bfc10578fca9bc86214295b290bec5b0821be8f /test/Bindings
parent696f768daf61044abff279b20326cf0138d02e1a (diff)
downloadexternal_llvm-da1435f86ebc9886dd7704294e01d192d79e069c.zip
external_llvm-da1435f86ebc9886dd7704294e01d192d79e069c.tar.gz
external_llvm-da1435f86ebc9886dd7704294e01d192d79e069c.tar.bz2
Adding bindings for memory buffers and module providers. Switching
to exceptions rather than variants for error handling in Ocaml. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45226 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Bindings')
-rw-r--r--test/Bindings/Ocaml/bitreader.ml58
-rw-r--r--test/Bindings/Ocaml/vmcore.ml4
2 files changed, 57 insertions, 5 deletions
diff --git a/test/Bindings/Ocaml/bitreader.ml b/test/Bindings/Ocaml/bitreader.ml
index 0bf8c00..05bbd28 100644
--- a/test/Bindings/Ocaml/bitreader.ml
+++ b/test/Bindings/Ocaml/bitreader.ml
@@ -18,6 +18,58 @@ let _ =
Llvm.dispose_module m;
- test (match Llvm_bitreader.read_bitcode_file fn with
- | Llvm_bitreader.Bitreader_success m -> Llvm.dispose_module m; true
- | Llvm_bitreader.Bitreader_failure _ -> false)
+ (* parse_bitcode *)
+ begin
+ let mb = Llvm.MemoryBuffer.of_file fn in
+ begin try
+ let m = Llvm_bitreader.parse_bitcode mb in
+ Llvm.dispose_module m
+ with x ->
+ Llvm.MemoryBuffer.dispose;
+ raise x
+ end
+ end;
+
+ (* MemoryBuffer.of_file *)
+ test begin try
+ let mb = Llvm.MemoryBuffer.of_file (fn ^ ".bogus") in
+ Llvm.MemoryBuffer.dispose mb;
+ false
+ with Llvm.IoError _ ->
+ true
+ end;
+
+ (* get_module_provider *)
+ begin
+ let mb = Llvm.MemoryBuffer.of_file fn in
+ let mp = begin try
+ Llvm_bitreader.get_module_provider mb
+ with x ->
+ Llvm.MemoryBuffer.dispose mb;
+ raise x
+ end in
+ Llvm.ModuleProvider.dispose mp
+ end;
+
+ (* corrupt the bitcode *)
+ let fn = fn ^ ".txt" in
+ begin let oc = open_out fn in
+ output_string oc "not a bitcode file\n";
+ close_out oc
+ end;
+
+ (* test get_module_provider exceptions *)
+ test begin
+ try
+ let mb = Llvm.MemoryBuffer.of_file fn in
+ let mp = begin try
+ Llvm_bitreader.get_module_provider mb
+ with x ->
+ Llvm.MemoryBuffer.dispose mb;
+ raise x
+ end in
+ Llvm.ModuleProvider.dispose mp;
+ false
+ with Llvm_bitreader.Error _ ->
+ true
+ end
diff --git a/test/Bindings/Ocaml/vmcore.ml b/test/Bindings/Ocaml/vmcore.ml
index 65d8a31..04b8086 100644
--- a/test/Bindings/Ocaml/vmcore.ml
+++ b/test/Bindings/Ocaml/vmcore.ml
@@ -805,8 +805,8 @@ let test_builder () =
let test_module_provider () =
let m = create_module "test" in
- let mp = create_module_provider m in
- dispose_module_provider mp
+ let mp = ModuleProvider.create m in
+ ModuleProvider.dispose mp
(*===-- Writer ------------------------------------------------------------===*)