From: taemin.yeom Date: Wed, 29 Sep 2021 04:22:42 +0000 (+0900) Subject: Support lower gtest version X-Git-Tag: submit/tizen/20210929.044826^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ddb260cd112300bb0be27f0b7e1e857afaae719b;p=platform%2Fhal%2Fapi%2Fsensor.git Support lower gtest version "GTEST_SKIP()" is supported from gtest 1.10 so in lower version, it has to been ignored. Change-Id: Ic2a64eb5005ec177dfb6bc04d2dbf55133cfd453 Signed-off-by: taemin.yeom --- diff --git a/haltest/main.cpp b/haltest/main.cpp index 1a20fef..a142e3e 100644 --- a/haltest/main.cpp +++ b/haltest/main.cpp @@ -25,6 +25,8 @@ protected: TEST_F(SENSOR_API, GetBackendP) { + SKIP_NO_FEATURE(); + int ret_val; ret_val = hal_sensor_get_backend(); EXPECT_EQ(ret_val, 0) << strerr("Failed to get sensor device", ret_val); @@ -32,6 +34,8 @@ TEST_F(SENSOR_API, GetBackendP) TEST_F(SENSOR_API, CreateP) { + SKIP_NO_FEATURE(); + int ret_val; void **devices; ret_val = hal_sensor_create(&devices); diff --git a/haltest/sensor-device.cpp b/haltest/sensor-device.cpp index 3b87482..ed28660 100644 --- a/haltest/sensor-device.cpp +++ b/haltest/sensor-device.cpp @@ -36,6 +36,11 @@ public: int SENSOR_DEV::device_count = 0; device_registry_t SENSOR_DEV::devices; +#define SKIP_NO_FEATURE() \ + if (!check_feature_all()) { \ + return; \ + } + #define SKIP_NO_DEV() \ if (device_count <= 0) { \ SKIP_MESSAGE("There is no sensor devices."); \ @@ -44,6 +49,7 @@ device_registry_t SENSOR_DEV::devices; TEST_F(SENSOR_DEV, get_poll_fdP) { + SKIP_NO_FEATURE() SKIP_NO_DEV() for (auto it = devices.begin(); it != devices.end(); ++it) { @@ -56,6 +62,7 @@ TEST_F(SENSOR_DEV, get_sensorsP) const sensor_info_t *sensors = nullptr; int ret_func; + SKIP_NO_FEATURE() SKIP_NO_DEV() for (auto it = devices.begin(); it != devices.end(); ++it) { @@ -67,6 +74,7 @@ TEST_F(SENSOR_DEV, get_sensorsP) TEST_F(SENSOR_DEV, get_sensorsN) { + SKIP_NO_FEATURE() SKIP_NO_DEV() for (auto it = devices.begin(); it != devices.end(); ++it) { @@ -154,6 +162,7 @@ TEST_F(SENSOR_DEV, get_dataP) sensor_data_t *data = NULL; const sensor_info_t *sensors = nullptr; + SKIP_NO_FEATURE() SKIP_NO_DEV() for (auto it = devices.begin(); it != devices.end(); ++it) { @@ -169,6 +178,7 @@ TEST_F(SENSOR_DEV, get_dataN) int length = 0; sensor_data_t *data = NULL; + SKIP_NO_FEATURE() SKIP_NO_DEV() for (auto it = devices.begin(); it != devices.end(); ++it) { diff --git a/haltest/sensor-haltest.h b/haltest/sensor-haltest.h index 88ef284..bd4ec43 100644 --- a/haltest/sensor-haltest.h +++ b/haltest/sensor-haltest.h @@ -21,6 +21,7 @@ #include #if (GTEST_VERSION_MAJOR < 1 || (GTEST_VERSION_MAJOR == 1 && GTEST_VERSION_MINOR < 10)) +#define GTEST_SKIP() ; // hack gtest internal for print message namespace testing { @@ -52,6 +53,11 @@ do { \ testing::internal::ColoredPrintf(testing::internal::COLOR_DEFAULT, "\n"); \ } while (0) +#define SKIP_NO_FEATURE() \ + if (!check_feature_all()) { \ + return; \ + } + // SetUp/TearDown function for a testsuite differ by gtest version #if (GTEST_VERSION_MAJOR >= 2 || (GTEST_VERSION_MAJOR == 1 && GTEST_VERSION_MINOR >= 10)) #define SetUpHalTestSuite SetUpTestSuite