signal_handler.odin 859 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //+private
  2. package testing
  3. /*
  4. (c) Copyright 2024 Feoramund <[email protected]>.
  5. Made available under Odin's BSD-3 license.
  6. List of contributors:
  7. Feoramund: Total rewrite.
  8. */
  9. import "base:runtime"
  10. import "core:log"
  11. Stop_Reason :: enum {
  12. Unknown,
  13. Illegal_Instruction,
  14. Arithmetic_Error,
  15. Segmentation_Fault,
  16. Unhandled_Trap,
  17. }
  18. test_assertion_failure_proc :: proc(prefix, message: string, loc: runtime.Source_Code_Location) -> ! {
  19. log.fatalf("%s: %s", prefix, message, location = loc)
  20. runtime.trap()
  21. }
  22. setup_signal_handler :: proc() {
  23. _setup_signal_handler()
  24. }
  25. setup_task_signal_handler :: proc(test_index: int) {
  26. _setup_task_signal_handler(test_index)
  27. }
  28. should_stop_runner :: proc() -> bool {
  29. return _should_stop_runner()
  30. }
  31. should_stop_test :: proc() -> (test_index: int, reason: Stop_Reason, ok: bool) {
  32. return _should_stop_test()
  33. }