-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from Engil/engil/add_test_dynlink_backtrace
testsuite: add tests for dynlink and stack unwinding
- Loading branch information
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
(* TEST | ||
include dynlink | ||
files = "backtrace_dynlink_plugin.ml" | ||
libraries = "" | ||
* shared-libraries | ||
** native-dynlink | ||
*** setup-ocamlopt.byte-build-env | ||
**** ocamlopt.byte | ||
module = "backtrace_dynlink.ml" | ||
flags = "-g" | ||
**** ocamlopt.byte | ||
program = "backtrace_dynlink_plugin.cmxs" | ||
flags = "-shared -g" | ||
all_modules = "backtrace_dynlink_plugin.ml" | ||
**** ocamlopt.byte | ||
program = "${test_build_directory}/main.exe" | ||
libraries = "dynlink" | ||
all_modules = "backtrace_dynlink.cmx" | ||
***** run | ||
ocamlrunparam += ",b=1" | ||
****** check-program-output | ||
*) | ||
|
||
(* test for backtrace and stack unwinding with dynlib. *) | ||
(* https://github.com/ocaml-multicore/ocaml-multicore/issues/440 *) | ||
(* https://github.com/ocaml-multicore/ocaml-multicore/pull/499 *) | ||
|
||
let () = | ||
Dynlink.allow_unsafe_modules true; | ||
try | ||
Dynlink.loadfile "backtrace_dynlink_plugin.cmxs" | ||
with | ||
| Dynlink.Error err -> | ||
print_endline @@ Dynlink.error_message err; | ||
Printexc.print_backtrace stdout; | ||
| exn -> | ||
Printexc.to_string exn |> print_endline; | ||
print_endline "ERROR" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Raised by primitive operation at Backtrace_dynlink_plugin in file "backtrace_dynlink_plugin.ml", line 6, characters 13-38 | ||
Called from Dynlink.Native.run.(fun) in file "otherlibs/dynlink/native/dynlink.ml", line 85, characters 12-29 | ||
Called from Stdlib__list.iter in file "list.ml", line 110, characters 12-15 | ||
Called from Dynlink_common.Make.load.(fun) in file "otherlibs/dynlink/dynlink_common.ml", line 347, characters 13-44 | ||
Called from Stdlib__list.iter in file "list.ml", line 110, characters 12-15 | ||
Called from Dynlink_common.Make.load in file "otherlibs/dynlink/dynlink_common.ml", line 345, characters 8-240 | ||
Called from Dynlink_common.Make.loadfile in file "otherlibs/dynlink/dynlink_common.ml" (inlined), line 357, characters 26-45 | ||
Called from Backtrace_dynlink in file "backtrace_dynlink.ml", line 35, characters 4-52 | ||
execution of module initializers in the shared library failed: Failure("SUCCESS") | ||
Raised by primitive operation at Dynlink.Native.run.(fun) in file "otherlibs/dynlink/native/dynlink.ml", line 85, characters 12-29 | ||
Re-raised at Dynlink.Native.run.(fun) in file "otherlibs/dynlink/native/dynlink.ml", line 87, characters 10-149 | ||
Called from Stdlib__list.iter in file "list.ml", line 110, characters 12-15 | ||
Called from Dynlink_common.Make.load.(fun) in file "otherlibs/dynlink/dynlink_common.ml", line 347, characters 13-44 | ||
Called from Stdlib__list.iter in file "list.ml", line 110, characters 12-15 | ||
Called from Dynlink_common.Make.load in file "otherlibs/dynlink/dynlink_common.ml", line 345, characters 8-240 | ||
Re-raised at Dynlink_common.Make.load in file "otherlibs/dynlink/dynlink_common.ml", line 355, characters 8-17 | ||
Called from Dynlink_common.Make.loadfile in file "otherlibs/dynlink/dynlink_common.ml" (inlined), line 357, characters 26-45 | ||
Called from Backtrace_dynlink in file "backtrace_dynlink.ml", line 35, characters 4-52 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
let () = | ||
try | ||
failwith "SUCCESS" | ||
with | ||
| e -> | ||
let c = Printexc.get_callstack 10 in | ||
Printexc.print_raw_backtrace stdout c; | ||
raise e |