sensord: add sensorctl instead of original sensor-test 38/99938/2
authorkibak.yoon <kibak.yoon@samsung.com>
Thu, 24 Nov 2016 12:03:25 +0000 (21:03 +0900)
committerkibak.yoon <kibak.yoon@samsung.com>
Wed, 30 Nov 2016 13:06:37 +0000 (22:06 +0900)
- this sensorctl is an initial version for the sync,
  it will be updated to the latest version as soon as possible.

Change-Id: Ie532efaecf73fc742810c9b6ce53085ac8e75817
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
35 files changed:
CMakeLists.txt
packaging/sensord.spec
src/sensorctl/CMakeLists.txt [new file with mode: 0644]
src/sensorctl/dbus_util.cpp [new file with mode: 0644]
src/sensorctl/dbus_util.h [new file with mode: 0644]
src/sensorctl/info_manager.cpp [new file with mode: 0644]
src/sensorctl/info_manager.h [new file with mode: 0644]
src/sensorctl/injector.h [new file with mode: 0644]
src/sensorctl/injector_context_orientation.cpp [new file with mode: 0644]
src/sensorctl/injector_context_orientation.h [new file with mode: 0644]
src/sensorctl/injector_manager.cpp [new file with mode: 0644]
src/sensorctl/injector_manager.h [new file with mode: 0644]
src/sensorctl/injector_wrist_up_algo.cpp [new file with mode: 0644]
src/sensorctl/injector_wrist_up_algo.h [new file with mode: 0644]
src/sensorctl/injector_wrist_up_conf.cpp [new file with mode: 0644]
src/sensorctl/injector_wrist_up_conf.h [new file with mode: 0644]
src/sensorctl/loopback_manager.cpp [new file with mode: 0644]
src/sensorctl/loopback_manager.h [new file with mode: 0644]
src/sensorctl/sensor_manager.cpp [new file with mode: 0644]
src/sensorctl/sensor_manager.h [new file with mode: 0644]
src/sensorctl/sensorctl.cpp [new file with mode: 0644]
src/sensorctl/sensorctl_log.h [new file with mode: 0644]
src/sensorctl/tester.h [new file with mode: 0644]
src/sensorctl/tester_manager.cpp [new file with mode: 0644]
src/sensorctl/tester_manager.h [new file with mode: 0644]
src/sensorctl/tester_sensor.cpp [new file with mode: 0644]
src/sensorctl/tester_sensor.h [new file with mode: 0644]
src/test/CMakeLists.txt [deleted file]
src/test/src/api-test.c [deleted file]
src/test/src/check-sensor.c [deleted file]
src/test/src/check-sensor.h [deleted file]
src/test/src/fusion-data-collection.c [deleted file]
src/test/src/multi-process-performance-test.c [deleted file]
src/test/src/multi-thread-performance-test.c [deleted file]
src/test/src/sensor-test.c [deleted file]

index 591edb4..bf31fa9 100644 (file)
@@ -17,4 +17,4 @@ ADD_SUBDIRECTORY(src/server)
 ADD_SUBDIRECTORY(src/client)
 ADD_SUBDIRECTORY(src/shared)
 ADD_SUBDIRECTORY(src/hal)
-ADD_SUBDIRECTORY(src/test)
+ADD_SUBDIRECTORY(src/sensorctl)
index b1439b8..bb1cd3f 100644 (file)
@@ -123,9 +123,5 @@ ln -sf %{_libdir}/libsensor.so.%{version} %{_libdir}/libsensor.so.1
 
 %files -n sensor-test
 %defattr(-,root,root,-)
-%{_bindir}/api-test
-%{_bindir}/sensor-test
-%{_bindir}/multi-thread-performance-test
-%{_bindir}/multi-process-performance-test
-%{_bindir}/fusion-data-collection
+%{_bindir}/sensorctl
 %license LICENSE.APLv2
diff --git a/src/sensorctl/CMakeLists.txt b/src/sensorctl/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1accf2a
--- /dev/null
@@ -0,0 +1,28 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(sensorctl CXX)
+INCLUDE(GNUInstallDirs)
+
+SET(DEPS glib-2.0 gio-2.0)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED ${DEPS})
+
+INCLUDE_DIRECTORIES(
+       ${CMAKE_CURRENT_SOURCE_DIR}
+       ${CMAKE_SOURCE_DIR}/src/hal/
+       ${CMAKE_SOURCE_DIR}/src/client/
+       ${CMAKE_SOURCE_DIR}/src/shared/
+)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+
+# Installing files
+FILE(GLOB_RECURSE SRCS *.cpp)
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} sensor)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)
diff --git a/src/sensorctl/dbus_util.cpp b/src/sensorctl/dbus_util.cpp
new file mode 100644 (file)
index 0000000..886872e
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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 <stdlib.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <sensorctl_log.h>
+
+static GDBusConnection *connection;
+
+bool dbus_init(void)
+{
+       GError *error = NULL;
+       gchar *gaddr;
+
+       if (connection)
+               return true;
+
+#ifndef GLIB_VERSION_2_36
+       g_type_init();
+#endif
+
+       gaddr = g_dbus_address_get_for_bus_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+
+       if (!gaddr) {
+               PRINT("ERROR: Failed to get dbus address : %s", error->message);
+               g_error_free(error);
+               error = NULL;
+               return false;
+       }
+
+       connection = g_dbus_connection_new_for_address_sync(gaddr,
+                       (GDBusConnectionFlags)(G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT
+                       | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION),
+                       NULL, NULL, &error);
+       g_free(gaddr);
+
+       if (!connection) {
+               PRINT("ERROR: Failed to get dbus connection : %s", error->message);
+               g_error_free(error);
+               error = NULL;
+               return false;
+       }
+
+       PRINT("G-DBUS connected[%s]\n",
+                       g_dbus_connection_get_unique_name(connection));
+       return true;
+}
+
+bool dbus_fini(void)
+{
+       if (!connection)
+               return true;
+
+       g_dbus_connection_close_sync(connection, NULL, NULL);
+       g_object_unref(connection);
+       connection = NULL;
+
+       return true;
+}
+
+bool dbus_emit_signal(gchar *dest_bus_name, gchar *object_path,
+               gchar *interface_name, gchar *signal_name,
+               GVariant *variant, GError **error)
+{
+       g_dbus_connection_emit_signal(connection,
+                               dest_bus_name,
+                               object_path,
+                               interface_name,
+                               signal_name,
+                               variant,
+                               error);
+       return true;
+}
+
+GVariant *make_variant_int(int count, char *options[])
+{
+       switch (count) {
+       case 1:
+               return g_variant_new("(i)", atoi(options[0]));
+       case 2:
+               return g_variant_new("(ii)", atoi(options[0]), atoi(options[1]));
+       case 3:
+               return g_variant_new("(iii)", atoi(options[0]), atoi(options[1]), atoi(options[2]));
+       default:
+               break;
+       }
+
+       return NULL;
+}
+
diff --git a/src/sensorctl/dbus_util.h b/src/sensorctl/dbus_util.h
new file mode 100644 (file)
index 0000000..a51d903
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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.
+ *
+ */
+
+#pragma once // _DBUS_UTIL_H_
+
+#include <glib.h>
+#include <gio/gio.h>
+
+bool dbus_init(void);
+bool dbus_fini(void);
+bool dbus_emit_signal(gchar *dest_bus_name, gchar *object_path,
+               gchar *interface_name, gchar *signal_name,
+               GVariant *variant, GError **error);
+GVariant *make_variant_int(int count, char *options[]);
diff --git a/src/sensorctl/info_manager.cpp b/src/sensorctl/info_manager.cpp
new file mode 100644 (file)
index 0000000..676bc40
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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 <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <sensor_internal.h>
+#include <sensorctl_log.h>
+#include "info_manager.h"
+
+bool info_manager::process(int argc, char *argv[])
+{
+       sensor_type_t type;
+
+       if (argc == 2) {
+               usage();
+               return false;
+       }
+
+       type = get_sensor_type(argv[2]);
+       if (type == UNKNOWN_SENSOR)
+               return false;
+
+       sensor_t *sensors;
+       int count;
+
+       sensord_get_sensor_list(type, &sensors, &count);
+       sensor_info(sensors, count);
+
+       free(sensors);
+       return true;
+}
+
+void info_manager::sensor_info(sensor_t *sensors, int count)
+{
+       sensor_t sensor;
+       char *vendor;
+       char *name;
+       float min_range;
+       float max_range;
+       float resolution;
+       int min_interval;
+       int fifo_count;
+       int max_batch_count;
+
+       for (int i = 0; i < count; ++i) {
+               sensor = sensors[i];
+
+               name = const_cast<char *>(sensord_get_name(sensor));
+               vendor = const_cast<char *>(sensord_get_vendor(sensor));
+               sensord_get_max_range(sensor, &max_range);
+               sensord_get_min_range(sensor, &min_range);
+               sensord_get_resolution(sensor, &resolution);
+               sensord_get_min_interval(sensor, &min_interval);
+               sensord_get_fifo_count(sensor, &fifo_count);
+               sensord_get_max_batch_count(sensor, &max_batch_count);
+
+               PRINT("-------sensor[%d] information-------\n", i);
+               PRINT("vendor : %s\n", vendor);
+               PRINT("name : %s\n", name);
+               PRINT("min_range : %f\n", min_range);
+               PRINT("max_range : %f\n", max_range);
+               PRINT("resolution : %f\n", resolution);
+               PRINT("min_interval : %d\n", min_interval);
+               PRINT("fifo_count : %d\n", fifo_count);
+               PRINT("max_batch_count : %d\n", max_batch_count);
+               PRINT("--------------------------------\n");
+       }
+}
+
+void info_manager::usage(void)
+{
+       PRINT("usage: sensorctl info <sensor_type>\n");
+       PRINT("\n");
+
+       usage_sensors();
+}
+
diff --git a/src/sensorctl/info_manager.h b/src/sensorctl/info_manager.h
new file mode 100644 (file)
index 0000000..b71dfc0
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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.
+ *
+ */
+
+#pragma once // _INFO_MANAGER_H_
+
+#include <sensor_internal.h>
+#include "sensor_manager.h"
+
+class info_manager : public sensor_manager {
+public:
+       info_manager() {}
+       virtual ~info_manager() {}
+
+       bool process(int argc, char *argv[]);
+private:
+       void sensor_info(sensor_t *sensors, int count);
+       void usage(void);
+};
diff --git a/src/sensorctl/injector.h b/src/sensorctl/injector.h
new file mode 100644 (file)
index 0000000..f9e8b40
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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.
+ *
+ */
+
+#pragma once // _INJECTOR_H_
+
+#include <sensor_internal.h>
+
+#define SENSORD_BUS_NAME               "org.tizen.system.sensord"
+#define SENSORD_OBJ_PATH               "/Org/Tizen/System/SensorD"
+#define SENSORD_INTERFACE_NAME "org.tizen.system.sensord"
+
+class injector_interface {
+public:
+       virtual bool init(void) { return true; }
+       virtual bool inject(int option_count, char *options[]) = 0;
+};
diff --git a/src/sensorctl/injector_context_orientation.cpp b/src/sensorctl/injector_context_orientation.cpp
new file mode 100644 (file)
index 0000000..863b901
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2016 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 <stdio.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <sensorctl_log.h>
+#include "dbus_util.h"
+#include "injector_manager.h"
+#include "injector_context_orientation.h"
+
+#define CONTEXT_ORIENTATION_SIGNAL     "orientation"
+
+bool injector_context_orientation::inject(int option_count, char *options[])
+{
+       GVariant *variant;
+
+       if (option_count == 0) {
+               _E("ERROR: invalid argument\n");
+               return false;
+       }
+
+       variant = make_variant_int(option_count, options);
+
+       if (variant == NULL)
+               return false;
+
+       dbus_emit_signal(NULL,
+                       (gchar *)SENSORD_OBJ_PATH,
+                       (gchar *)SENSORD_INTERFACE_NAME,
+                       (gchar *)CONTEXT_ORIENTATION_SIGNAL,
+                       variant,
+                       NULL);
+
+       PRINT("set options to context: \n");
+       for (int i = 0; i < option_count; ++i)
+               PRINT("option %d: %s\n", i, options[i]);
+
+       return true;
+}
+
+REGISTER_INJECTOR(CONTEXT_SENSOR, CONTEXT_ORIENTATION_SIGNAL, injector_context_orientation)
diff --git a/src/sensorctl/injector_context_orientation.h b/src/sensorctl/injector_context_orientation.h
new file mode 100644 (file)
index 0000000..01d2d18
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2016 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.
+ *
+ */
+
+#pragma once // _CONTEXT_INJECTOR_H_
+
+#include <glib.h>
+#include <gio/gio.h>
+#include "injector.h"
+
+class injector_context_orientation: public injector_interface {
+public:
+       injector_context_orientation() {}
+       virtual ~injector_context_orientation() {}
+
+       bool inject(int option_count, char *options[]);
+};
diff --git a/src/sensorctl/injector_manager.cpp b/src/sensorctl/injector_manager.cpp
new file mode 100644 (file)
index 0000000..4f6b722
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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 <stdio.h>
+#include <string.h>
+#include <sensor_internal.h>
+#include <sensorctl_log.h>
+#include "dbus_util.h"
+#include "injector.h"
+#include "injector_manager.h"
+
+#define NAME_MAX_TEST 32
+#define ARGC_BASE 4 /* e.g. {sensorctl, inject, wristup, conf} */
+
+static std::vector<injector_info> injector_infos;
+
+injector_manager::injector_manager()
+{
+       if (!dbus_init()) {
+               _E("Failed to init dbus");
+               throw;
+       }
+}
+
+injector_manager::~injector_manager()
+{
+       dbus_fini();
+}
+
+bool injector_manager::register_injector(injector_info info)
+{
+       injector_infos.push_back(info);
+       return true;
+}
+
+injector_interface *injector_manager::get_injector(sensor_type_t type, const char *name)
+{
+       int injector_count;
+       injector_count = injector_infos.size();
+
+       for (int i = 0; i < injector_count; ++i) {
+               if (type == injector_infos[i].type &&
+                   !strcmp(injector_infos[i].name, name))
+                       return injector_infos[i].injector;
+       }
+       return NULL;
+}
+
+bool injector_manager::process(int argc, char *argv[])
+{
+       int option_count;
+       char *options[8];
+       bool result;
+       sensor_type_t type;
+       char *event_name;
+       int i;
+
+       if (argc < 4) {
+               usage();
+               return false;
+       }
+
+       /* 1. get sensor type */
+       type = get_sensor_type(argv[2]);
+       if (type == UNKNOWN_SENSOR) {
+               _E("ERROR : failed to process injector\n");
+               return false;
+       }
+
+       /* 2. set up injector */
+       event_name = argv[3];
+
+       injector_interface *injector = get_injector(type, event_name);
+       if (injector == NULL) {
+               _E("ERROR: cannot find matched injector\n");
+               return false;
+       }
+
+       /* 3. init injector */
+       result = injector->init();
+       if (!result) {
+               _E("ERROR: failed to init injector\n");
+               return false;
+       }
+
+       /* 4. inject event with options */
+       option_count = argc - ARGC_BASE;
+       for (i = 0; i < option_count; ++i) {
+               options[i] = new char[NAME_MAX_TEST];
+               strncpy(options[i], argv[ARGC_BASE+i], sizeof(argv[ARGC_BASE+i]));
+       }
+
+       result = injector->inject(option_count, options);
+       if (!result) {
+               _E("ERROR : failed to process injector\n");
+               for (i = 0; i < option_count; ++i)
+                       delete [] options[i];
+
+               return false;
+       }
+
+       for (i = 0; i < option_count; ++i)
+               delete [] options[i];
+
+       return true;
+}
+
+void injector_manager::usage(void)
+{
+       PRINT("usage: sensorctl inject <sensor_type> [<event_type>] [<options>]\n\n");
+
+       usage_sensors();
+}
+
diff --git a/src/sensorctl/injector_manager.h b/src/sensorctl/injector_manager.h
new file mode 100644 (file)
index 0000000..380c486
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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.
+ *
+ */
+
+#pragma once // _INJECT_MANAGER_H_
+
+#include <sensor_internal.h>
+#include <vector>
+#include "injector.h"
+#include "sensor_manager.h"
+
+#define REGISTER_INJECTOR(sensor_type, sensor_name, injector_type) \
+static void __attribute__((constructor)) reg_injector(void) \
+{ \
+       struct injector_info info; \
+       info.type = (sensor_type); \
+       info.name = (sensor_name); \
+       info.injector = new(std::nothrow) (injector_type)(); \
+       if (!info.injector) { \
+               _E("ERROR: Failed to allocate memory(%s)", #injector_type); \
+               return; \
+       } \
+       injector_manager::register_injector(info); \
+}
+
+struct injector_info {
+       sensor_type_t type;
+       const char *name;
+       injector_interface *injector;
+};
+
+class injector_manager : public sensor_manager {
+public:
+       injector_manager();
+       virtual ~injector_manager();
+
+       bool process(int argc, char *argv[]);
+
+       static bool register_injector(injector_info info);
+private:
+       injector_interface *get_injector(sensor_type_t type, const char *name);
+       void usage(void);
+};
diff --git a/src/sensorctl/injector_wrist_up_algo.cpp b/src/sensorctl/injector_wrist_up_algo.cpp
new file mode 100644 (file)
index 0000000..766e6ec
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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 <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <map>
+#include <string>
+#include <sensorctl_log.h>
+#include "dbus_util.h"
+#include "injector_manager.h"
+#include "injector_wrist_up_algo.h"
+
+#define WRIST_UP_ALGO_SIGNAL "algo"
+#define OPTION_INDEX 0
+
+typedef std::map<std::string, int> option_map_t;
+static option_map_t option_map;
+
+bool injector_wrist_up_algo::init(void)
+{
+       option_map.insert(option_map_t::value_type("auto", 0));
+       option_map.insert(option_map_t::value_type("green", 1));
+       option_map.insert(option_map_t::value_type("purple", 2));
+       option_map.insert(option_map_t::value_type("red", 3));
+
+       return true;
+}
+
+bool injector_wrist_up_algo::inject(int option_count, char *options[])
+{
+       int option;
+
+       if (option_count == 0) {
+               _E("ERROR: invalid argument\n");
+               return false;
+       }
+
+       option_map_t::iterator it;
+       it = option_map.find(options[OPTION_INDEX]);
+
+       if (it == option_map.end()) {
+               _E("ERROR: no matched-option: %s\n", options[OPTION_INDEX]);
+               return false;
+       }
+
+       option = it->second;
+
+       dbus_emit_signal(NULL,
+                       (gchar *)SENSORD_OBJ_PATH,
+                       (gchar *)SENSORD_INTERFACE_NAME,
+                       (gchar *)WRIST_UP_ALGO_SIGNAL,
+                       g_variant_new("(i)", option),
+                       NULL);
+
+       _I("set [%s] mode to wristup (%d)", options[OPTION_INDEX], option);
+       return true;
+}
+
+REGISTER_INJECTOR(MOTION_SENSOR, "algo", injector_wrist_up_algo)
diff --git a/src/sensorctl/injector_wrist_up_algo.h b/src/sensorctl/injector_wrist_up_algo.h
new file mode 100644 (file)
index 0000000..a5bd6fe
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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.
+ *
+ */
+
+#pragma once // _WRISTUP_INJECTOR_H_
+
+#include <glib.h>
+#include <gio/gio.h>
+#include "injector.h"
+
+class injector_wrist_up_algo: public injector_interface {
+public:
+       injector_wrist_up_algo() {}
+       virtual ~injector_wrist_up_algo() {}
+
+       bool init(void);
+       bool inject(int option_count, char *options[]);
+};
diff --git a/src/sensorctl/injector_wrist_up_conf.cpp b/src/sensorctl/injector_wrist_up_conf.cpp
new file mode 100644 (file)
index 0000000..11e7a2f
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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 <stdio.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <sensorctl_log.h>
+#include "dbus_util.h"
+#include "injector_manager.h"
+#include "injector_wrist_up_conf.h"
+
+#define WRIST_UP_CONF_SIGNAL                   "conf"
+
+bool injector_wrist_up_conf::inject(int option_count, char *options[])
+{
+       GVariant *variant;
+
+       if (option_count == 0) {
+               _E("ERROR: invalid argument\n");
+               return false;
+       }
+
+       variant = make_variant_int(option_count, options);
+
+       if (variant == NULL)
+               return false;
+
+       dbus_emit_signal(NULL,
+                       (gchar *)SENSORD_OBJ_PATH,
+                       (gchar *)SENSORD_INTERFACE_NAME,
+                       (gchar *)WRIST_UP_CONF_SIGNAL,
+                       variant,
+                       NULL);
+
+       PRINT("set options to wristup: \n");
+       for (int i = 0; i < option_count; ++i)
+               PRINT("option %d: %s\n", i, options[i]);
+
+       return true;
+}
+
+REGISTER_INJECTOR(MOTION_SENSOR, "conf", injector_wrist_up_conf)
+
diff --git a/src/sensorctl/injector_wrist_up_conf.h b/src/sensorctl/injector_wrist_up_conf.h
new file mode 100644 (file)
index 0000000..93b75f4
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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.
+ *
+ */
+
+#pragma once // _WRISTUP_INJECTOR_H_
+
+#include <glib.h>
+#include <gio/gio.h>
+#include "injector.h"
+
+#define NAME_MAX_TEST 32
+
+class injector_wrist_up_conf: public injector_interface {
+public:
+       injector_wrist_up_conf() {}
+       virtual ~injector_wrist_up_conf() {}
+
+       bool inject(int option_count, char *options[]);
+};
diff --git a/src/sensorctl/loopback_manager.cpp b/src/sensorctl/loopback_manager.cpp
new file mode 100644 (file)
index 0000000..4b78007
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2016 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sensor_internal.h>
+#include <sensorctl_log.h>
+#include "loopback_manager.h"
+
+#define SHUB_INST_LIB_ADD      ((char)-79)
+#define SHUB_INST_LIB_REMOVE   ((char)-78)
+#define SHUB_LOOP_BACK_LIB     12
+#define DEFAULT_COMMAND_SIZE   3
+#define MAX_COMMAND_SIZE       82
+#define MAX_DATA_SIZE          84      /* -79, 12, 4byte Delaytime + 78 bytes data */
+
+static void int_to_bytes(int32_t value, int length, char cmd[])
+{
+       /* Convert to Big-endian */
+       for (int i = length - 1; i >= 0; i--) {
+               cmd[i] = (value & 0xff);
+               value = value >> 8;
+       }
+}
+
+bool loopback_manager::process(int argc, char *argv[])
+{
+       sensor_type_t type;
+
+       if (argc < DEFAULT_COMMAND_SIZE || argc > MAX_COMMAND_SIZE) {
+               usage();
+               return false;
+       }
+
+       if (!strcmp(argv[2], "start")) {
+               int handle;
+               sensor_t sensor;
+               sensor = sensord_get_sensor(CONTEXT_SENSOR);
+               handle = sensord_connect(sensor);
+
+               /*
+                *  sensorhub (bytes) command [0~1] delaytime [2~5] data[6~83]
+                *      shell (argv)  command [0~2] delaytime [3]   data[4~81]
+                */
+               char test_data[MAX_DATA_SIZE] = {SHUB_INST_LIB_ADD, SHUB_LOOP_BACK_LIB,};
+               int_to_bytes(atoi(argv[3]), sizeof(int), &(test_data[2]));
+
+               for (int i = 4; i < argc; i++)
+                       test_data[i+2] = atoi(argv[i]);
+
+               sensord_set_attribute_str(handle, 0, test_data, sizeof(test_data));
+               sensord_disconnect(handle);
+               return true;
+       }
+
+       if (!strcmp(argv[2], "stop")) {
+               int handle;
+               sensor_t sensor;
+               sensor = sensord_get_sensor(CONTEXT_SENSOR);
+               handle = sensord_connect(sensor);
+
+               char test_data[4] = {SHUB_INST_LIB_REMOVE, SHUB_LOOP_BACK_LIB,};
+
+               sensord_set_attribute_str(handle, 0, test_data, sizeof(test_data));
+               sensord_disconnect(handle);
+               return true;
+       }
+
+       usage();
+
+       return false;
+}
+
+void loopback_manager::usage(void)
+{
+       PRINT("usage: sensorctl loopback [start/stop] [14byte sensor char data]\n");
+       PRINT("ex: sensorctl loopback start 15000 1 1 19 1 (after 15000ms, wrist up event)\n");
+       PRINT("ex: sensorctl loopback stop\n");
+       PRINT(" * if not enought 14byte, remain bytes are filled with 0\n");
+       PRINT("\n");
+}
+
diff --git a/src/sensorctl/loopback_manager.h b/src/sensorctl/loopback_manager.h
new file mode 100644 (file)
index 0000000..2aa3297
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2016 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.
+ *
+ */
+
+#pragma once // _LOOPBACK_MANAGER_H_
+
+#include <sensor_internal.h>
+#include "sensor_manager.h"
+
+class loopback_manager : public sensor_manager {
+public:
+       loopback_manager() {}
+       virtual ~loopback_manager() {}
+
+       bool process(int argc, char *argv[]);
+private:
+       void usage(void);
+};
diff --git a/src/sensorctl/sensor_manager.cpp b/src/sensorctl/sensor_manager.cpp
new file mode 100644 (file)
index 0000000..ce2e4ef
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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 <string.h>
+#include <macro.h>
+#include <sensorctl_log.h>
+#include "sensor_manager.h"
+
+#define NAME_MAX_TEST 32
+
+struct sensor_info {
+       sensor_type_t type;
+       char name[NAME_MAX_TEST];
+};
+
+static struct sensor_info sensor_infos[] = {
+       {ALL_SENSOR,                            "all"},
+
+       // General Sensors
+       {ACCELEROMETER_SENSOR,          "accelerometer"},
+       {GEOMAGNETIC_SENSOR,            "magnetic"},
+       {LIGHT_SENSOR,                          "light"},
+       {PROXIMITY_SENSOR,                      "proximity"},
+       {GYROSCOPE_SENSOR,                      "gyroscope"},
+       {PRESSURE_SENSOR,                       "pressure"},
+       {BIO_SENSOR,                            "bio"},
+       {BIO_HRM_SENSOR,                        "hrm"},
+       {AUTO_ROTATION_SENSOR,          "auto_rotation"},
+       {GRAVITY_SENSOR,                        "gravity"},
+       {LINEAR_ACCEL_SENSOR,           "linear_accel"},
+       {ROTATION_VECTOR_SENSOR,        "rotation_vector"},
+       {ORIENTATION_SENSOR,            "orientation"},
+       {TEMPERATURE_SENSOR,            "temperature"},
+       {HUMIDITY_SENSOR,                       "humidity"},
+       {ULTRAVIOLET_SENSOR,            "ultraviolet"},
+       {BIO_LED_GREEN_SENSOR,          "hrm_led_green"},
+       {BIO_LED_IR_SENSOR,                     "hrm_led_ir"},
+       {BIO_LED_RED_SENSOR,            "hrm_led_red"},
+       {GYROSCOPE_UNCAL_SENSOR,        "gyro_uncal"},
+       {GEOMAGNETIC_UNCAL_SENSOR,      "mag_uncal"},
+       {GYROSCOPE_RV_SENSOR,           "gyro_rv"},
+       {GEOMAGNETIC_RV_SENSOR,         "mag_rv"},
+       /* If WRIST_UP_SENSOR is created, it has to be changed to WRIST_UP_SENSOR */
+       {MOTION_SENSOR,                         "motion"},
+       {CONTEXT_SENSOR,                        "context"},
+       {EXERCISE_SENSOR,                       "exercise"},
+       {GESTURE_WRIST_UP_SENSOR,       "wristup"},
+};
+
+bool sensor_manager::process(int argc, char *argv[])
+{
+       return false;
+}
+
+void sensor_manager::usage_sensors(void)
+{
+       PRINT("The sensor types are:\n");
+       int sensor_count = ARRAY_SIZE(sensor_infos);
+
+       for (int i = 0; i < sensor_count; ++i)
+               PRINT("  %d: %s(%d)\n", i, sensor_infos[i].name, sensor_infos[i].type);
+       PRINT("\n");
+}
+
+sensor_type_t sensor_manager::get_sensor_type(char *name)
+{
+       int index;
+       int sensor_count = ARRAY_SIZE(sensor_infos);
+
+       for (index = 0; index < sensor_count; ++index) {
+               if (!strcmp(sensor_infos[index].name, name))
+                       break;
+       }
+
+       if (index == sensor_count) {
+               _E("ERROR: sensor name is wrong\n");
+               usage_sensors();
+               return UNKNOWN_SENSOR;
+       }
+       return sensor_infos[index].type;
+}
+
+const char *sensor_manager::get_sensor_name(sensor_type_t type)
+{
+       int index;
+       int sensor_count = ARRAY_SIZE(sensor_infos);
+
+       for (index = 0; index < sensor_count; ++index) {
+               if (sensor_infos[index].type == type)
+                       break;
+       }
+
+       if (index == sensor_count) {
+               _E("ERROR: sensor name is wrong\n");
+               usage_sensors();
+               return "UNKNOWN SENSOR";
+       }
+       return sensor_infos[index].name;
+}
diff --git a/src/sensorctl/sensor_manager.h b/src/sensorctl/sensor_manager.h
new file mode 100644 (file)
index 0000000..9fd3476
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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.
+ *
+ */
+
+#pragma once // _SENSOR_MANAGER_H_
+
+#include <sensor_internal.h>
+
+class sensor_manager {
+public:
+       virtual bool process(int argc, char *argv[]);
+protected:
+       void usage_sensors(void);
+
+       sensor_type_t get_sensor_type(char *name);
+       const char * get_sensor_name(sensor_type_t type);
+};
diff --git a/src/sensorctl/sensorctl.cpp b/src/sensorctl/sensorctl.cpp
new file mode 100644 (file)
index 0000000..aa4543e
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+
+#include <sensorctl_log.h>
+#include "sensor_manager.h"
+#include "tester_manager.h"
+#include "injector_manager.h"
+#include "info_manager.h"
+#include "loopback_manager.h"
+
+static void good_bye(void)
+{
+}
+
+static void signal_handler(int signo)
+{
+       _E("\nReceived SIGNAL(%d)\n", signo);
+       exit(EXIT_SUCCESS);
+
+       return;
+}
+
+void usage(void)
+{
+       PRINT("usage: sensorctl <command> <sensor_type> [<args>]\n");
+
+       PRINT("The sensorctl commands are:\n");
+       PRINT("  test:   test sensor(s)\n");
+       PRINT("  inject: inject the event to sensor\n");
+       PRINT("  info:   show sensor infos\n");
+       PRINT("  loopback: sensor loopback test\n");
+}
+
+sensor_manager *create_manager(int argc, char *argv[2])
+{
+       sensor_manager *manager = NULL;
+
+       if (!strcmp(argv[1], "test"))
+               manager = new(std::nothrow) tester_manager;
+       if (!strcmp(argv[1], "inject"))
+               manager = new(std::nothrow) injector_manager;
+       if (!strcmp(argv[1], "info"))
+               manager = new(std::nothrow) info_manager;
+       if (!strcmp(argv[1], "loopback"))
+               manager = new(std::nothrow) loopback_manager;
+
+       if (!manager) {
+               _E("failed to allocate memory for manager");
+               return NULL;
+       }
+
+       return manager;
+}
+
+int main(int argc, char *argv[])
+{
+       atexit(good_bye);
+
+       signal(SIGINT,  signal_handler);
+       signal(SIGHUP,  signal_handler);
+       signal(SIGTERM, signal_handler);
+       signal(SIGQUIT, signal_handler);
+       signal(SIGABRT, signal_handler);
+
+       if (argc < 2) {
+               usage();
+               return 0;
+       }
+
+       sensor_manager *manager = create_manager(argc, argv);
+       if (!manager) {
+               usage();
+               return 0;
+       }
+
+       manager->process(argc, argv);
+
+       return 0;
+}
diff --git a/src/sensorctl/sensorctl_log.h b/src/sensorctl/sensorctl_log.h
new file mode 100644 (file)
index 0000000..f5f8f25
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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.
+ *
+ */
+
+#pragma once // _SENSORCTL_LOG_H_
+
+#include <glib.h>
+#include <stdio.h>
+
+#define KNRM  "\x1B[0m"
+#define KRED  "\x1B[31m"
+#define KGRN  "\x1B[32m"
+#define KYEL  "\x1B[33m"
+#define KBLU  "\x1B[34m"
+#define KMAG  "\x1B[35m"
+#define KCYN  "\x1B[36m"
+#define KWHT  "\x1B[37m"
+#define RESET "\033[0m"
+
+#define PRINT(fmt, args...) \
+       do { \
+               g_print(fmt, ##args); \
+       } while (0)
+
+#define _E(fmt, args...) \
+       do { \
+               g_print("\x1B[31m" fmt "\033[0m", ##args); \
+       } while (0)
+
+#define _I(fmt, args...) \
+       do { \
+               g_print("\x1B[32m" fmt "\033[0m", ##args); \
+       } while (0)
+
diff --git a/src/sensorctl/tester.h b/src/sensorctl/tester.h
new file mode 100644 (file)
index 0000000..2d912c9
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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.
+ *
+ */
+
+#pragma once // _TESTER_H_
+
+#include <sensor_internal.h>
+
+class tester_interface {
+public:
+       virtual bool init(void) = 0;
+       virtual bool test(sensor_type_t type, int option_count, char *options[]) = 0;
+};
diff --git a/src/sensorctl/tester_manager.cpp b/src/sensorctl/tester_manager.cpp
new file mode 100644 (file)
index 0000000..ffd9e57
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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 <stdio.h>
+#include <string.h>
+#include <sensor_internal.h>
+#include <sensorctl_log.h>
+#include "tester.h"
+#include "tester_manager.h"
+#include "tester_sensor.h"
+
+#define NAME_MAX_TEST 32
+#define ARGC_BASE 3 /* e.g. {sensorctl, test, accelerometer} */
+
+bool tester_manager::process(int argc, char *argv[])
+{
+       int option_count;
+       char *options[8];
+       sensor_type_t type;
+       int i;
+
+       if (argc == 2) {
+               usage();
+               return false;
+       }
+
+       /* 1. get sensor type */
+       type = get_sensor_type(argv[2]);
+       if (type == UNKNOWN_SENSOR) {
+               _E("ERROR : failed to process injector\n");
+               return false;
+       }
+
+       /* 2. set up injector */
+       tester_interface *tester = new tester_sensor();
+       tester->init();
+
+       /* 3. test sensor with options */
+       option_count = argc - ARGC_BASE;
+       for (i = 0; i < option_count; ++i) {
+               options[i] = new char[NAME_MAX_TEST];
+               strncpy(options[i], argv[ARGC_BASE+i], sizeof(argv[ARGC_BASE+i]));
+       }
+
+       tester->test(type, option_count, options);
+
+       return true;
+}
+
+void tester_manager::usage(void)
+{
+       PRINT("usage: sensorctl test <sensor_type> [interval] [event_count] [test_count]\n\n");
+
+       usage_sensors();
+
+       PRINT("interval_ms:\n");
+       PRINT("  interval. default value is 100ms.\n");
+       PRINT("event count(n):\n");
+       PRINT("  test sensor until it gets n event. default is 999999(infinitly).\n");
+       PRINT("test count(n):\n");
+       PRINT("  test sensor in n times repetitively, default is 1.\n\n");
+}
+
diff --git a/src/sensorctl/tester_manager.h b/src/sensorctl/tester_manager.h
new file mode 100644 (file)
index 0000000..16f4b16
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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.
+ *
+ */
+
+#pragma once // _TEST_MANAGER_H_
+
+#include "sensor_manager.h"
+
+class tester_manager : public sensor_manager {
+public:
+       tester_manager() {}
+       virtual ~tester_manager() {}
+
+       bool process(int argc, char *argv[]);
+private:
+       void usage(void);
+};
diff --git a/src/sensorctl/tester_sensor.cpp b/src/sensorctl/tester_sensor.cpp
new file mode 100644 (file)
index 0000000..5a75da6
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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 <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <sensor_internal.h>
+#include <sensorctl_log.h>
+#include "tester_sensor.h"
+
+#define DEFAULT_INTERVAL 100
+#define DEFAULT_LATENCY 0
+#define DEFAULT_TEST_COUNT 1
+#define DEFAULT_EVENT_COUNT 9999
+
+#define SENSOR_SHIFT_TYPE 16
+
+static GMainLoop *mainloop;
+static int check_loop;
+
+static const char *result_str(bool result) {
+       if (result)             return KGRN"[PASS]"RESET;
+       else                    return KRED"[FAIL]"RESET;
+}
+
+bool tester_sensor::init(void)
+{
+       return true;
+}
+
+void tester_sensor::test_cb(sensor_t sensor, unsigned int event_type, sensor_data_t *data, void *user_data)
+{
+       sensor_type_t type;
+       int *cnt_event;
+
+       sensord_get_type(sensor, &type);
+
+       cnt_event = (int *)user_data;
+
+       if (check_loop++ >= *cnt_event) {
+               if (!mainloop)
+                       return;
+
+               g_main_loop_quit(mainloop);
+               g_main_loop_unref(mainloop);
+               mainloop = NULL;
+               return;
+       }
+
+       PRINT("[%llu] %s:", data->timestamp, sensord_get_name(sensor));
+
+       if (type == GESTURE_WRIST_UP_SENSOR) {
+               PRINT("[%d]\n", ((sensorhub_data_t *)data)->hub_data[0]);
+               return;
+       }
+
+       for (int i = 0; i < data->value_count; ++i)
+               PRINT(" [%f]", data->values[i]);
+       PRINT("\n");
+}
+
+void tester_sensor::test_sensor(sensor_type_t type, int interval, int latency, int cnt_test, int cnt_event)
+{
+       bool result;
+       sensor_t sensor;
+       unsigned int event_id;
+       sensor_data_t data;
+       int handle;
+       int count = 0;
+
+       event_id = type << SENSOR_SHIFT_TYPE | 0x1;
+
+       while (count++ < cnt_test) {
+               mainloop = g_main_loop_new(NULL, FALSE);
+               check_loop = 0;
+
+               PRINT("=======================================\n");
+               PRINT("TEST(%d/%d)\n", count, cnt_test);
+               PRINT("=======================================\n");
+
+               sensor = sensord_get_sensor(type);
+               PRINT("%s sensord_get_sensor: sensor(%p)\n", result_str((sensor == NULL)? 0 : 1), sensor);
+
+               handle = sensord_connect(sensor);
+               PRINT("%s sensord_connect: handle(%d)\n", result_str((handle >= 0)), handle);
+
+               result = sensord_register_event(handle, event_id, interval, latency, test_cb, (void *)&cnt_event);
+               PRINT("%s sensord_register_event\n", result_str(result));
+
+               result = sensord_start(handle, 3);
+               PRINT("%s sensord_start\n", result_str(result));
+
+               result = sensord_get_data(handle, event_id, &data);
+               PRINT("%s sensord_get_data\n", result_str(result));
+
+               result = sensord_flush(handle);
+               PRINT("%s sensord_flush\n", result_str(result));
+
+               if (result) {
+                       for (int i = 0; i < data.value_count; ++i)
+                               PRINT("[%f] ", data.values[i]);
+                       PRINT("\n");
+               }
+
+               g_main_loop_run(mainloop);
+
+               result = sensord_unregister_event(handle, event_id);
+               PRINT("%s sensord_unregister_event: handle(%d)\n", result_str(result), handle);
+               result = sensord_stop(handle);
+               PRINT("%s sensord_stop: handle(%d)\n", result_str(result), handle);
+               result = sensord_disconnect(handle);
+               PRINT("%s sensord_disconnect: handle(%d)\n", result_str(result), handle);
+       }
+}
+
+bool tester_sensor::test(sensor_type_t type, int option_count, char *options[])
+{
+       int interval = DEFAULT_INTERVAL;
+       int latency = DEFAULT_LATENCY;
+       int cnt_test = DEFAULT_TEST_COUNT;
+       int cnt_event = DEFAULT_EVENT_COUNT;
+
+       sensor_type_t sensor_type = type;
+
+       if (option_count >= 1)
+               interval = atoi(options[0]);
+       if (option_count >= 2)
+               cnt_event = atoi(options[1]);
+       if (option_count >= 3)
+               cnt_test = atoi(options[2]);
+
+       test_sensor(sensor_type, interval, latency, cnt_test, cnt_event);
+       return true;
+}
diff --git a/src/sensorctl/tester_sensor.h b/src/sensorctl/tester_sensor.h
new file mode 100644 (file)
index 0000000..68b76b4
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * sensorctl
+ *
+ * Copyright (c) 2015 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.
+ *
+ */
+
+#pragma once // _SENSOR_TESTER_H_
+
+#include "tester.h"
+
+class tester_sensor : public tester_interface {
+public:
+       tester_sensor() {}
+       virtual ~tester_sensor() {}
+
+       virtual bool init(void);
+       virtual bool test(sensor_type_t type, int option_count, char *options[]);
+private:
+       void test_sensor(sensor_type_t type, int interval, int latency, int cnt_test, int cnt_event);
+       static void test_cb(sensor_t sensor, unsigned int event_type, sensor_data_t *data, void *user_data);
+};
diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt
deleted file mode 100644 (file)
index d9e3ec9..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-project(sensor-tc C)
-
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(EXEC_PREFIX "\${prefix}")
-SET(VERSION 1.0)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED glib-2.0)
-
-add_definitions(${rpkgs_CFLAGS})
-add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}")
-
-include_directories(${CMAKE_CURRENT_SOURCE_DIR})
-include_directories(${CMAKE_SOURCE_DIR}/src/client)
-include_directories(${CMAKE_SOURCE_DIR}/src/shared)
-include_directories(${CMAKE_SOURCE_DIR}/src/hal)
-
-FOREACH(flag ${pkgs_CFLAGS})
-       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-
-link_directories(${CMAKE_SOURCE_DIR}/src/client/)
-
-add_executable(api-test src/api-test.c)
-add_executable(sensor-test src/sensor-test.c src/check-sensor.c)
-add_executable(multi-process-performance-test src/multi-process-performance-test.c src/check-sensor.c)
-add_executable(fusion-data-collection src/fusion-data-collection.c)
-add_executable(multi-thread-performance-test src/multi-thread-performance-test.c src/check-sensor.c)
-
-SET_TARGET_PROPERTIES(api-test PROPERTIES LINKER_LANGUAGE C)
-SET_TARGET_PROPERTIES(sensor-test PROPERTIES LINKER_LANGUAGE C)
-SET_TARGET_PROPERTIES(multi-process-performance-test PROPERTIES LINKER_LANGUAGE C)
-SET_TARGET_PROPERTIES(fusion-data-collection PROPERTIES LINKER_LANGUAGE C)
-SET_TARGET_PROPERTIES(multi-thread-performance-test PROPERTIES LINKER_LANGUAGE C)
-
-target_link_libraries(api-test glib-2.0 dlog sensor)
-target_link_libraries(sensor-test glib-2.0 dlog sensor)
-target_link_libraries(multi-process-performance-test glib-2.0 dlog sensor pthread)
-target_link_libraries(fusion-data-collection glib-2.0 dlog sensor)
-target_link_libraries(multi-thread-performance-test glib-2.0 dlog sensor pthread)
-
-INSTALL(TARGETS api-test DESTINATION /usr/bin/)
-INSTALL(TARGETS sensor-test DESTINATION /usr/bin/)
-INSTALL(TARGETS multi-process-performance-test DESTINATION /usr/bin/)
-INSTALL(TARGETS fusion-data-collection DESTINATION /usr/bin/)
-INSTALL(TARGETS multi-thread-performance-test DESTINATION /usr/bin/)
diff --git a/src/test/src/api-test.c b/src/test/src/api-test.c
deleted file mode 100644 (file)
index 2a1ff11..0000000
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2015 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 <time.h>
-#include <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sensor_internal.h>
-#include <sensor_common.h>
-#include <stdbool.h>
-#include <sensor_common.h>
-#include <unistd.h>
-
-#define DEFAULT_EVENT_INTERVAL 100
-
-static GMainLoop *mainloop;
-FILE *fp;
-
-void callback(sensor_t sensor, unsigned int event_type, sensor_data_t *data, void *user_data)
-{
-       g_main_loop_quit(mainloop);
-}
-
-bool check_sensor_api(unsigned int event_type, int cond_value)
-{
-       int handle;
-
-       mainloop = g_main_loop_new(NULL, FALSE);
-
-       sensor_type_t sensor_type = event_type >> 16;
-       sensor_t sensor = sensord_get_sensor(sensor_type);
-
-       handle = sensord_connect(sensor);
-
-       if (handle < 0) {
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_connect\n", sensor_type, event_type);
-               return false;
-       }
-
-       bool is_supported;
-       bool result_boolean = sensord_is_supported_event_type(sensor, event_type, &is_supported);
-       if (!result_boolean && !is_supported) {
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_is_supported_event\n", sensor_type, event_type);
-               return false;
-       }
-
-       int output;
-       result_boolean = sensord_get_min_interval(sensor, &output);
-       if (!result_boolean) {
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_min_interval\n", sensor_type, event_type);
-               return false;
-       }
-
-       float output3;
-       result_boolean = sensord_get_resolution(sensor, &output3);
-       if (!result_boolean) {
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_resolution\n", sensor_type, event_type);
-               return false;
-       }
-
-       result_boolean = sensord_get_max_range(sensor, &output3);
-       if (!result_boolean) {
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_max_range\n", sensor_type, event_type);
-               return false;
-       }
-
-       result_boolean = sensord_get_min_range(sensor, &output3);
-       if (!result_boolean) {
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_min_range\n", sensor_type, event_type);
-               return false;
-       }
-
-       sensor_privilege_t output4;
-       result_boolean = sensord_get_privilege(sensor, &output4);
-       if (!result_boolean) {
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_privilege\n", sensor_type, event_type);
-               return false;
-       }
-
-       const char* result_char = sensord_get_vendor(sensor);
-       if (!result_char) {
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_vendor\n", sensor_type, event_type);
-               return false;
-       }
-
-       result_char = sensord_get_name(sensor);
-       if (!result_char) {
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_name\n", sensor_type, event_type);
-               return false;
-       }
-
-       sensor_type_t output_type;
-       result_boolean = sensord_get_type(sensor, &output_type);
-       if (!result_boolean) {
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_type\n", sensor_type, event_type);
-               return false;
-       }
-
-       unsigned int *output2;
-       result_boolean = sensord_get_supported_event_types(sensor, &output2, &output);
-       if (!result_boolean) {
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_supported_event_types\n", sensor_type, event_type);
-               return false;
-       }
-
-       sensor_t *output_list;
-       result_boolean = sensord_get_sensor_list(sensor_type, &output_list, &output);
-       if (!result_boolean) {
-               free(output2);
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_sensor_list\n", sensor_type, event_type);
-               return false;
-       }
-
-       result_boolean = sensord_register_event(handle, event_type, cond_value, 0, callback, NULL);
-       if (!result_boolean) {
-               free(output2);
-               free(output_list);
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_register_event\n", sensor_type, event_type);
-               return false;
-       }
-
-       result_boolean = sensord_start(handle, 1);
-       if (!result_boolean) {
-               sensord_unregister_event(handle, event_type);
-               sensord_disconnect(handle);
-               free(output2);
-               free(output_list);
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_start\n", sensor_type, event_type);
-               return false;
-       }
-
-       sensor_data_t data;
-       result_boolean = sensord_get_data(handle, event_type, &data);
-       if (!result_boolean) {
-               sensord_unregister_event(handle, event_type);
-               sensord_disconnect(handle);
-               free(output2);
-               free(output_list);
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_data\n", sensor_type, event_type);
-               return false;
-       }
-
-       g_main_loop_run(mainloop);
-       g_main_loop_unref(mainloop);
-
-       result_boolean = sensord_change_event_interval(handle, event_type, 101);
-       if (!result_boolean) {
-               free(output2);
-               free(output_list);
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_change_event_interval\n", sensor_type, event_type);
-               return false;
-       }
-
-       result_boolean = sensord_set_option(handle, SENSOR_OPTION_ON_IN_SCREEN_OFF);
-       if (!result_boolean){
-               free(output2);
-               free(output_list);
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_change_sensor_option\n", sensor_type, event_type);
-               return false;
-       }
-
-       result_boolean = sensord_unregister_event(handle, event_type);
-       if (!result_boolean) {
-               free(output2);
-               free(output_list);
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_unregister_event\n", sensor_type, event_type);
-               return false;
-       }
-
-       result_boolean = sensord_stop(handle);
-       if (!result_boolean) {
-               free(output2);
-               free(output_list);
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_stop\n", sensor_type, event_type);
-               return false;
-       }
-
-       result_boolean = sensord_disconnect(handle);
-       if (!result_boolean) {
-               free(output2);
-               free(output_list);
-               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_disconnect\n", sensor_type, event_type);
-               return false;
-       }
-
-       free(output2);
-       free(output_list);
-
-       return true;
-}
-
-int main(int argc, char **argv)
-{
-       bool result;
-
-       int interval = DEFAULT_EVENT_INTERVAL;
-       if (argc == 2)
-               interval = atof(argv[1]);
-
-       fp = fopen("auto_test.output", "w+");
-
-       result = check_sensor_api(ACCELEROMETER_RAW_DATA_EVENT, interval);
-       fprintf(fp, "Accelerometer - RAW_DATA_REPORT_ON_TIME - %d\n", result);
-
-       result = check_sensor_api(GEOMAGNETIC_RAW_DATA_EVENT, interval);
-       fprintf(fp, "Geomagnetic - RAW_DATA_REPORT_ON_TIME - %d\n", result);
-
-       result = check_sensor_api(GRAVITY_RAW_DATA_EVENT, interval);
-       fprintf(fp, "Gravity - RAW_DATA_REPORT_ON_TIME - %d\n", result);
-
-       result = check_sensor_api(GYROSCOPE_RAW_DATA_EVENT, interval);
-       fprintf(fp, "Gyroscope - RAW_DATA_REPORT_ON_TIME - %d\n", result);
-
-       result = check_sensor_api(LIGHT_LUX_DATA_EVENT, interval);
-       fprintf(fp, "Light - RAW_DATA_REPORT_ON_TIME - %d\n", result);
-
-       result = check_sensor_api(LINEAR_ACCEL_RAW_DATA_EVENT, interval);
-       fprintf(fp, "Linear Accel - RAW_DATA_REPORT_ON_TIME - %d\n", result);
-
-       result = check_sensor_api(ORIENTATION_RAW_DATA_EVENT, interval);
-       fprintf(fp, "Orientation - RAW_DATA_REPORT_ON_TIME - %d\n", result);
-
-       result = check_sensor_api(TILT_RAW_DATA_EVENT, interval);
-       fprintf(fp, "Tilt - RAW_DATA_REPORT_ON_TIME - %d\n", result);
-
-       result = check_sensor_api(PRESSURE_RAW_DATA_EVENT, interval);
-       fprintf(fp, "Pressure - RAW_DATA_REPORT_ON_TIME - %d\n", result);
-
-       result = check_sensor_api(ROTATION_VECTOR_RAW_DATA_EVENT, interval);
-       fprintf(fp, "Rotation Vector - RAW_DATA_REPORT_ON_TIME - %d\n", result);
-
-       result = check_sensor_api(GEOMAGNETIC_RV_RAW_DATA_EVENT, interval);
-       fprintf(fp, "Geomagnetic Rotation Vector - RAW_DATA_REPORT_ON_TIME - %d\n", result);
-
-       result = check_sensor_api(GAMING_RV_RAW_DATA_EVENT, interval);
-       fprintf(fp, "Gaming Rotation Vector - RAW_DATA_REPORT_ON_TIME - %d\n", result);
-
-       result = check_sensor_api(GYROSCOPE_UNCAL_SENSOR, interval);
-       fprintf(fp, "Gyroscope Uncal Sensor - RAW_DATA_REPORT_ON_TIME - %d\n", result);
-
-       result = check_sensor_api(TEMPERATURE_RAW_DATA_EVENT, interval);
-       fprintf(fp, "Temperature - RAW_DATA_REPORT_ON_TIME - %d\n", result);
-
-       result = check_sensor_api(ULTRAVIOLET_RAW_DATA_EVENT, interval);
-       fprintf(fp, "ULTRAVIOLET - RAW_DATA_REPORT_ON_TIME - %d\n", result);
-
-       result = check_sensor_api(BIO_LED_RED_RAW_DATA_EVENT, interval);
-       fprintf(fp, "BIO_LED_RED - RAW_DATA_REPORT_ON_TIME - %d\n", result);
-
-       result = check_sensor_api(FACE_DOWN_RAW_DATA_EVENT, interval);
-       fprintf(fp, "Face Down - RAW_DATA_REPORT_ON_TIME - %d\n", result);
-
-       printf("Logs printed in ./auto_test.output\n");
-       fclose(fp);
-       return 0;
-}
diff --git a/src/test/src/check-sensor.c b/src/test/src/check-sensor.c
deleted file mode 100644 (file)
index 04ea726..0000000
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2014-15 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 <time.h>
-#include <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sensor_internal.h>
-#include <stdbool.h>
-#include <sensor_common.h>
-#include <unistd.h>
-#include <string.h>
-#include "check-sensor.h"
-
-void printpollinglogs(sensor_type_t type,sensor_data_t data)
-{
-       switch(type) {
-       case(ACCELEROMETER_SENSOR):
-               printf("Accelerometer [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2]);
-               break;
-       case(AUTO_ROTATION_SENSOR):
-               printf("Auto Rotation [%lld] [%6.6f]\n\n", data.timestamp, data.values[0]);
-               break;
-       case(GYROSCOPE_SENSOR):
-               printf("Gyroscope [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2]);
-               break;
-       case(PRESSURE_SENSOR):
-               printf("Pressure [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2]);
-               break;
-       case(GEOMAGNETIC_SENSOR):
-               printf("Geomagnetic [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2]);
-               break;
-       case(LIGHT_SENSOR):
-               printf("Light [%lld] [%6.6f]\n\n", data.timestamp, data.values[0]);
-               break;
-       case(TEMPERATURE_SENSOR):
-               printf("Temperature [%lld] [%6.6f]\n\n", data.timestamp, data.values[0]);
-               break;
-       case(PROXIMITY_SENSOR):
-               printf("Proximity [%lld] [%6.6f]\n\n", data.timestamp, data.values[0]);
-               break;
-       case(ULTRAVIOLET_SENSOR):
-               printf("Ultraviolet [%lld] [%6.6f]\n", data.timestamp, data.values[0]);
-               break;
-       case(BIO_LED_RED_SENSOR):
-               printf("Bio_LED_Red [%lld] [%6.6f]\n", data.timestamp, data.values[0]);
-               break;
-       case(ORIENTATION_SENSOR):
-               printf("Orientation [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2]);
-               break;
-       case(TILT_SENSOR):
-               printf("Tilt [%lld] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1]);
-               break;
-       case(GRAVITY_SENSOR):
-               printf("Gravity [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2]);
-               break;
-       case(LINEAR_ACCEL_SENSOR):
-               printf("Linear Acceleration [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2]);
-               break;
-       case(ROTATION_VECTOR_SENSOR):
-               printf("Rotation Vector [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2], data.values[3]);
-               break;
-       case(GEOMAGNETIC_RV_SENSOR):
-               printf("Geomagnetic Rv [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2], data.values[3]);
-               break;
-       case(GYROSCOPE_RV_SENSOR):
-               printf("Gaming Rv [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2], data.values[3]);
-               break;
-       case(GYROSCOPE_UNCAL_SENSOR):
-               printf("Gyroscope Uncal [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2], data.values[3], data.values[4], data.values[5]);
-               break;
-       case(GESTURE_FACE_DOWN_SENSOR):
-               printf("Face Down [%lld] [%6.6f]\n\n", data.timestamp, data.values[0]);
-               break;
-       default:
-               return;
-       }
-}
-
-int get_event(sensor_type_t sensor_type, char str[])
-{
-       switch (sensor_type) {
-       case ACCELEROMETER_SENSOR:
-               if (strcmp(str, "RAW_DATA_EVENT") == 0)
-                       return ACCELEROMETER_RAW_DATA_EVENT;
-               break;
-       case AUTO_ROTATION_SENSOR:
-               if (strcmp(str, "CHANGE_STATE_EVENT") == 0)
-                       return AUTO_ROTATION_CHANGE_STATE_EVENT;
-               break;
-       case GYROSCOPE_SENSOR:
-               if (strcmp(str, "RAW_DATA_EVENT") == 0)
-                       return GYROSCOPE_RAW_DATA_EVENT;
-               break;
-       case PRESSURE_SENSOR:
-               if (strcmp(str, "RAW_DATA_EVENT") == 0)
-                       return PRESSURE_RAW_DATA_EVENT;
-               break;
-       case GEOMAGNETIC_SENSOR:
-               if (strcmp(str, "RAW_DATA_EVENT") == 0)
-                       return GEOMAGNETIC_RAW_DATA_EVENT;
-               break;
-       case LIGHT_SENSOR:
-               if (strcmp(str, "RAW_DATA_EVENT") == 0)
-                       return LIGHT_LUX_DATA_EVENT;
-               break;
-       case TEMPERATURE_SENSOR:
-               if (strcmp(str, "RAW_DATA_EVENT") == 0)
-                       return TEMPERATURE_RAW_DATA_EVENT;
-               break;
-       case PROXIMITY_SENSOR:
-               if (strcmp(str, "CHANGE_STATE_EVENT") == 0)
-                       return PROXIMITY_CHANGE_STATE_EVENT;
-               break;
-       case ULTRAVIOLET_SENSOR:
-               if (strcmp(str, "RAW_DATA_EVENT") == 0)
-                       return ULTRAVIOLET_RAW_DATA_EVENT;
-               break;
-       case BIO_LED_RED_SENSOR:
-               if (strcmp(str, "RAW_DATA_EVENT") == 0)
-                       return BIO_LED_RED_RAW_DATA_EVENT;
-               break;
-       case ORIENTATION_SENSOR:
-               if (strcmp(str, "RAW_DATA_EVENT") == 0)
-                       return ORIENTATION_RAW_DATA_EVENT;
-               break;
-       case TILT_SENSOR:
-               if (strcmp(str, "RAW_DATA_EVENT") == 0)
-                       return TILT_RAW_DATA_EVENT;
-               break;
-       case GRAVITY_SENSOR:
-               if (strcmp(str, "RAW_DATA_EVENT") == 0)
-                       return GRAVITY_RAW_DATA_EVENT;
-               break;
-       case LINEAR_ACCEL_SENSOR:
-               if (strcmp(str, "RAW_DATA_EVENT") == 0)
-                       return LINEAR_ACCEL_RAW_DATA_EVENT;
-               break;
-       case ROTATION_VECTOR_SENSOR:
-               if (strcmp(str, "RAW_DATA_EVENT") == 0)
-                       return ROTATION_VECTOR_RAW_DATA_EVENT;
-               break;
-       case GEOMAGNETIC_RV_SENSOR:
-               if (strcmp(str, "RAW_DATA_EVENT") == 0)
-                       return GEOMAGNETIC_RV_RAW_DATA_EVENT;
-               break;
-       case GYROSCOPE_RV_SENSOR:
-               if (strcmp(str, "RAW_DATA_EVENT") == 0)
-                       return GAMING_RV_RAW_DATA_EVENT;
-               break;
-       case GYROSCOPE_UNCAL_SENSOR:
-               if (strcmp(str, "RAW_DATA_EVENT") == 0)
-                       return GYROSCOPE_UNCAL_RAW_DATA_EVENT;
-               break;
-       case GESTURE_FACE_DOWN_SENSOR:
-               if (strcmp(str, "RAW_DATA_EVENT") == 0)
-                       return FACE_DOWN_RAW_DATA_EVENT;
-               break;
-
-       default:
-               return -1;
-       }
-       return -1;
-}
-
-void callback(sensor_t sensor, unsigned int event_type, sensor_data_t *data, void *user_data)
-{
-       sensor_type_t sensor_type = event_type >> 16;
-
-       switch (sensor_type) {
-       case ACCELEROMETER_SENSOR:
-               printf("Accelerometer [%lld] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
-               break;
-       case AUTO_ROTATION_SENSOR:
-               printf("Auto Rotation [%lld] [%6.6f]\n", data->timestamp, data->values[0]);
-               break;
-       case GYROSCOPE_SENSOR:
-               printf("Gyroscope [%lld] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
-               break;
-       case PRESSURE_SENSOR:
-               printf("Pressure [%lld] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
-               break;
-       case GEOMAGNETIC_SENSOR:
-               printf("Geomagnetic [%lld] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
-               break;
-       case LIGHT_SENSOR:
-               printf("Light [%lld] [%6.6f]\n", data->timestamp, data->values[0]);
-               break;
-       case TEMPERATURE_SENSOR :
-               printf("Temperature [%lld] [%6.6f]\n", data->timestamp, data->values[0]);
-               break;
-       case PROXIMITY_SENSOR:
-               printf("Proximity [%lld] [%6.6f]\n", data->timestamp, data->values[0]);
-               break;
-       case ULTRAVIOLET_SENSOR:
-               printf("Ultraviolet [%lld] [%6.6f]\n", data->timestamp, data->values[0]);
-               break;
-       case BIO_LED_RED_SENSOR:
-               printf("Bio_LED_Red [%lld] [%6.6f]\n", data->timestamp, data->values[0]);
-               break;
-       case ORIENTATION_SENSOR :
-               printf("Orientation [%lld] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
-               break;
-       case TILT_SENSOR :
-               printf("Tilt [%lld] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1]);
-               break;
-       case GRAVITY_SENSOR:
-               printf("Gravity [%lld] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
-               break;
-       case LINEAR_ACCEL_SENSOR:
-               printf("Linear acceleration [%lld] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
-               break;
-       case ROTATION_VECTOR_SENSOR:
-               printf("Rotation vector [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2], data->values[3]);
-               break;
-       case GEOMAGNETIC_RV_SENSOR:
-               printf("Geomagnetic RV [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2], data->values[3]);
-               break;
-       case GYROSCOPE_RV_SENSOR:
-               printf("Gaming RV [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2], data->values[3]);
-               break;
-       case GYROSCOPE_UNCAL_SENSOR:
-               printf("Gyroscope Uncal [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2], data->values[3], data->values[4], data->values[5]);
-               break;
-       case GESTURE_FACE_DOWN_SENSOR:
-               printf("Face Down [%lld] [%6.6f] \n", data->timestamp, data->values[0]);
-               break;
-
-       default:
-               return;
-       }
-}
-
-void *check_sensor(void *arg)
-{
-       struct pthread_arguments * argu = (struct pthread_arguments *) arg;
-
-       GMainLoop *mainloop;
-       int handle;
-       bool result, start_handle, stop_handle;
-
-       mainloop = g_main_loop_new(NULL, FALSE);
-
-       sensor_t sensor = sensord_get_sensor(argu -> sensor_type);
-       handle = sensord_connect(sensor);
-
-       result = sensord_register_event(handle, argu->event, argu->interval, 0, callback, NULL);
-
-       if (!result) {
-               printf("Can't register sensor\n");
-               return NULL;
-       }
-
-       start_handle = sensord_start(handle, 0);
-
-       if (!start_handle) {
-               printf("Error\n\n\n\n");
-               sensord_unregister_event(handle, argu->event);
-               sensord_disconnect(handle);
-               return NULL;
-       }
-
-       g_main_loop_run(mainloop);
-       g_main_loop_unref(mainloop);
-
-       result = sensord_unregister_event(handle, argu->event);
-
-       if (!result) {
-               printf("Error\n\n");
-               return NULL;
-       }
-
-       stop_handle = sensord_stop(handle);
-
-       if (!stop_handle) {
-               printf("Error\n\n");
-               return NULL;
-       }
-
-       sensord_disconnect(handle);
-       return NULL;
-}
-
-int polling_sensor(sensor_type_t sensor_type, unsigned int event)
-{
-       bool result;
-       int handle;
-
-       printf("Polling based\n");
-       sensor_t sensor;
-       sensor = sensord_get_sensor(sensor_type);
-       handle = sensord_connect(sensor);
-       result = sensord_start(handle, 1);
-
-       if (!result) {
-               printf("Can't start the sensor\n");
-               printf("Error\n\n\n\n");
-               return -1;
-       }
-
-       sensor_data_t data;
-
-       while (1) {
-               result = sensord_get_data(handle, event, &data);
-               printpollinglogs(sensor_type, data);
-               usleep(100000);
-       }
-
-       result = sensord_disconnect(handle);
-
-       if (!result) {
-               printf("Can't disconnect sensor\n");
-               printf("Error\n\n\n\n");
-               return -1;
-       }
-
-       return 0;
-}
diff --git a/src/test/src/check-sensor.h b/src/test/src/check-sensor.h
deleted file mode 100644 (file)
index 042dc87..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2014-15 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 CHECK_SENSOR_H
-#define CHECK_SENSOR_H
-
-#include <sensor_types.h>
-
-#define DEFAULT_EVENT_INTERVAL 100
-
-int get_event(sensor_type_t sensor_type, char str[]);
-void callback(sensor_t sensor, unsigned int event_type, sensor_data_t *data, void *user_data);
-void *check_sensor(void *arg);
-void printpollinglogs(sensor_type_t type, sensor_data_t data);
-int polling_sensor(sensor_type_t sensor_type, unsigned int event);
-
-struct pthread_arguments
-{
-       sensor_type_t sensor_type;
-       unsigned int event;
-       int interval;
-};
-#endif
diff --git a/src/test/src/fusion-data-collection.c b/src/test/src/fusion-data-collection.c
deleted file mode 100644 (file)
index 6abd6f5..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2014-15 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 <time.h>
-#include <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sensor_internal.h>
-#include <stdbool.h>
-#include <sensor_common.h>
-#include <unistd.h>
-#include <string.h>
-
-#define MAXSIZE 4
-
-static GMainLoop *mainloop;
-FILE* file_output[MAXSIZE];
-
-void callback(sensor_t sensor, unsigned int event_type, sensor_data_t *data, void *user_data)
-{
-       sensor_type_t sensor_type = event_type >> 16;
-
-       switch (sensor_type) {
-       case ACCELEROMETER_SENSOR:
-               fprintf(file_output[0], "%6.6f %6.6f %6.6f %lld\n", data->values[0], data->values[1], data->values[2], data->timestamp);
-               fflush(file_output[0]);
-               break;
-       case GEOMAGNETIC_SENSOR:
-               fprintf(file_output[1], "%6.6f %6.6f %6.6f %lld\n", data->values[0], data->values[1], data->values[2], data->timestamp);
-               fflush(file_output[1]);
-               break;
-       case GYROSCOPE_SENSOR:
-               fprintf(file_output[2], "%6.6f %6.6f %6.6f %lld\n", data->values[0], data->values[1], data->values[2], data->timestamp);
-               fflush(file_output[2]);
-               break;
-       case PROXIMITY_SENSOR:
-               fprintf(file_output[MAXSIZE-1], "%6.6f %lld\n", data->values[0], data->timestamp);
-               fflush(file_output[MAXSIZE-1]);
-               break;
-       default:
-               return;
-       }
-}
-
-void usage()
-{
-       printf("Usage : ./fusion-data-collection <interval>\n\n");
-
-       printf("interval:\n");
-       printf("The sampling interval in ms.\n");
-       exit(-1);
-}
-
-int main(int argc, char **argv)
-{
-       int interval;
-
-       if (argc == 2) {
-               interval = atoi(argv[1]);
-               if (interval <= 0)
-                       usage();
-       }
-       else
-               usage();
-
-       int i;
-
-       int handle[MAXSIZE];
-       bool result[MAXSIZE], start_handle[MAXSIZE];
-       unsigned int event[MAXSIZE];
-       int sensors[MAXSIZE];
-
-       sensors[0] = ACCELEROMETER_SENSOR;
-       sensors[1] = GEOMAGNETIC_SENSOR;
-       sensors[2] = GYROSCOPE_SENSOR;
-       sensors[MAXSIZE-1] = PROXIMITY_SENSOR;
-
-       mainloop = g_main_loop_new(NULL, FALSE);
-
-       char file_name[50];
-
-       for (i = 0; i < MAXSIZE; i++) {
-               snprintf(file_name, sizeof(file_name), "output_%d", sensors[i]);
-               file_output[i] = fopen(file_name, "w+");
-               sensor_t sensor = sensord_get_sensor(sensors[i]);
-               handle[i] = sensord_connect(sensor);
-               event[i] = (sensors[i] << 16) | 0x0001;
-               result[i] = sensord_register_event(handle[i], event[i], interval, 0, callback, NULL);
-
-               if (!result[i]) {
-                       printf("error: unable to register sensor\n");
-                       return -1;
-               }
-               start_handle[i] = sensord_start(handle[i], 1);
-
-               if (!start_handle[i]) {
-                       printf("error: unable to start handle\n");
-                       sensord_unregister_event(handle[i], event[i]);
-                       sensord_disconnect(handle[i]);
-                       return -1;
-               }
-       }
-
-       g_main_loop_run(mainloop);
-       g_main_loop_unref(mainloop);
-
-       for (i = 0; i < MAXSIZE; i++) {
-               sensord_unregister_event(handle[i], event[i]);
-               sensord_stop(handle[i]);
-               sensord_disconnect(handle[i]);
-       }
-
-       return 0;
-}
diff --git a/src/test/src/multi-process-performance-test.c b/src/test/src/multi-process-performance-test.c
deleted file mode 100644 (file)
index c9b02ec..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2015 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 <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <sensor_common.h>
-#include <sensor_types.h>
-
-#include "check-sensor.h"
-
-void usage()
-{
-       printf("Usage : ./performance-test <TIMEOUT> <interval>(optional)\n\n");
-
-       printf("TIMEOUT:\n");
-       printf("time for which the parallel sensor test cases should run\n");
-
-       printf("interval:\n");
-       printf("The time interval should be entered based on the sampling frequency supported by accelerometer driver on the device in ms.\n");
-       printf("If no value for sensor is entered default value by the driver will be used.\n");
-}
-
-int main(int argc, char** argv)
-{
-       pid_t b = 1;
-
-       int i = 0;
-       int interval = DEFAULT_EVENT_INTERVAL;
-       int TIMEOUT = 10; //in seconds for which all the sensor tests should run
-
-       if(argc < 2) {
-               usage();
-               return -1;
-       }
-       else if(argc == 2){
-               TIMEOUT = atoi(argv[1]);
-               if (TIMEOUT == 0) {
-                       usage();
-                       return -1;
-               }
-       }
-       else {
-               TIMEOUT = atoi(argv[1]);
-               interval = atoi(argv[2]);
-               if (TIMEOUT == 0 || interval == 0) {
-                       usage();
-                       return -1;
-               }
-       }
-
-       //make an array of size MAX and fill it with all the sensors needed to run
-       int MAX = 6;
-       pid_t pids[MAX];
-       sensor_type_t sensor[MAX];
-
-       //Update the value of MAX and add more sensors here to test more sensors in parallel
-       sensor[0] = ACCELEROMETER_SENSOR;
-       sensor[1] = GYROSCOPE_SENSOR;
-       sensor[2] = GEOMAGNETIC_SENSOR;
-       sensor[3] = PRESSURE_SENSOR;
-       sensor[4] = PROXIMITY_SENSOR;
-       sensor[MAX-1] = LIGHT_SENSOR;
-
-       while (i < MAX) {
-               if (b > 0) {
-                       b = fork();
-                       if (b == -1) perror("Fork failed\n");
-                       else if (b == 0) {
-                               break;
-                       }
-                       pids[i] = b;
-                       i++;
-               }
-       }
-
-       if (i < MAX) {
-               // call the sensord test tc-common for a sensor.
-               int event = (sensor[i] << 16) | 0x0001;
-               struct pthread_arguments arg;
-               arg.sensor_type = sensor[i];
-               arg.event = event;
-               arg.interval = interval;
-
-               check_sensor((void*)&arg);
-       }
-       else {
-               // Main Parent Child. Waits for TIMEOUT and then kills all child processes.
-               sleep (TIMEOUT);
-               int j = 0;
-
-               for (j = 0; j < MAX; j++) {
-                       char command[100];
-                       snprintf(command, sizeof(command), "kill %d", pids[j]);
-                       if (system(command) == -1)
-                               return -1;
-               }
-       }
-
-       return 0;
-}
diff --git a/src/test/src/multi-thread-performance-test.c b/src/test/src/multi-thread-performance-test.c
deleted file mode 100644 (file)
index 588c0e7..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2015 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 <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sensor_internal.h>
-#include <stdbool.h>
-#include <sensor_common.h>
-#include <unistd.h>
-#include <string.h>
-#include <pthread.h>
-#include "check-sensor.h"
-
-void usage()
-{
-       printf("Usage : ./multi-sensor <TIMEOUT> <interval>(optional)\n\n");
-       printf("TIMEOUT:\n");
-       printf("time for which the parallel sensor test cases should run\n");
-
-       printf("interval:\n");
-       printf("The time interval should be entered based on the sampling frequency supported by accelerometer driver on the device in ms.\n");
-       printf("If no value for sensor is entered default value by the driver will be used.\n");
-       printf("arg[i].sensor_type: ");
-       printf("[accelerometer] ");
-       printf("[auto_rotation]\n");
-       printf("[gyroscope] ");
-       printf("[pressure] ");
-       printf("[temperature] ");
-       printf("[geomagnetic] ");
-       printf("[orientation] ");
-       printf("[tilt] ");
-       printf("[gravity] ");
-       printf("[linear_accel] ");
-       printf("[rotation_vector] ");
-       printf("[geomagnetic_rv] ");
-       printf("[gaming_rv] ");
-       printf("[ultraviolet] ");
-       printf("[light]\n");
-       printf("[gyro_uncal]");
-       printf("[face_down]");
-
-}
-
-int main(int argc, char **argv)
-{
-
-       int i = 0;
-       int interval = DEFAULT_EVENT_INTERVAL;
-       int TIMEOUT = 10; //in seconds for which all the sensor tests should run
-
-       if(argc < 2) {
-               usage();
-               return -1;
-       }
-       else if(argc == 2){
-               TIMEOUT = atoi(argv[1]);
-               if (TIMEOUT == 0) {
-                       usage();
-                       return -1;
-               }
-       }
-       else {
-               TIMEOUT = atoi(argv[1]);
-               interval = atoi(argv[2]);
-               if (TIMEOUT == 0 || interval == 0) {
-                       usage();
-                       return -1;
-               }
-       }
-
-       int MAX = 6, j = 0, k = 0;
-       struct pthread_arguments arg[MAX];
-       int t = 0;
-
-       arg[0].sensor_type = ACCELEROMETER_SENSOR;
-       arg[0].event = ACCELEROMETER_RAW_DATA_EVENT;
-       arg[1].sensor_type = GYROSCOPE_SENSOR;
-       arg[1].event = GYROSCOPE_RAW_DATA_EVENT;
-       arg[2].sensor_type = GEOMAGNETIC_RV_SENSOR;
-       arg[2].event = GEOMAGNETIC_RV_RAW_DATA_EVENT;
-       arg[3].sensor_type = PRESSURE_SENSOR;
-       arg[3].event = PRESSURE_RAW_DATA_EVENT;
-       arg[4].sensor_type = PROXIMITY_SENSOR;
-       arg[4].event = PROXIMITY_CHANGE_STATE_EVENT;
-       arg[5].sensor_type = LIGHT_SENSOR;
-       arg[5].event = LIGHT_LUX_DATA_EVENT;
-
-       for (t = 0; t < MAX; t++)
-               arg[t].interval = interval;
-
-       pthread_t thread_id[MAX];
-
-       for (j = 0; j < MAX; j++)
-               pthread_create(&thread_id[j], NULL, check_sensor, (void*)&arg[j]);
-
-       sleep(TIMEOUT);
-       return 0;
-}
diff --git a/src/test/src/sensor-test.c b/src/test/src/sensor-test.c
deleted file mode 100644 (file)
index ff2b005..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2014-15 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 <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sensor_internal.h>
-#include <stdbool.h>
-#include <sensor_common.h>
-#include <unistd.h>
-#include <string.h>
-
-#include "check-sensor.h"
-
-void usage()
-{
-       printf("Usage : ./sensor-test <Sensor_type> -p(optional) <event>(optional) <interval>(optional)\n\n");
-
-       printf("Sensor_type: ");
-       printf("[accelerometer] ");
-       printf("[auto_rotation]\n");
-       printf("[gyroscope] ");
-       printf("[pressure] ");
-       printf("[temperature] ");
-       printf("[geomagnetic] ");
-       printf("[orientation] ");
-       printf("[tilt] ");
-       printf("[gravity] ");
-       printf("[linear_accel] ");
-       printf("[rotation_vector] ");
-       printf("[geomagnetic_rv] ");
-       printf("[gaming_rv] ");
-       printf("[ultraviolet] ");
-       printf("[bio_led_red] ");
-       printf("[light]\n");
-       printf("[gyroscope_uncal]");
-       printf("[face_down]");
-       printf("event:");
-       printf("[RAW_DATA_EVENT]\n");
-       printf("-p: [polling]\n");
-       printf("Sensor_type: ");
-       printf("[proximity]\n");
-       printf("event:");
-       printf("[CHANGE_STATE_EVENT]\n");
-       printf("-p: [polling]\n");
-       printf("interval:\n");
-       printf("The time interval should be entered based on the sampling frequency supported by accelerometer driver on the device in ms.If no value for sensor is entered default value by the driver will be used.\n");
-}
-
-int main(int argc, char **argv)
-{
-       int interval;
-       unsigned int event;
-       sensor_type_t sensor_type;
-       bool is_polling;
-
-       char *end1;
-
-       if (argc < 2 || argc > 5) {
-               printf("Wrong number of arguments\n");
-               usage();
-               return -1;
-       }
-
-       if (strcmp(argv[1], "accelerometer") == 0) {
-                sensor_type = ACCELEROMETER_SENSOR;
-                event = ACCELEROMETER_RAW_DATA_EVENT;
-       }
-       else if (strcmp(argv[1], "auto_rotation") == 0) {
-                sensor_type = AUTO_ROTATION_SENSOR;
-                event = AUTO_ROTATION_CHANGE_STATE_EVENT;
-       }
-       else if (strcmp(argv[1], "gyroscope") == 0) {
-                sensor_type = GYROSCOPE_SENSOR;
-                event = GYROSCOPE_RAW_DATA_EVENT;
-       }
-       else if (strcmp(argv[1], "pressure") == 0) {
-                sensor_type = PRESSURE_SENSOR;
-                event = PRESSURE_RAW_DATA_EVENT;
-       }
-       else if (strcmp(argv[1], "temperature") == 0) {
-                sensor_type = TEMPERATURE_SENSOR;
-                event = TEMPERATURE_RAW_DATA_EVENT;
-       }
-       else if (strcmp(argv[1], "geomagnetic") == 0) {
-                sensor_type = GEOMAGNETIC_SENSOR;
-                event = GEOMAGNETIC_RAW_DATA_EVENT;
-       }
-       else if (strcmp(argv[1], "orientation") == 0) {
-                sensor_type = ORIENTATION_SENSOR;
-                event = ORIENTATION_RAW_DATA_EVENT;
-       }
-       else if (strcmp(argv[1], "tilt") == 0) {
-                sensor_type = TILT_SENSOR;
-                event = TILT_RAW_DATA_EVENT;
-       }
-       else if (strcmp(argv[1], "gravity") == 0) {
-                sensor_type = GRAVITY_SENSOR;
-                event = GRAVITY_RAW_DATA_EVENT;
-       }
-       else if (strcmp(argv[1], "linear_accel") == 0) {
-                sensor_type = LINEAR_ACCEL_SENSOR;
-                event = LINEAR_ACCEL_RAW_DATA_EVENT;
-       }
-       else if (strcmp(argv[1], "rotation_vector") == 0) {
-                sensor_type = ROTATION_VECTOR_SENSOR;
-                event = ROTATION_VECTOR_RAW_DATA_EVENT;
-       }
-       else if (strcmp(argv[1], "geomagnetic_rv") == 0) {
-                sensor_type = GEOMAGNETIC_RV_SENSOR;
-                event = GEOMAGNETIC_RV_RAW_DATA_EVENT;
-       }
-       else if (strcmp(argv[1], "gaming_rv") == 0) {
-                sensor_type = GYROSCOPE_RV_SENSOR;
-                event = GAMING_RV_RAW_DATA_EVENT;
-       }
-       else if (strcmp(argv[1], "light") == 0) {
-                sensor_type = LIGHT_SENSOR;
-                event = LIGHT_LUX_DATA_EVENT;
-       }
-       else if (strcmp(argv[1], "proximity") == 0) {
-                sensor_type = PROXIMITY_SENSOR;
-                event = PROXIMITY_CHANGE_STATE_EVENT;
-       }
-       else if (strcmp(argv[1], "ultraviolet") == 0) {
-                sensor_type = ULTRAVIOLET_SENSOR;
-                event = ULTRAVIOLET_RAW_DATA_EVENT;
-       }
-       else if (strcmp(argv[1], "gyroscope_uncal") == 0) {
-                sensor_type = GYROSCOPE_UNCAL_SENSOR;
-                event = GYROSCOPE_UNCAL_RAW_DATA_EVENT;
-       }
-       else if (strcmp(argv[1], "bio_led_red") == 0) {
-                sensor_type = BIO_LED_RED_SENSOR;
-                event = BIO_LED_RED_RAW_DATA_EVENT;
-       }
-       else if (strcmp(argv[1], "face_down") == 0) {
-                sensor_type = GESTURE_FACE_DOWN_SENSOR;
-                event = FACE_DOWN_RAW_DATA_EVENT;
-       }
-       else {
-                usage();
-                return -1;
-       }
-
-       interval = DEFAULT_EVENT_INTERVAL;
-
-       is_polling = FALSE;
-
-       if(argc >= 3 && strcmp(argv[2], "-p") == 0) {
-               is_polling = TRUE;
-       }
-
-       if (is_polling) {
-               if (argc == 4) {
-                       int temp_event = get_event(sensor_type, argv[3]);
-                       if (temp_event == -1) {
-                               interval = atoi(argv[3]);
-                               if (interval == 0){
-                                       usage();
-                                       return -1;
-                               }
-                       }
-                       else {
-                               event = temp_event;
-                       }
-               }
-               else if (argc == 5) {
-                       event = get_event(sensor_type, argv[3]);
-                       interval = strtol(argv[4], &end1, 10);
-
-                       if (*end1) {
-                               printf("Conversion error, non-convertible part: %s\n", end1);
-                               return -1;
-                       }
-               }
-               return polling_sensor(sensor_type, event);
-       }
-       else {
-               if (argc == 3) {
-                       int temp_event = get_event(sensor_type, argv[2]);
-
-                       if (temp_event == -1) {
-                               interval = atoi(argv[2]);
-                               if (interval == 0){
-                                       usage();
-                                       return -1;
-                               }
-                       }
-                       else {
-                               event = temp_event;
-                       }
-               }
-               else if (argc == 4) {
-                       event = get_event(sensor_type, argv[2]);
-                       interval = strtol(argv[3], &end1, 10);
-
-                       if (*end1) {
-                               printf("Conversion error, non-convertible part: %s\n", end1);
-                               return -1;
-                       }
-               }
-               struct pthread_arguments arg;
-               arg.sensor_type = sensor_type;
-               arg.event = event;
-               arg.interval = interval;
-
-               void *result = check_sensor((void*)&arg);
-
-               if (!result)
-                       return -1;
-
-               return 0;
-       }
-}