run_test.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright 2010-2024 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bx/blob/master/LICENSE
  4. */
  5. #define CATCH_CONFIG_RUNNER
  6. #include "test.h"
  7. #include <bx/string.h>
  8. #include <bx/file.h>
  9. #include <bx/simd_t.h>
  10. bool testAssertHandler(const bx::Location& _location, const char* _format, va_list _argList)
  11. {
  12. bx::printf("%s(%d): ", _location.filePath, _location.line);
  13. bx::vprintf(_format, _argList);
  14. bx::printf("\n");
  15. uintptr_t stack[32];
  16. const uint32_t num = bx::getCallStack(2 /* skip self */, BX_COUNTOF(stack), stack);
  17. bx::writeCallstack(bx::getStdOut(), stack, num, bx::ErrorIgnore{});
  18. // Throwing exceptions is required for testing asserts being trigged.
  19. // Use REQUIRE_ASSERTS to test asserts.
  20. throw std::exception();
  21. return true;
  22. }
  23. int runAllTests(int _argc, const char* _argv[])
  24. {
  25. bx::setAssertHandler(testAssertHandler);
  26. bx::printf(
  27. "\nCompiler: " BX_COMPILER_NAME
  28. ", CPU: " BX_CPU_NAME
  29. ", Arch: " BX_ARCH_NAME
  30. ", OS: " BX_PLATFORM_NAME
  31. ", CRT: " BX_CRT_NAME
  32. ", C++: " BX_CPP_NAME
  33. ", SIMD"
  34. #if BX_SIMD_SUPPORTED
  35. # if BX_SIMD_AVX
  36. ", AVX"
  37. # endif // BX_SIMD_AVX
  38. # if BX_SIMD_LANGEXT
  39. ", LangExt"
  40. # endif // BX_SIMD_LANGEXT
  41. # if BX_SIMD_NEON
  42. ", Neon"
  43. # endif // BX_SIMD_NEON
  44. # if BX_SIMD_SSE
  45. ", SSE"
  46. # endif // BX_SIMD_SSE
  47. #else
  48. ": Not supported."
  49. #endif // BX_SIMD_SUPPORTED
  50. ", Date: " __DATE__
  51. ", Time: " __TIME__
  52. "\n\n"
  53. );
  54. using namespace Catch;
  55. Session session;
  56. ConfigData config;
  57. config.defaultColourMode = BX_PLATFORM_EMSCRIPTEN ? ColourMode::None : ColourMode::PlatformDefault;
  58. session.useConfigData(config);
  59. return session.run(_argc, _argv);
  60. }