blob: de54d98d86db7fb886e41a1b0f18b6f48b1a5bb1 [file] [log] [blame]
Keun Soo Yimbf804532016-05-07 22:40:38 -07001/*
2 * Copyright 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Keun Soo Yim04431a92016-05-24 16:26:42 -070017#include <unistd.h>
18
Keun Soo Yim072337b2016-05-13 15:58:26 -070019#include <iostream>
20
Keun Soo Yim6d8a16b2016-06-30 19:29:02 -070021#include "TcpServerForRunner.h"
Keun Soo Yimbf804532016-05-07 22:40:38 -070022
Keun Soo Yima066dd52016-07-01 15:18:28 -070023#define DEFAULT_HAL_DRIVER_FILE_PATH32 "./fuzzer32"
24#define DEFAULT_HAL_DRIVER_FILE_PATH64 "./fuzzer64"
25#define DEFAULT_SHELL_DRIVER_FILE_PATH32 "./vts_shell_driver32"
26#define DEFAULT_SHELL_DRIVER_FILE_PATH64 "./vts_shell_driver64"
Keun Soo Yimbf804532016-05-07 22:40:38 -070027
Keun Soo Yim072337b2016-05-13 15:58:26 -070028
29int main(int argc, char* argv[]) {
Keun Soo Yim072337b2016-05-13 15:58:26 -070030 char* spec_dir_path = NULL;
Keun Soo Yima066dd52016-07-01 15:18:28 -070031 char* hal_path32;
32 char* hal_path64;
33 char* shell_path32;
34 char* shell_path64;
Keun Soo Yim072337b2016-05-13 15:58:26 -070035
36 if (argc == 1) {
Keun Soo Yima066dd52016-07-01 15:18:28 -070037 hal_path32 = DEFAULT_HAL_DRIVER_FILE_PATH32;
38 hal_path64 = DEFAULT_HAL_DRIVER_FILE_PATH64;
39 shell_path32 = DEFAULT_SHELL_DRIVER_FILE_PATH32;
40 shell_path64 = DEFAULT_SHELL_DRIVER_FILE_PATH64;
Keun Soo Yim072337b2016-05-13 15:58:26 -070041 } else if (argc == 2) {
Keun Soo Yima066dd52016-07-01 15:18:28 -070042 hal_path32 = DEFAULT_HAL_DRIVER_FILE_PATH32;
43 hal_path64 = DEFAULT_HAL_DRIVER_FILE_PATH64;
Keun Soo Yim8e07a092016-05-04 16:30:35 -070044 spec_dir_path = argv[1];
Keun Soo Yima066dd52016-07-01 15:18:28 -070045 shell_path32 = DEFAULT_SHELL_DRIVER_FILE_PATH32;
46 shell_path64 = DEFAULT_SHELL_DRIVER_FILE_PATH64;
Keun Soo Yim072337b2016-05-13 15:58:26 -070047 } else if (argc == 3) {
Keun Soo Yima066dd52016-07-01 15:18:28 -070048 hal_path32 = argv[1];
49 hal_path64 = argv[2];
Keun Soo Yim8e07a092016-05-04 16:30:35 -070050 } else if (argc == 4) {
Keun Soo Yima066dd52016-07-01 15:18:28 -070051 hal_path32 = argv[1];
52 hal_path64 = argv[2];
Keun Soo Yim8e07a092016-05-04 16:30:35 -070053 spec_dir_path = argv[3];
Keun Soo Yima066dd52016-07-01 15:18:28 -070054 } else if (argc == 6) {
55 hal_path32 = argv[1];
56 hal_path64 = argv[2];
57 spec_dir_path = argv[3];
58 shell_path32 = argv[4];
59 shell_path64 = argv[5];
Keun Soo Yim072337b2016-05-13 15:58:26 -070060 } else {
Keun Soo Yim8e07a092016-05-04 16:30:35 -070061 std::cerr << "usage: vts_hal_agent "
Keun Soo Yima066dd52016-07-01 15:18:28 -070062 << "[[<hal 32-bit binary path> [<hal 64-bit binary path>] "
63 << "[<spec file base dir path>]]"
64 << "[[<shell 32-bit binary path> [<shell 64-bit binary path>] "
65 << std::endl;
Keun Soo Yim8e07a092016-05-04 16:30:35 -070066 return -1;
Keun Soo Yim072337b2016-05-13 15:58:26 -070067 }
Keun Soo Yim04431a92016-05-24 16:26:42 -070068
69 char* dir_path;
70 dir_path = (char*) malloc(strlen(argv[0]) + 1);
71 strcpy(dir_path, argv[0]);
72 for (int index = strlen(argv[0]) - 2; index >= 0; index--) {
73 if (dir_path[index] == '/') {
74 dir_path[index] = '\0';
75 break;
76 }
77 }
78 printf("chdir %s\n", dir_path);
79 chdir(dir_path);
80
Keun Soo Yim6d8a16b2016-06-30 19:29:02 -070081 android::vts::StartTcpServerForRunner(
Keun Soo Yima066dd52016-07-01 15:18:28 -070082 (const char*) spec_dir_path,
83 (const char*) hal_path32, (const char*) hal_path64,
84 (const char*) shell_path32, (const char*) shell_path64);
Keun Soo Yimbf804532016-05-07 22:40:38 -070085 return 0;
86}