diff options
-rw-r--r-- | haltest/main.cpp | 6 | ||||
-rw-r--r-- | haltest/sensor-device.cpp | 35 | ||||
-rw-r--r-- | haltest/sensor-haltest.h | 8 |
3 files changed, 19 insertions, 30 deletions
diff --git a/haltest/main.cpp b/haltest/main.cpp index a142e3e..a0da52b 100644 --- a/haltest/main.cpp +++ b/haltest/main.cpp @@ -13,12 +13,6 @@ protected: } void SetUp() override { - int ret_val = check_feature_all(); - if (!ret_val) { - SKIP_MESSAGE("All sensor features are false"); - GTEST_SKIP(); - return; - } } void TearDown() override {} }; diff --git a/haltest/sensor-device.cpp b/haltest/sensor-device.cpp index ed28660..2856c8f 100644 --- a/haltest/sensor-device.cpp +++ b/haltest/sensor-device.cpp @@ -23,12 +23,6 @@ public: } void SetUp() override { - int ret_val = check_feature_all(); - if (!ret_val) { - SKIP_MESSAGE("All sensor features are false"); - GTEST_SKIP(); - return; - } } void TearDown() override{} }; @@ -36,21 +30,18 @@ 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() \ +do { \ if (device_count <= 0) { \ SKIP_MESSAGE("There is no sensor devices."); \ return; \ - } + } \ +} while (0) TEST_F(SENSOR_DEV, get_poll_fdP) { - SKIP_NO_FEATURE() - SKIP_NO_DEV() + SKIP_NO_FEATURE(); + SKIP_NO_DEV(); for (auto it = devices.begin(); it != devices.end(); ++it) { EXPECT_NE((*it)->get_poll_fd(), 0); @@ -62,8 +53,8 @@ TEST_F(SENSOR_DEV, get_sensorsP) const sensor_info_t *sensors = nullptr; int ret_func; - SKIP_NO_FEATURE() - SKIP_NO_DEV() + SKIP_NO_FEATURE(); + SKIP_NO_DEV(); for (auto it = devices.begin(); it != devices.end(); ++it) { ret_func = (*it)->get_sensors(&sensors); @@ -74,8 +65,8 @@ TEST_F(SENSOR_DEV, get_sensorsP) TEST_F(SENSOR_DEV, get_sensorsN) { - SKIP_NO_FEATURE() - SKIP_NO_DEV() + SKIP_NO_FEATURE(); + SKIP_NO_DEV(); for (auto it = devices.begin(); it != devices.end(); ++it) { EXPECT_EQ((*it)->get_sensors(nullptr), -EINVAL); @@ -162,8 +153,8 @@ TEST_F(SENSOR_DEV, get_dataP) sensor_data_t *data = NULL; const sensor_info_t *sensors = nullptr; - SKIP_NO_FEATURE() - SKIP_NO_DEV() + SKIP_NO_FEATURE(); + SKIP_NO_DEV(); for (auto it = devices.begin(); it != devices.end(); ++it) { EXPECT_GE((*it)->get_sensors(&sensors), 1); @@ -178,8 +169,8 @@ TEST_F(SENSOR_DEV, get_dataN) int length = 0; sensor_data_t *data = NULL; - SKIP_NO_FEATURE() - SKIP_NO_DEV() + SKIP_NO_FEATURE(); + SKIP_NO_DEV(); for (auto it = devices.begin(); it != devices.end(); ++it) { EXPECT_EQ((*it)->get_data(0, &data, &length), -EINVAL); diff --git a/haltest/sensor-haltest.h b/haltest/sensor-haltest.h index bd4ec43..a1f2e9f 100644 --- a/haltest/sensor-haltest.h +++ b/haltest/sensor-haltest.h @@ -21,7 +21,7 @@ #include <string.h> #if (GTEST_VERSION_MAJOR < 1 || (GTEST_VERSION_MAJOR == 1 && GTEST_VERSION_MINOR < 10)) -#define GTEST_SKIP() ; +#define GTEST_SKIP() // hack gtest internal for print message namespace testing { @@ -54,9 +54,13 @@ do { \ } while (0) #define SKIP_NO_FEATURE() \ +do { \ if (!check_feature_all()) { \ + SKIP_MESSAGE("All sensor features are false"); \ + GTEST_SKIP(); \ return; \ - } + } \ +} while (0) // SetUp/TearDown function for a testsuite differ by gtest version #if (GTEST_VERSION_MAJOR >= 2 || (GTEST_VERSION_MAJOR == 1 && GTEST_VERSION_MINOR >= 10)) |