From e1193ae69147a419052afec988a0086728ced690 Mon Sep 17 00:00:00 2001 From: Taesoo Jun Date: Thu, 5 Jul 2018 11:01:16 +0900 Subject: [PATCH] Add exception handle for google test framework Change-Id: Ie8a465b9cbcbb0f4a055c790ee9687de63f378b5 Signed-off-by: Taesoo Jun --- gtest/unittest.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/gtest/unittest.cpp b/gtest/unittest.cpp index 6ba0cdb..7db3ff9 100755 --- a/gtest/unittest.cpp +++ b/gtest/unittest.cpp @@ -1375,6 +1375,20 @@ TEST(WifiTest, Start_n) int main(int argc, char **argv) { - InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + int ret = -1; + + try { + testing::InitGoogleTest(&argc, argv); + } catch(...) { + std::cout << "Exception occurred." << std::endl; + } + + try { + ret = RUN_ALL_TESTS(); + } catch (const ::testing::internal::GoogleTestFailureException& e) { + ret = -1; + std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl; + } + + return ret; } -- 2.34.1