sensord: change variable name of attribute-related functions
[platform/core/system/sensord.git] / src / test / src / multi-thread-performance-test.c
1 /*
2  * sensord
3  *
4  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
5  *
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  */
19 #include <glib.h>
20 #include <stdlib.h>
21 #include <stdio.h>
22 #include <sensor_internal.h>
23 #include <stdbool.h>
24 #include <sensor_common.h>
25 #include <unistd.h>
26 #include <string.h>
27 #include <pthread.h>
28 #include "check-sensor.h"
29
30 void usage()
31 {
32         printf("Usage : ./multi-sensor <TIMEOUT> <interval>(optional)\n\n");
33         printf("TIMEOUT:\n");
34         printf("time for which the parallel sensor test cases should run\n");
35
36         printf("interval:\n");
37         printf("The time interval should be entered based on the sampling frequency supported by accelerometer driver on the device in ms.\n");
38         printf("If no value for sensor is entered default value by the driver will be used.\n");
39         printf("arg[i].sensor_type: ");
40         printf("[accelerometer] ");
41         printf("[auto_rotation]\n");
42         printf("[gyroscope] ");
43         printf("[pressure] ");
44         printf("[temperature] ");
45         printf("[geomagnetic] ");
46         printf("[orientation] ");
47         printf("[tilt] ");
48         printf("[gravity] ");
49         printf("[linear_accel] ");
50         printf("[rotation_vector] ");
51         printf("[geomagnetic_rv] ");
52         printf("[gaming_rv] ");
53         printf("[ultraviolet] ");
54         printf("[light]\n");
55         printf("[gyro_uncal]");
56         printf("[face_down]");
57
58 }
59
60 int main(int argc, char **argv)
61 {
62
63         int i = 0;
64         int interval = DEFAULT_EVENT_INTERVAL;
65         int TIMEOUT = 10; //in seconds for which all the sensor tests should run
66
67         if(argc < 2) {
68                 usage();
69                 return -1;
70         }
71         else if(argc == 2){
72                 TIMEOUT = atoi(argv[1]);
73                 if (TIMEOUT == 0) {
74                         usage();
75                         return -1;
76                 }
77         }
78         else {
79                 TIMEOUT = atoi(argv[1]);
80                 interval = atoi(argv[2]);
81                 if (TIMEOUT == 0 || interval == 0) {
82                         usage();
83                         return -1;
84                 }
85         }
86
87         int MAX = 6, j = 0, k = 0;
88         struct pthread_arguments arg[MAX];
89         int t = 0;
90
91         arg[0].sensor_type = ACCELEROMETER_SENSOR;
92         arg[0].event = ACCELEROMETER_RAW_DATA_EVENT;
93         arg[1].sensor_type = GYROSCOPE_SENSOR;
94         arg[1].event = GYROSCOPE_RAW_DATA_EVENT;
95         arg[2].sensor_type = GEOMAGNETIC_RV_SENSOR;
96         arg[2].event = GEOMAGNETIC_RV_RAW_DATA_EVENT;
97         arg[3].sensor_type = PRESSURE_SENSOR;
98         arg[3].event = PRESSURE_RAW_DATA_EVENT;
99         arg[4].sensor_type = PROXIMITY_SENSOR;
100         arg[4].event = PROXIMITY_CHANGE_STATE_EVENT;
101         arg[5].sensor_type = LIGHT_SENSOR;
102         arg[5].event = LIGHT_LUX_DATA_EVENT;
103
104         for (t = 0; t < MAX; t++)
105                 arg[t].interval = interval;
106
107         pthread_t thread_id[MAX];
108
109         for (j = 0; j < MAX; j++)
110                 pthread_create(&thread_id[j], NULL, check_sensor, (void*)&arg[j]);
111
112         sleep(TIMEOUT);
113         return 0;
114 }