diff options
Diffstat (limited to 'chrome_frame/test')
-rw-r--r-- | chrome_frame/test/run_all_unittests.cc | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/chrome_frame/test/run_all_unittests.cc b/chrome_frame/test/run_all_unittests.cc index 694c6c0..8736e66 100644 --- a/chrome_frame/test/run_all_unittests.cc +++ b/chrome_frame/test/run_all_unittests.cc @@ -31,13 +31,36 @@ void PureCall() { __debugbreak(); } +// This class implements the Run method and registers an exception handler to +// ensure that any ChromeFrame processes like IE, Firefox, etc are terminated +// if there is a crash in the chrome frame test suite. +class ChromeFrameTestSuite : public base::TestSuite { + public: + ChromeFrameTestSuite(int argc, char** argv) + : base::TestSuite(argc, argv) {} + + int Run() { + // Register a stack based exception handler to catch any exceptions which + // occur in the course of the test. + int ret = -1; + __try { + ret = base::TestSuite::Run(); + } + + _except(EXCEPTION_EXECUTE_HANDLER) { + ret = -1; + } + return ret; + } +}; + int main(int argc, char **argv) { base::EnableTerminationOnHeapCorruption(); base::PlatformThread::SetName("ChromeFrame tests"); _set_purecall_handler(PureCall); - TestSuite test_suite(argc, argv); + ChromeFrameTestSuite test_suite(argc, argv); SetConfigBool(kChromeFrameHeadlessMode, true); SetConfigBool(kChromeFrameAccessibleMode, true); @@ -67,6 +90,12 @@ int main(int argc, char **argv) { ret = test_suite.Run(); } + if (ret == -1) { + LOG(ERROR) << "ChromeFrame tests crashed"; + chrome_frame_test::KillProcesses(L"iexplore.exe", 0, false); + chrome_frame_test::KillProcesses(L"firefox.exe", 0, false); + } + DeleteConfigValue(kChromeFrameHeadlessMode); DeleteConfigValue(kChromeFrameAccessibleMode); |