4 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
24 #include <sensor_internal.h>
25 #include <sensorctl_log.h>
27 #include <tester_auto.h>
29 static void test_cb(sensor_t sensor, unsigned int event_type, sensor_data_t *data, void *user_data)
34 static void test_func(const char *name, std::function<bool()> func)
39 if (ret) PRINT(GRN "[PASS] %s", name);
40 else PRINT(RED "[FAIL] %s", name);
44 static bool operate_sensor(sensor_type_t type)
46 sensor_t sensor = sensord_get_sensor(type);
50 static bool start_sensor(sensor_t sensor)
55 static bool read_sensor(sensor_t sensor)
60 static bool is_supported(sensor_type_t type, sensor_t sensor)
65 bool tester_auto::init(void)
70 bool tester_auto::test(sensor_type_t type, int option_count, char *options[])
73 sensor_t *list = sensord_get_sensors(ALL_SENSOR);
74 for (int i = 0; i< ARRAY_SIZE(list); ++i) {
75 sensor_type_t type = sensord_get_type(list[i]);
77 sensor_t sensor = sensord_get_sensor(ACCELEROMETER_SENSOR);
78 test_func("SENSOR_NAME", std::bind(operate_sensor, ACCELEROMETER_SENSOR));
79 test_func("SENSOR_NAME", std::bind(start_sensor, sensor));
80 test_func("SENSOR_NAME", std::bind(read_sensor, sensor));
81 test_func("SENSOR_NAME", std::bind(is_supported, ACCELEROMETER_SENSOR, sensor));