Fix UTC crash for some system 47/316947/3
authorEunki Hong <eunkiki.hong@samsung.com>
Fri, 30 Aug 2024 14:31:01 +0000 (23:31 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Mon, 2 Sep 2024 02:41:02 +0000 (11:41 +0900)
- If http_proxy environment not defined, std::getenv return nullptr. We didn't consider this case
- If we use Dali::Accessibility::TestEnableSC() without DBusWrapper::Install(std::unique_ptr<DBusWrapper>(new TestDBusWrapper)), it will be crashed.

Change-Id: I51247ce8ac37d1080cc29980debef4024ba0b104
Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
13 files changed:
automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/accessibility-test-utils.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Accessible.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Controls-BridgeUp.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Controls.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Text.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Value.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-ColorConversion.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-DebugRendering.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-PropertyHelper.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-SvgLoader.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-TextSelectionPopup-internal.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-environment-variable.cpp

index 98c29513b914171eefe41f9e7df4e18b4e1371a3..214c9078a72e540a6a396c4ca5e0457f4087c98d 100644 (file)
@@ -41,7 +41,13 @@ void TestEnableSC(bool b)
     static bool ScreenReaderEnabled = false;
     static bool IsEnabled           = false;
 
-    auto wr = static_cast<TestDBusWrapper*>(DBusWrapper::Installed());
+    auto* dbusWrapper = DBusWrapper::Installed();
+    auto* wr          = dynamic_cast<TestDBusWrapper*>(dbusWrapper);
+    if(wr == nullptr)
+    {
+      fprintf(stderr, "Wrong case! TestDBusWrapper was not installed! have you forget to call DBusWrapper::Install(std::unique_ptr<DBusWrapper>(new TestDBusWrapper)); at startup?\n");
+      std::abort();
+    }
 
     wr->testMethods[std::tuple<std::string, std::string, std::string, MethodType>{"/org/a11y/bus", "org.a11y.Status", "ScreenReaderEnabled", MethodType::Getter}] = [wr](const MessagePtr& m) -> MessagePtr {
       auto reply = wr->newReplyMessage(m);
index eee08a76f40061d5a10f0301dbf4a8749b7e0faa..02ca1fa764fa36bb45c5fa6bde9150530d6ceb60 100644 (file)
@@ -39,6 +39,7 @@ void utc_dali_toolkit_accessibility_accessible_startup(void)
 void utc_dali_toolkit_accessibility_accessible_cleanup(void)
 {
   test_return_value = TET_PASS;
+  DBusWrapper::Install({}); // Clean up TestDBusWrapper
 }
 
 int utcDaliAccessibilityCheckBoxButtonGetStates(void)
index b703dcfe06690df84ed3526d89809ae2f6d880e2..5522508f4c46653f5d1fa1d033fa58e214f9ad05 100644 (file)
@@ -33,6 +33,18 @@ const auto flushCoalescableMessage = [](Dali::ToolkitTestApplication& applicatio
 };
 }
 
+void utc_dali_toolkit_accessibility_control_bridgeup_startup(void)
+{
+  test_return_value = TET_UNDEF;
+  DBusWrapper::Install(std::unique_ptr<DBusWrapper>(new TestDBusWrapper));
+}
+
+void utc_dali_toolkit_accessibility_control_bridgeup_cleanup(void)
+{
+  test_return_value = TET_PASS;
+  DBusWrapper::Install({}); // Clean up TestDBusWrapper
+}
+
 namespace Dali
 {
 namespace Accessibility
index 76744be3c8a6dd9fbcf969a7be2bfa94cf96549c..b2bd5440b37040f49c2295b4540b36e71deabd73 100644 (file)
@@ -26,8 +26,7 @@ void utc_dali_accessibility_controls_startup(void)
 void utc_dali_accessibility_controls_cleanup(void)
 {
   test_return_value = TET_PASS;
-  //DBusWrapper::Install({}) is a de-install
-  DBusWrapper::Install({});
+  DBusWrapper::Install({}); // Clean up TestDBusWrapper
 }
 
 int UtcDaliControlAccessibileGet01(void)
index 4389b900440b61cfe89e99ce4fa81128f1a00d8b..ad6a870d5ed7f165886052f31b8b45fdd80f8545 100644 (file)
@@ -39,6 +39,7 @@ void utc_dali_toolkit_accessibility_text_startup(void)
 void utc_dali_toolkit_accessibility_text_cleanup(void)
 {
   test_return_value = TET_PASS;
+  DBusWrapper::Install({}); // Clean up TestDBusWrapper
 }
 
 int utcDaliAccessibilityTextEditorGetName(void)
index d19755a153486d5e5208ecaca486c42ce04e7a0d..caabef75b1f706b5de46f1bd864923a5678ef3ef 100644 (file)
@@ -45,6 +45,7 @@ void utc_dali_toolkit_accessibility_value_startup(void)
 void utc_dali_toolkit_accessibility_value_cleanup(void)
 {
   test_return_value = TET_PASS;
+  DBusWrapper::Install({}); // Clean up TestDBusWrapper
 }
 
 int utcDaliAccessibilityProgressBarGetMinimum(void)
index cec590ce211487d473c881821e69a4a2e9673a8c..21e3ec76aef87067203f5ff14d73f253e325ac90 100644 (file)
@@ -36,6 +36,9 @@ void dali_color_conversion_startup(void)
 void dali_color_conversion_cleanup(void)
 {
   test_return_value = TET_PASS;
+#if defined(ELDBUS_ENABLED)
+  DBusWrapper::Install({}); // Clean up TestDBusWrapper
+#endif
 }
 
 int UtcDaliPropertyHelperConvertHtmlStringToColor(void)
index 69365fb2830db47b43db5112d67b2dd9b804f4fd..f1438db783b37276ec1a70326b3f279811bf6fd4 100755 (executable)
@@ -93,6 +93,9 @@ void dali_debug_rendering_startup(void)
 void dali_debug_rendering_cleanup(void)
 {
   test_return_value = TET_PASS;
+#if defined(ELDBUS_ENABLED)
+  DBusWrapper::Install({}); // Clean up TestDBusWrapper
+#endif
 }
 
 int UtcDaliDebugRenderingGetVisual1(void)
index 38fdc58894762349fc092133f41a7c6359adae27..d4a859f46b131e9fc00c0d728e7636b2a1a30ddb 100644 (file)
@@ -36,6 +36,9 @@ void dali_property_helper_startup(void)
 void dali_property_helper_cleanup(void)
 {
   test_return_value = TET_PASS;
+#if defined(ELDBUS_ENABLED)
+  DBusWrapper::Install({}); // Clean up TestDBusWrapper
+#endif
 }
 
 int UtcDaliPropertyHelperGetStringFromPropertyWithString(void)
index 58a815c3372ed458959ef5154cc71825769424c2..eb824f33f16d30fbd20eb8bfa3dae1ebd4e0bbe9 100644 (file)
@@ -54,6 +54,9 @@ void utc_dali_toolkit_internal_svg_loader_startup(void)
 void utc_dali_toolkit_internal_svg_loader_cleanup(void)
 {
   test_return_value = TET_PASS;
+#if defined(ELDBUS_ENABLED)
+  DBusWrapper::Install({}); // Clean up TestDBusWrapper
+#endif
 }
 
 namespace
index c5ad959331e8f82d9cf3ee5d941acce4d71085d7..db4adcf17755acbd903016d357b9ebe00cc3a2d4 100644 (file)
@@ -42,6 +42,9 @@ void dali_textselectionpopupinternal_startup(void)
 void dali_textselectionpopupinternal_cleanup(void)
 {
   test_return_value = TET_PASS;
+#if defined(ELDBUS_ENABLED)
+  DBusWrapper::Install({}); // Clean up TestDBusWrapper
+#endif
 }
 
 int UtcDaliToolkitTextSelectionPopupIconPropertiesN(void)
index bd7c6e395cd750cb1fb3f3348ad35ec8db01cc4e..04f95370dd2d706ef11d47bf4e9d44a542fcf950 100644 (file)
@@ -53,6 +53,9 @@ void utc_dali_toolkit_texture_manager_startup(void)
 void utc_dali_toolkit_texture_manager_cleanup(void)
 {
   test_return_value = TET_PASS;
+#if defined(ELDBUS_ENABLED)
+  DBusWrapper::Install({}); // Clean up TestDBusWrapper
+#endif
 }
 
 namespace
index 064a6d682fa066a1cf4d3198f2f761e5143117b3..def6ba320b088559baa60fd91c70ea62413e5165 100644 (file)
@@ -40,14 +40,15 @@ const char* GetEnvironmentVariable(const char* variable)
   // Get http_proxy from real environment variables
   if(std::string(variable) == std::string("http_proxy"))
   {
-    return (gEnvironmentVariables[variable] = std::getenv("http_proxy")).c_str();
+    auto* httpProxyResult = std::getenv("http_proxy");
+    return (gEnvironmentVariables[variable] = (httpProxyResult ? httpProxyResult : "")).c_str();
   }
   return nullptr;
 }
 
 void SetTestEnvironmentVariable(const char* variable, const char* value)
 {
-  gEnvironmentVariables[variable] = value;
+  gEnvironmentVariables[variable] = value ? value : "";
 }
 
 } // namespace EnvironmentVariable