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.
23 #include <sensor_common.h>
24 #include <sensor_types.h>
26 #include "check-sensor.h"
30 printf("Usage : ./performance-test <TIMEOUT> <interval>(optional)\n\n");
33 printf("time for which the parallel sensor test cases should run\n");
35 printf("interval:\n");
36 printf("The time interval should be entered based on the sampling frequency supported by accelerometer driver on the device in ms.\n");
37 printf("If no value for sensor is entered default value by the driver will be used.\n");
40 int main(int argc, char** argv)
45 int interval = DEFAULT_EVENT_INTERVAL;
46 int TIMEOUT = 10; //in seconds for which all the sensor tests should run
53 TIMEOUT = atoi(argv[1]);
60 TIMEOUT = atoi(argv[1]);
61 interval = atoi(argv[2]);
62 if (TIMEOUT == 0 || interval == 0) {
68 //make an array of size MAX and fill it with all the sensors needed to run
71 sensor_type_t sensor[MAX];
73 //Update the value of MAX and add more sensors here to test more sensors in parallel
74 sensor[0] = ACCELEROMETER_SENSOR;
75 sensor[1] = GYROSCOPE_SENSOR;
76 sensor[2] = GEOMAGNETIC_SENSOR;
77 sensor[3] = PRESSURE_SENSOR;
78 sensor[4] = PROXIMITY_SENSOR;
79 sensor[MAX-1] = LIGHT_SENSOR;
84 if (b == -1) perror("Fork failed\n");
94 // call the sensord test tc-common for a sensor.
95 int event = (sensor[i] << 16) | 0x0001;
96 struct pthread_arguments arg;
97 arg.sensor_type = sensor[i];
99 arg.interval = interval;
101 check_sensor((void*)&arg);
104 // Main Parent Child. Waits for TIMEOUT and then kills all child processes.
108 for (j = 0; j < MAX; j++) {
110 snprintf(command, sizeof(command), "kill %d", pids[j]);
111 if (system(command) == -1)