From bb398f32cae25395640db4b70b4c77247e887b46 Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Mon, 4 May 2015 20:12:02 -0500 Subject: [PATCH] Guard test code with __try __except --- .../cpu/frontend/test/xe-cpu-ppc-test.cc | 44 ++++++++++++++----- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/src/xenia/cpu/frontend/test/xe-cpu-ppc-test.cc b/src/xenia/cpu/frontend/test/xe-cpu-ppc-test.cc index 7a64c7c8a..3b220cf88 100644 --- a/src/xenia/cpu/frontend/test/xe-cpu-ppc-test.cc +++ b/src/xenia/cpu/frontend/test/xe-cpu-ppc-test.cc @@ -367,6 +367,39 @@ bool DiscoverTests(std::wstring& test_path, return true; } +#ifdef _MSC_VER +int filter(unsigned int code) { + if (code == EXCEPTION_ILLEGAL_INSTRUCTION) + return EXCEPTION_EXECUTE_HANDLER; + + return EXCEPTION_CONTINUE_SEARCH; +} +#endif + +void ProtectedRunTest(TestSuite &test_suite, TestRunner &runner, TestCase &test_case, int &failed_count, int &passed_count) { +#ifdef _MSC_VER + __try { +#endif + + if (!runner.Setup(test_suite)) { + XELOGE(" TEST FAILED SETUP"); + ++failed_count; + } + if (runner.Run(test_case)) { + ++passed_count; + } else { + XELOGE(" TEST FAILED"); + ++failed_count; + } + +#ifdef _MSC_VER + } __except (filter(GetExceptionCode())) { + XELOGE(" TEST FAILED (UNSUPPORTED INSTRUCTION)"); + ++failed_count; + } +#endif +} + bool RunTests(const std::wstring& test_name) { int result_code = 1; int failed_count = 0; @@ -409,16 +442,7 @@ bool RunTests(const std::wstring& test_name) { for (auto& test_case : test_suite.test_cases) { XELOGI(" - %s", test_case.name.c_str()); TestRunner runner; - if (!runner.Setup(test_suite)) { - XELOGE(" TEST FAILED SETUP"); - ++failed_count; - } - if (runner.Run(test_case)) { - ++passed_count; - } else { - XELOGE(" TEST FAILED"); - ++failed_count; - } + ProtectedRunTest(test_suite, runner, test_case, failed_count, passed_count); } XELOGI("");