From 6f0d90cea3cef30da5de4dcb1c58280a881fdc15 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 22 Apr 2021 14:50:16 +0900 Subject: [PATCH 01/16] Remove unneeded fPIE gcc option The fPIE option is for the executable binary. It is not proper for shared library files. So that remove unneeded fPIE gcc option. Change-Id: I800016e2bb30b8a02d2170b9c87df4cd334dfa02 Signed-off-by: Chanwoo Choi --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b3e104..8e2f855 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -fPIE -fPIC") +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -fPIC") SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -lrt") SET(CMAKE_EXE_LINKER_FLAGS "-pie") -- 2.7.4 From 0813c0b54e38beb0f84d1b5d1f0a455bdb12474f Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Mon, 26 Apr 2021 17:19:16 +0900 Subject: [PATCH 02/16] Add get_attribute interface Change-Id: I588887f1fdc17dbd079d97d646b1b88b932a940a Signed-off-by: Yunmi Ha --- include/hal-sensor-types.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/hal-sensor-types.h b/include/hal-sensor-types.h index fcba0cd..d7b78d1 100644 --- a/include/hal-sensor-types.h +++ b/include/hal-sensor-types.h @@ -570,6 +570,15 @@ class sensor_device { int len) { return true; } + virtual bool get_attribute_int(uint32_t id, int32_t attribute, + int32_t *value) { + return true; + } + virtual bool set_attribute_str(uint32_t id, int32_t attribute, char **value, + int *len) { + return true; + } + virtual bool flush(uint32_t id) { return true; } }; -- 2.7.4 From 452278d1f20aebc46f4dc7a78a190d6e0baaf618 Mon Sep 17 00:00:00 2001 From: "taemin.yeom" Date: Tue, 11 May 2021 16:04:32 +0900 Subject: [PATCH 03/16] Add conditional compile directive to avoid build error Change-Id: I4e6d3bda7bcea0af59793344b0787b9aa89114b0 Signed-off-by: taemin.yeom --- haltest/sensor-haltest.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/haltest/sensor-haltest.h b/haltest/sensor-haltest.h index 033fb75..3e030f1 100644 --- a/haltest/sensor-haltest.h +++ b/haltest/sensor-haltest.h @@ -19,6 +19,7 @@ #include #include +#if (GTEST_VERSION_MAJOR < 1 || (GTEST_VERSION_MAJOR == 1 && GTEST_VERSION_MINOR < 10)) // hack gtest internal for print message namespace testing { @@ -34,6 +35,7 @@ namespace testing extern void ColoredPrintf(GTestColor color, const char* fmt, ...); } } +#endif #define SKIP_MESSAGE(fmt, args...) \ do { \ -- 2.7.4 From d8f8d0c6004ec5cf821c891a19b5d8fb690aaa17 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Mon, 21 Jun 2021 20:51:21 +0900 Subject: [PATCH 04/16] Fix get_attribute interface Change-Id: I22e5145fbb8a11f32a0eba96d9dfbf335cf2e0ba Signed-off-by: Hyotaek Shim --- include/hal-sensor-types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hal-sensor-types.h b/include/hal-sensor-types.h index d7b78d1..07d89d3 100644 --- a/include/hal-sensor-types.h +++ b/include/hal-sensor-types.h @@ -574,7 +574,7 @@ class sensor_device { int32_t *value) { return true; } - virtual bool set_attribute_str(uint32_t id, int32_t attribute, char **value, + virtual bool get_attribute_str(uint32_t id, int32_t attribute, char **value, int *len) { return true; } -- 2.7.4 From ed1d69136415abe6c2f74eaac3eed67485108679 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Mon, 21 Jun 2021 20:58:12 +0900 Subject: [PATCH 05/16] Add file cases to .gitignore Change-Id: I2bb317443cd46fbff28c369c92081dafe3422f26 Signed-off-by: Hyotaek Shim --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 623211c..43c5f5b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,7 @@ build.ninja rules.ninja #ETC -.vscode/ \ No newline at end of file +.vscode/ +cscope.files +cscope.out +tags -- 2.7.4 From a1f3041dd445b01942e5b7bad512398a60798df3 Mon Sep 17 00:00:00 2001 From: "taemin.yeom" Date: Tue, 22 Jun 2021 10:51:05 +0900 Subject: [PATCH 06/16] Add const keyword to char* argument Change-Id: I84d417a5c4e17c1eeeb03c6c66654a8ef78b35b2 Signed-off-by: taemin.yeom --- include/hal-sensor-types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hal-sensor-types.h b/include/hal-sensor-types.h index 07d89d3..d4ee3fe 100644 --- a/include/hal-sensor-types.h +++ b/include/hal-sensor-types.h @@ -566,7 +566,7 @@ class sensor_device { int32_t value) { return true; } - virtual bool set_attribute_str(uint32_t id, int32_t attribute, char *value, + virtual bool set_attribute_str(uint32_t id, int32_t attribute, const char *value, int len) { return true; } -- 2.7.4 From e06b5066452e0967f04d278cce00ebc4e5ba635f Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Fri, 9 Jul 2021 15:23:21 +0900 Subject: [PATCH 07/16] Divide HAL so file by each sensor Change-Id: I13af2315223a2730876983b587153bd4d75de346 Signed-off-by: Yunmi Ha --- src/hal-api-sensor.cpp | 111 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 99 insertions(+), 12 deletions(-) diff --git a/src/hal-api-sensor.cpp b/src/hal-api-sensor.cpp index 01683b7..7dbbd99 100644 --- a/src/hal-api-sensor.cpp +++ b/src/hal-api-sensor.cpp @@ -13,19 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#include +#include #include #include #include "hal-api-sensor-log.h" #include "hal-sensor-interface.h" +#include "hal-sensor-types.h" #include "hal-sensor.h" #ifndef EXPORT #define EXPORT __attribute__((visibility("default"))) #endif -static hal_backend_sensor_funcs *hal_sensor_funcs = NULL; +static hal_backend_sensor_funcs **hal_sensor_funcs = NULL; +static char **hal_sensor_names = NULL; +static int hal_sensor_count = 0; /* -1 : failed to initialize 0 : not initialized @@ -33,33 +37,100 @@ static hal_backend_sensor_funcs *hal_sensor_funcs = NULL; */ static int hal_initialized = 0; +static std::vector hal_backend_devs; + +#define FREE(x) \ + do { if (x) { free(x); x = NULL; } } while(0) + EXPORT int hal_sensor_get_backend(void) { - int ret; + int ret_getnames, ret_getbackend; + int i; + int loaded_backend = 0; if (hal_sensor_funcs) return 0; - ret = hal_common_get_backend(HAL_MODULE_SENSOR, (void **)&hal_sensor_funcs); - if (ret < 0) { - _E("Failed to get backend"); - hal_initialized = -1; + hal_sensor_count = hal_common_get_backend_count(HAL_MODULE_SENSOR); + if (hal_sensor_count < 0) { + _E("Failed to get backend count."); + return -ENODEV; + } else if (hal_sensor_count == 0) { + _E("There is no hal-backend-sensor library."); + return -ENODEV; + } + + hal_sensor_names = (char **)malloc(sizeof(char *) * hal_sensor_count); + if (!hal_sensor_names) { + _E("Failed to allocate memory."); + hal_sensor_count = 0; return -ENODEV; } + for (i = 0; i < hal_sensor_count; i++) { + hal_sensor_names[i] = (char *)malloc(sizeof(char) * 256); + if (!hal_sensor_names[i]) { + _E("Failed to allocate memory."); + goto FREE_MEMORY; + } + } + + ret_getnames = hal_common_get_backend_library_names(HAL_MODULE_SENSOR, hal_sensor_names, hal_sensor_count); + if (ret_getnames < 0) { + _E("Failed to get backend library names."); + goto FREE_MEMORY; + } + + hal_sensor_funcs = (hal_backend_sensor_funcs **)malloc(sizeof(hal_backend_sensor_funcs *) * hal_sensor_count); + if (!hal_sensor_funcs) { + _E("Failed to allocate memory."); + goto FREE_MEMORY; + } + + for(i = 0; i < hal_sensor_count; i++) { + ret_getbackend = hal_common_get_backend_with_library_name(HAL_MODULE_SENSOR, (void **)&hal_sensor_funcs[i], hal_sensor_names[i]); + if (ret_getbackend < 0) { + _E("Failed to get backend (%s)", hal_sensor_names[i]); + } else + loaded_backend++; + } + + if (loaded_backend == 0) { + FREE(hal_sensor_funcs); + goto FREE_MEMORY; + } + hal_initialized = 1; return 0; + +FREE_MEMORY: + for(i = 0; i < hal_sensor_count; i++) + FREE(hal_sensor_names[i]); + + FREE(hal_sensor_names); + + hal_sensor_count = 0; + hal_initialized = -1; + return -ENODEV; } EXPORT int hal_sensor_put_backend(void) { + int i = 0; if (!hal_sensor_funcs) return -ENODEV; - hal_common_put_backend(HAL_MODULE_SENSOR, (void *)hal_sensor_funcs); - hal_sensor_funcs = NULL; + for (i = 0; i < hal_sensor_count; i++) { + if (hal_sensor_funcs[i]) { + hal_common_put_backend_with_library_name(HAL_MODULE_SENSOR, (void *)hal_sensor_funcs[i], hal_sensor_names[i]); + } + FREE(hal_sensor_names[i]); + } + FREE(hal_sensor_names); + FREE(hal_sensor_funcs); + hal_initialized = 0; return 0; @@ -68,15 +139,31 @@ int hal_sensor_put_backend(void) EXPORT int hal_sensor_create(sensor_device_t **devices) { - int ret; + int ret, ret_create; + int i, j; + sensor_device_t *device; if (!hal_sensor_funcs && !hal_initialized) { if ((ret = hal_sensor_get_backend()) < 0) return ret; } - if (!hal_sensor_funcs || !hal_sensor_funcs->create) + if (!hal_sensor_funcs || (hal_sensor_count == 0)) return -ENODEV; - return hal_sensor_funcs->create(devices); + if (hal_backend_devs.empty()) { + for (i = 0; i < hal_sensor_count; i++) { + if (!hal_sensor_funcs[i] || !hal_sensor_funcs[i]->create) + continue; + + ret_create = hal_sensor_funcs[i]->create(&device); + for (j = 0; j < ret_create; j++) + { + hal_backend_devs.push_back(device[j]); + } + } + } + + *devices = &hal_backend_devs[0]; + return hal_backend_devs.size(); } -- 2.7.4 From f0f58a0bff4126e122af6676e6ada40f60e2781a Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Tue, 13 Jul 2021 11:35:15 +0900 Subject: [PATCH 08/16] Change hal_common_get_backend_library_names API parameter. Change-Id: I1bca6851b6a8b2704622ebf44fbf4bfa6b413ce5 Signed-off-by: Yunmi Ha --- src/hal-api-sensor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hal-api-sensor.cpp b/src/hal-api-sensor.cpp index 7dbbd99..02a88b5 100644 --- a/src/hal-api-sensor.cpp +++ b/src/hal-api-sensor.cpp @@ -42,6 +42,8 @@ static std::vector hal_backend_devs; #define FREE(x) \ do { if (x) { free(x); x = NULL; } } while(0) +#define MAX_LIB_NAME 256 + EXPORT int hal_sensor_get_backend(void) { @@ -69,14 +71,14 @@ int hal_sensor_get_backend(void) } for (i = 0; i < hal_sensor_count; i++) { - hal_sensor_names[i] = (char *)malloc(sizeof(char) * 256); + hal_sensor_names[i] = (char *)malloc(sizeof(char) * MAX_LIB_NAME); if (!hal_sensor_names[i]) { _E("Failed to allocate memory."); goto FREE_MEMORY; } } - ret_getnames = hal_common_get_backend_library_names(HAL_MODULE_SENSOR, hal_sensor_names, hal_sensor_count); + ret_getnames = hal_common_get_backend_library_names(HAL_MODULE_SENSOR, hal_sensor_names, hal_sensor_count, MAX_LIB_NAME); if (ret_getnames < 0) { _E("Failed to get backend library names."); goto FREE_MEMORY; -- 2.7.4 From 721d9b70d9d1be8e6390e8034b79e1139447e2c0 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Wed, 14 Jul 2021 10:58:39 +0900 Subject: [PATCH 09/16] Change sensor-haltests rpm to hal-api-sensor-haltests Change-Id: I76fae2d91e5e65e8ec7c06eb24bf93cb5cb7ab90 Signed-off-by: Hyotaek Shim --- packaging/hal-api-sensor.spec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packaging/hal-api-sensor.spec b/packaging/hal-api-sensor.spec index c86626f..8c7ac36 100644 --- a/packaging/hal-api-sensor.spec +++ b/packaging/hal-api-sensor.spec @@ -35,11 +35,11 @@ Requires: %{name} = %{version}-%{release} %{name} Interface for product vendor developer ### hal test package ######## -%package -n sensor-haltests +%package haltests Summary: Sensor HAL(Hardware Abstraction Layer) Test Cases Requires: %{name} = %{version}-%{release} -%description -n sensor-haltests +%description haltests Sensor HAL(Hardware Abstraction Layer) Test Cases ### build and install ######### @@ -82,7 +82,7 @@ rm -rf %{buildroot} %{_includedir}/hal/*.h %{_libdir}/pkgconfig/%{name}.pc -%files -n sensor-haltests +%files haltests %manifest %{name}.manifest %license LICENSE %{_bindir}/hal/sensor-haltests -- 2.7.4 From f22456cf0cf1e054d62b4847d28610c03a28c997 Mon Sep 17 00:00:00 2001 From: "taemin.yeom" Date: Mon, 27 Sep 2021 18:45:08 +0900 Subject: [PATCH 10/16] Add checking features in sensor haltest Change-Id: I0d0086eb401d835a0520a94156d5f4512bbda625 Signed-off-by: taemin.yeom --- haltest/CMakeLists.txt | 1 + haltest/main.cpp | 13 +++++++---- haltest/sensor-device.cpp | 10 +++++++-- haltest/sensor-haltest.h | 52 +++++++++++++++++++++++++++++++++++++++++++ packaging/hal-api-sensor.spec | 1 + 5 files changed, 71 insertions(+), 6 deletions(-) diff --git a/haltest/CMakeLists.txt b/haltest/CMakeLists.txt index 97c237c..6cccd68 100644 --- a/haltest/CMakeLists.txt +++ b/haltest/CMakeLists.txt @@ -12,6 +12,7 @@ SET(REQUIRES_LIST ${REQUIRES_LIST} gio-2.0 gmock dlog + capi-system-info ) FIND_LIBRARY( diff --git a/haltest/main.cpp b/haltest/main.cpp index 287c9f4..1a20fef 100644 --- a/haltest/main.cpp +++ b/haltest/main.cpp @@ -12,14 +12,20 @@ protected: static void SetUpHalTestSuite() { } - void SetUp() override {} + 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 {} }; TEST_F(SENSOR_API, GetBackendP) { int ret_val; - ret_val = hal_sensor_get_backend(); EXPECT_EQ(ret_val, 0) << strerr("Failed to get sensor device", ret_val); } @@ -27,12 +33,11 @@ TEST_F(SENSOR_API, GetBackendP) TEST_F(SENSOR_API, CreateP) { int ret_val; - void **devices; ret_val = hal_sensor_create(&devices); if (ret_val == -ENODEV) { SKIP_MESSAGE("Not supported HAL"); - return ; + return; } ASSERT_GT(ret_val, 0) << strerr("Failed to call create", ret_val); ASSERT_NE(devices[0], nullptr) << "Opened devices are invalid."; diff --git a/haltest/sensor-device.cpp b/haltest/sensor-device.cpp index 58bd034..3b87482 100644 --- a/haltest/sensor-device.cpp +++ b/haltest/sensor-device.cpp @@ -13,7 +13,6 @@ public: static void SetUpHalTestSuite() { void **sensors = nullptr; - device_count = hal_sensor_create(&sensors); ASSERT_GT(device_count, 0) << "Failed to get sensor devices"; @@ -23,7 +22,14 @@ public: } } - void SetUp() override{} + 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-haltest.h b/haltest/sensor-haltest.h index 3e030f1..88ef284 100644 --- a/haltest/sensor-haltest.h +++ b/haltest/sensor-haltest.h @@ -16,6 +16,7 @@ #ifndef __SENSOR_HALTEST_H__ #define __SENSOR_HALTEST_H__ +#include #include #include @@ -63,6 +64,57 @@ do { \ #define BUFMAX 256 static char errbuf1[BUFMAX]; +#define FEATURE_NUM 37 +static const char *feature[FEATURE_NUM] = { + "http://tizen.org/feature/sensor.accelerometer", + "http://tizen.org/feature/sensor.accelerometer.wakeup", + "http://tizen.org/feature/sensor.activity_recognition", + "http://tizen.org/feature/sensor.barometer", + "http://tizen.org/feature/sensor.barometer.wakeup", + "http://tizen.org/feature/sensor.geomagnetic_rotation_vector", + "http://tizen.org/feature/sensor.gesture_recognition", + "http://tizen.org/feature/sensor.gravity", + "http://tizen.org/feature/sensor.gyroscope", + "http://tizen.org/feature/sensor.gyroscope_rotation_vector", + "http://tizen.org/feature/sensor.gyroscope.uncalibrated", + "http://tizen.org/feature/sensor.gyroscope.wakeup", + "http://tizen.org/feature/sensor.heart_rate_monitor", + "http://tizen.org/feature/sensor.heart_rate_monitor.batch", + "http://tizen.org/feature/sensor.heart_rate_monitor.led_green", + "http://tizen.org/feature/sensor.heart_rate_monitor.led_green.batch", + "http://tizen.org/feature/sensor.heart_rate_monitor.led_ir", + "http://tizen.org/feature/sensor.heart_rate_monitor.led_red", + "http://tizen.org/feature/sensor.humidity", + "http://tizen.org/feature/sensor.linear_acceleration", + "http://tizen.org/feature/sensor.magnetometer", + "http://tizen.org/feature/sensor.magnetometer.uncalibrated", + "http://tizen.org/feature/sensor.magnetometer.wakeup", + "http://tizen.org/feature/sensor.pedometer", + "http://tizen.org/feature/sensor.photometer", + "http://tizen.org/feature/sensor.photometer.wakeup", + "http://tizen.org/feature/sensor.proximity", + "http://tizen.org/feature/sensor.proximity.wakeup", + "http://tizen.org/feature/sensor.rotation_vector", + "http://tizen.org/feature/sensor.significant_motion", + "http://tizen.org/feature/sensor.sleep_monitor", + "http://tizen.org/feature/sensor.stress_monitor", + "http://tizen.org/feature/sensor.temperature", + "http://tizen.org/feature/sensor.tiltmeter", + "http://tizen.org/feature/sensor.tiltmeter.wakeup", + "http://tizen.org/feature/sensor.ultraviolet", + "http://tizen.org/feature/sensor.wrist_up" +}; + +static bool check_feature_all() { + bool ret, val; + for (int i = 0; i < FEATURE_NUM; ++i) { + ret = system_info_get_platform_bool(feature[i], &val); + if (!ret && val) + return true; + } + return false; +} + static inline const char* strerr(const char* message, int eno) { if (eno == 0) diff --git a/packaging/hal-api-sensor.spec b/packaging/hal-api-sensor.spec index 8c7ac36..ca81eea 100644 --- a/packaging/hal-api-sensor.spec +++ b/packaging/hal-api-sensor.spec @@ -21,6 +21,7 @@ BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gmock) BuildRequires: pkgconfig(hal-api-common) +BuildRequires: pkgconfig(capi-system-info) %description %{name} interface -- 2.7.4 From ddb260cd112300bb0be27f0b7e1e857afaae719b Mon Sep 17 00:00:00 2001 From: "taemin.yeom" Date: Wed, 29 Sep 2021 13:22:42 +0900 Subject: [PATCH 11/16] 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 --- haltest/main.cpp | 4 ++++ haltest/sensor-device.cpp | 10 ++++++++++ haltest/sensor-haltest.h | 6 ++++++ 3 files changed, 20 insertions(+) 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 -- 2.7.4 From 87f764d7d0448a658ec37fabde9d662593e915f8 Mon Sep 17 00:00:00 2001 From: "taemin.yeom" Date: Wed, 29 Sep 2021 13:50:27 +0900 Subject: [PATCH 12/16] Fix redefinition and expression of macro Change-Id: I7c4fe6eaf34371fd00f4520bd02f466cbe549c34 Signed-off-by: taemin.yeom --- haltest/main.cpp | 6 ------ haltest/sensor-device.cpp | 35 +++++++++++++---------------------- 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 #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)) -- 2.7.4 From 985dd0ad44c2180d33ca2fea986819a6e4b3ddcc Mon Sep 17 00:00:00 2001 From: "taemin.yeom" Date: Fri, 17 Dec 2021 19:25:03 +0900 Subject: [PATCH 13/16] Add Lidar HAL sensor type Change-Id: I41fcb83fbb4a320d4025b3acf328d6278cd36821 Signed-off-by: taemin.yeom (cherry picked from commit 32d51134f5c50a6b56965ba3a05ecc5212f83ba7) --- include/hal-sensor-types.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/hal-sensor-types.h b/include/hal-sensor-types.h index d4ee3fe..2c1949c 100644 --- a/include/hal-sensor-types.h +++ b/include/hal-sensor-types.h @@ -153,6 +153,8 @@ typedef enum { SENSOR_DEVICE_GSR, SENSOR_DEVICE_SIMSENSE, SENSOR_DEVICE_PPG, + + SENSOR_DEVICE_LIDAR = 0x8000, } sensor_device_type; /* -- 2.7.4 From 3e2e5598f4ed437afeda9f92eae33a12ca935096 Mon Sep 17 00:00:00 2001 From: "taemin.yeom" Date: Wed, 22 Dec 2021 10:28:59 +0900 Subject: [PATCH 14/16] Add power state attribute enum Change-Id: I9d2c09a432a86f50b7c3c6558129713a35b6f4c3 Signed-off-by: taemin.yeom (cherry picked from commit e02e17cd5412e1f7b31d6ec5da06a84e8f77db1f) --- include/hal-sensor-types.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/hal-sensor-types.h b/include/hal-sensor-types.h index 2c1949c..32c3f20 100644 --- a/include/hal-sensor-types.h +++ b/include/hal-sensor-types.h @@ -523,6 +523,11 @@ enum sensor_attribute { CONVERT_TYPE_ATTR(SENSOR_DEVICE_FALL_DETECTION, 0x1), }; +enum sensor_attribute_common { + SENSOR_ATTR_COMMON_START = 0x1000000, + SENSOR_ATTR_POWER_STATE = SENSOR_ATTR_COMMON_START + 10001, +}; + enum sensor_activity { SENSOR_ACTIVITY_UNKNOWN = 1, SENSOR_ACTIVITY_STILL = 2, -- 2.7.4 From a419703b42da232adcc87c10fc19c6b31ca1f485 Mon Sep 17 00:00:00 2001 From: "taemin.yeom" Date: Fri, 24 Dec 2021 11:11:56 +0900 Subject: [PATCH 15/16] Change SENSOR_DEVICE_LIDAR enum value To avoid overflow in HAL backend Change-Id: I40c3736a1b73e13bdc96b58bf918c6f716c004af Signed-off-by: taemin.yeom --- include/hal-sensor-types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/hal-sensor-types.h b/include/hal-sensor-types.h index 32c3f20..2d407ea 100644 --- a/include/hal-sensor-types.h +++ b/include/hal-sensor-types.h @@ -139,6 +139,8 @@ typedef enum { SENSOR_DEVICE_ECG, SENSOR_DEVICE_FALL_DETECTION, + SENSOR_DEVICE_LIDAR = 0x3000, + SENSOR_DEVICE_CONTEXT = 0x7000, SENSOR_DEVICE_MOTION, SENSOR_DEVICE_PIR, @@ -153,8 +155,6 @@ typedef enum { SENSOR_DEVICE_GSR, SENSOR_DEVICE_SIMSENSE, SENSOR_DEVICE_PPG, - - SENSOR_DEVICE_LIDAR = 0x8000, } sensor_device_type; /* -- 2.7.4 From 4cd75f15361e0ac37d21ba5f94c56cffe8f01496 Mon Sep 17 00:00:00 2001 From: TaeminYeom Date: Fri, 24 Dec 2021 15:52:17 +0900 Subject: [PATCH 16/16] Unify SENSOR_DEVICE_LIDAR enum value with API Change-Id: Ifeda706017a0e459783f9d3df9752607b1ec2439 Signed-off-by: TaeminYeom --- include/hal-sensor-types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/hal-sensor-types.h b/include/hal-sensor-types.h index 2d407ea..3454dc5 100644 --- a/include/hal-sensor-types.h +++ b/include/hal-sensor-types.h @@ -77,6 +77,8 @@ typedef enum { SENSOR_DEVICE_HUMAN_SLEEP_DETECTOR, SENSOR_DEVICE_HUMAN_STRESS_MONITOR, + SENSOR_DEVICE_LIDAR = 1000, + SENSOR_DEVICE_EXERCISE_WALKING = 0x400, SENSOR_DEVICE_EXERCISE_RUNNING, SENSOR_DEVICE_EXERCISE_HIKING, @@ -139,8 +141,6 @@ typedef enum { SENSOR_DEVICE_ECG, SENSOR_DEVICE_FALL_DETECTION, - SENSOR_DEVICE_LIDAR = 0x3000, - SENSOR_DEVICE_CONTEXT = 0x7000, SENSOR_DEVICE_MOTION, SENSOR_DEVICE_PIR, -- 2.7.4