From: Youngjae Cho Date: Fri, 19 Mar 2021 01:24:48 +0000 (+0900) Subject: haltest: skip tests not supported by HAL X-Git-Tag: accepted/tizen/unified/20210331.113729~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a595a4836d2d9bd3a82505b9692d545f2528db1a;p=platform%2Fhal%2Fapi%2Fdevice.git haltest: skip tests not supported by HAL Instead of generating an error, skip a test if HAL function for that test is not supported. Change-Id: Ic28cbc788921b6a3ee116977dabe55cfaacabbd0 Signed-off-by: Youngjae Cho --- diff --git a/haltest/battery.cpp b/haltest/battery.cpp index fcb238c..5c43395 100644 --- a/haltest/battery.cpp +++ b/haltest/battery.cpp @@ -6,10 +6,10 @@ class BATTERY : public testing::Test { protected: void SetUp() override { - int ret; + int ret_val; - ret = system_info_get_platform_bool(FEATURE_BATTERY, &battery_supported); - ASSERT_EQ(ret, SYSTEM_INFO_ERROR_NONE) << "Failed to get battery feature"; + ret_val = system_info_get_platform_bool(FEATURE_BATTERY, &battery_supported); + ASSERT_EQ(ret_val, SYSTEM_INFO_ERROR_NONE) << "Failed to get battery feature"; } void TearDown() override {} @@ -28,35 +28,39 @@ static void __changed_cb(struct battery_info *info, void *data) TEST_F(BATTERY, GetBackendP) { - int ret; + int ret_val; if (!battery_supported) { SKIP_MESSAGE("Battery not supported"); return; } - ret = hal_device_battery_get_backend(); - EXPECT_EQ(ret, 0) << "Failed to get battery device (" << ret << ")"; + ret_val = hal_device_battery_get_backend(); + EXPECT_EQ(ret_val, 0) << "Failed to get battery device (" << ret_val << ")"; } TEST_F(BATTERY, RegisterChangedEventP) { - int ret; + int ret_val; if (!battery_supported) { SKIP_MESSAGE("Battery not supported"); return; } - ret = hal_device_battery_register_changed_event(__changed_cb, NULL); - ASSERT_EQ(ret, 0) << "Failed to register changed callback"; + ret_val = hal_device_battery_register_changed_event(__changed_cb, NULL); + if (ret_val == -ENODEV) { + SKIP_MESSAGE("Not supported HAL"); + return; + } + ASSERT_EQ(ret_val, 0) << "Failed to register changed callback"; changed_callback_registered = true; } TEST_F(BATTERY, UnregisterChangedEventP) { - int ret; + int ret_val; if (!battery_supported) { SKIP_MESSAGE("Battery not supported"); @@ -68,21 +72,29 @@ TEST_F(BATTERY, UnregisterChangedEventP) return; } - ret = hal_device_battery_unregister_changed_event(__changed_cb); - ASSERT_EQ(ret, 0) << "Failed to unregister changed callback"; + ret_val = hal_device_battery_unregister_changed_event(__changed_cb); + if (ret_val == -ENODEV) { + SKIP_MESSAGE("Not supported HAL"); + return; + } + ASSERT_EQ(ret_val, 0) << "Failed to unregister changed callback"; changed_callback_registered = false; } TEST_F(BATTERY, GetCurrentStateP) { - int ret; + int ret_val; if (!battery_supported) { SKIP_MESSAGE("Battery not supported"); return; } - ret = hal_device_battery_get_current_state(__changed_cb, NULL); - EXPECT_EQ(ret, 0) << "Failed to get current state"; + ret_val = hal_device_battery_get_current_state(__changed_cb, NULL); + if (ret_val == -ENODEV) { + SKIP_MESSAGE("Not supported HAL"); + return; + } + EXPECT_EQ(ret_val, 0) << "Failed to get current state"; } diff --git a/haltest/board.cpp b/haltest/board.cpp index 356c2c0..b1acd07 100644 --- a/haltest/board.cpp +++ b/haltest/board.cpp @@ -22,6 +22,10 @@ TEST_F(BOARD, GetDeviceSerialP) char *serial = nullptr; ret_val = hal_device_board_get_device_serial(&serial); + if (ret_val == -ENODEV) { + SKIP_MESSAGE("Not supported HAL"); + return; + } EXPECT_EQ(ret_val, 0) << "Failed to get device serial (" << ret_val << ")"; EXPECT_NE(serial, nullptr) << "Failed to get device serial (nullptr)"; @@ -37,6 +41,10 @@ TEST_F(BOARD, GetDeviceRevisionP) int revision; ret_val = hal_device_board_get_device_revision(&revision); + if (ret_val == -ENODEV) { + SKIP_MESSAGE("Not supported HAL"); + return; + } EXPECT_EQ(ret_val, 0) << "Failed to get device revision (" << ret_val << ")"; if (ret_val == 0)