run_test.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. ", Features: " BX_CPP_NAME
  33. #if BX_SIMD_SUPPORTED
  34. ", SIMD"
  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. #endif // BX_SIMD_SUPPORTED
  48. ", Date: " __DATE__
  49. ", Time: " __TIME__
  50. "\n\n"
  51. );
  52. using namespace Catch;
  53. Session session;
  54. ConfigData config;
  55. config.defaultColourMode = BX_PLATFORM_EMSCRIPTEN ? ColourMode::None : ColourMode::PlatformDefault;
  56. session.useConfigData(config);
  57. return session.run(_argc, _argv);
  58. }