From: Boram Bae Date: Thu, 23 Apr 2020 10:59:18 +0000 (+0900) Subject: [UTC][capi-system-sensor][Non-ACR] Add more logs for utc-sensor X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ab3995d3eb05e2a95e4098cb9c40cb966eb2d7a9;p=test%2Ftct%2Fnative%2Fapi.git [UTC][capi-system-sensor][Non-ACR] Add more logs for utc-sensor Change-Id: I3a66b3d2a7c82c34bd9d18cf0d98960b5a9ab821 Signed-off-by: Boram Bae --- diff --git a/src/utc/sensor/CMakeLists.txt b/src/utc/sensor/CMakeLists.txt index 712463a57..2a0d0ce48 100644 --- a/src/utc/sensor/CMakeLists.txt +++ b/src/utc/sensor/CMakeLists.txt @@ -5,6 +5,7 @@ SET(RPM_NAME "core-${PKG_NAME}-tests") SET(CAPI_LIB "capi-system-sensor") SET(TC_SOURCES + utc-sensor-common.c utc-system-sensor-basic.c utc-system-sensor-recorder.c utc-system-sensor-provider.c diff --git a/src/utc/sensor/utc-sensor-common.c b/src/utc/sensor/utc-sensor-common.c new file mode 100644 index 000000000..38882b3d2 --- /dev/null +++ b/src/utc/sensor/utc-sensor-common.c @@ -0,0 +1,52 @@ +// +// Copyright (c) 2020 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "utc-sensor-common.h" + +#define ADD_CASE_TO_STR(c) \ + case c: \ + ret = #c; \ + break; + +char *sensor_type_e_to_str(sensor_type_e type) +{ + char *ret = "Unknown type"; + + switch (type) + { + SENSOR_TYPES(ADD_CASE_TO_STR); + default: + break; + } + + return ret; +} + +char *sensor_error_to_str(int error) +{ + char *ret = "Unknown error"; + + switch (error) + { + SENSOR_ERRORS(ADD_CASE_TO_STR); + default: + break; + } + + return ret; +} + +#undef ADD_CASE_TO_STR diff --git a/src/utc/sensor/utc-sensor-common.h b/src/utc/sensor/utc-sensor-common.h new file mode 100644 index 000000000..22de8c8b3 --- /dev/null +++ b/src/utc/sensor/utc-sensor-common.h @@ -0,0 +1,61 @@ +// +// Copyright (c) 2020 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#ifndef __TCT_SENSOR_COMMONH_H__ +#define __TCT_SENSOR_COMMONH_H__ + +#include +#include + +#define SENSOR_TYPES(F) \ + F(SENSOR_ACCELEROMETER) \ + F(SENSOR_GRAVITY) \ + F(SENSOR_LINEAR_ACCELERATION) \ + F(SENSOR_MAGNETIC) \ + F(SENSOR_ROTATION_VECTOR) \ + F(SENSOR_ORIENTATION) \ + F(SENSOR_GYROSCOPE) \ + F(SENSOR_LIGHT) \ + F(SENSOR_PRESSURE) \ + F(SENSOR_ULTRAVIOLET) \ + F(SENSOR_TEMPERATURE) \ + F(SENSOR_HUMIDITY) \ + F(SENSOR_HRM) \ + F(SENSOR_HRM_LED_GREEN) \ + F(SENSOR_HRM_LED_IR) \ + F(SENSOR_HRM_LED_RED) \ + F(SENSOR_GYROSCOPE_UNCALIBRATED) \ + F(SENSOR_GEOMAGNETIC_UNCALIBRATED) \ + F(SENSOR_GYROSCOPE_ROTATION_VECTOR) \ + F(SENSOR_GEOMAGNETIC_ROTATION_VECTOR) \ + F(SENSOR_HRM_BATCH) \ + F(SENSOR_HRM_LED_GREEN_BATCH) + +#define SENSOR_ERRORS(F) \ + F(SENSOR_ERROR_NONE) \ + F(SENSOR_ERROR_IO_ERROR) \ + F(SENSOR_ERROR_INVALID_PARAMETER) \ + F(SENSOR_ERROR_OUT_OF_MEMORY) \ + F(SENSOR_ERROR_NOT_NEED_CALIBRATION) \ + F(SENSOR_ERROR_NOT_SUPPORTED) \ + F(SENSOR_ERROR_OPERATION_FAILED) \ + F(SENSOR_ERROR_PERMISSION_DENIED) \ + F(SENSOR_ERROR_NO_DATA) \ + F(SENSOR_ERROR_NOT_AVAILABLE) + +char *sensor_type_e_to_str(sensor_type_e type); +char *sensor_error_to_str(int ret); + +#endif \ No newline at end of file diff --git a/src/utc/sensor/utc-system-sensor-basic.c b/src/utc/sensor/utc-system-sensor-basic.c index 3a61664cc..e02557924 100755 --- a/src/utc/sensor/utc-system-sensor-basic.c +++ b/src/utc/sensor/utc-system-sensor-basic.c @@ -14,7 +14,7 @@ // limitations under the License. // #include "assert.h" -#include +#include "utc-sensor-common.h" #include #include #include @@ -718,6 +718,9 @@ int utc_system_sensor_listener_set_event_cb_p(void) error = sensor_destroy_listener(listener); assert_eq(error, SENSOR_ERROR_NONE); + if (!g_called) { + FPRINTF("[Line : %d][%s] sensor_listener_set_events_cb failed to invoke callback\n", __LINE__, sensor_type_e_to_str(types[i])); + } assert(g_called); } } @@ -859,6 +862,9 @@ int utc_system_sensor_listener_set_events_cb_p(void) error = sensor_destroy_listener(listener); assert_eq(error, SENSOR_ERROR_NONE); + if (!g_called) { + FPRINTF("[Line : %d][%s][%s] sensor_listener_set_events_cb failed to invoke callback\n", __LINE__, sensor_type_e_to_str(types[i])); + } assert(g_called); } }