[UTC][capi-system-sensor][Non-ACR] Add more logs for utc-sensor 85/231685/2
authorBoram Bae <boram21.bae@samsung.com>
Thu, 23 Apr 2020 10:59:18 +0000 (19:59 +0900)
committerBoram Bae <boram21.bae@samsung.com>
Tue, 28 Apr 2020 01:00:18 +0000 (10:00 +0900)
Change-Id: I3a66b3d2a7c82c34bd9d18cf0d98960b5a9ab821
Signed-off-by: Boram Bae <boram21.bae@samsung.com>
src/utc/sensor/CMakeLists.txt
src/utc/sensor/utc-sensor-common.c [new file with mode: 0644]
src/utc/sensor/utc-sensor-common.h [new file with mode: 0644]
src/utc/sensor/utc-system-sensor-basic.c

index 712463a57aa3fde68825cb26349a76f061fdbef2..2a0d0ce48312887ac6941cce0f220aac15c98420 100644 (file)
@@ -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 (file)
index 0000000..38882b3
--- /dev/null
@@ -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 (file)
index 0000000..22de8c8
--- /dev/null
@@ -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 <sensor.h>
+#include <dlog.h>
+
+#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
index 3a61664ccb7d5824fcad2ccfb7a2486da11390d9..e025579241e9966d640bb397af14afdd0f19a4a9 100755 (executable)
@@ -14,7 +14,7 @@
 // limitations under the License.
 //
 #include "assert.h"
-#include <sensor.h>
+#include "utc-sensor-common.h"
 #include <glib.h>
 #include <string.h>
 #include <system_info.h>
@@ -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);
                }
        }