blob: 891c7693739b76912793566b8f4af8567be86fee [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 Yim8e07a092016-05-04 16:30:35 -070023#define DEFAULT_FUZZER_FILE_PATH32 "./fuzzer32"
24#define DEFAULT_FUZZER_FILE_PATH64 "./fuzzer64"
Keun Soo Yimbf804532016-05-07 22:40:38 -070025
Keun Soo Yim072337b2016-05-13 15:58:26 -070026
27int main(int argc, char* argv[]) {
Keun Soo Yim8e07a092016-05-04 16:30:35 -070028 char* fuzzer_path32;
29 char* fuzzer_path64;
Keun Soo Yim072337b2016-05-13 15:58:26 -070030 char* spec_dir_path = NULL;
31
32 if (argc == 1) {
Keun Soo Yim8e07a092016-05-04 16:30:35 -070033 fuzzer_path32 = DEFAULT_FUZZER_FILE_PATH32;
34 fuzzer_path64 = DEFAULT_FUZZER_FILE_PATH64;
Keun Soo Yim072337b2016-05-13 15:58:26 -070035 } else if (argc == 2) {
Keun Soo Yim8e07a092016-05-04 16:30:35 -070036 fuzzer_path32 = DEFAULT_FUZZER_FILE_PATH32;
37 fuzzer_path64 = DEFAULT_FUZZER_FILE_PATH64;
38 spec_dir_path = argv[1];
Keun Soo Yim072337b2016-05-13 15:58:26 -070039 } else if (argc == 3) {
Keun Soo Yim8e07a092016-05-04 16:30:35 -070040 fuzzer_path32 = argv[1];
41 fuzzer_path64 = argv[2];
42 } else if (argc == 4) {
43 fuzzer_path32 = argv[1];
44 fuzzer_path64 = argv[2];
45 spec_dir_path = argv[3];
Keun Soo Yim072337b2016-05-13 15:58:26 -070046 } else {
Keun Soo Yim8e07a092016-05-04 16:30:35 -070047 std::cerr << "usage: vts_hal_agent "
48 << "[[<fuzzer 32-bit binary path> [<fuzzer 64-bit binary path>] "
49 << "[<spec file base dir path>]]" << std::endl;
50 return -1;
Keun Soo Yim072337b2016-05-13 15:58:26 -070051 }
Keun Soo Yim04431a92016-05-24 16:26:42 -070052
53 char* dir_path;
54 dir_path = (char*) malloc(strlen(argv[0]) + 1);
55 strcpy(dir_path, argv[0]);
56 for (int index = strlen(argv[0]) - 2; index >= 0; index--) {
57 if (dir_path[index] == '/') {
58 dir_path[index] = '\0';
59 break;
60 }
61 }
62 printf("chdir %s\n", dir_path);
63 chdir(dir_path);
64
Keun Soo Yim6d8a16b2016-06-30 19:29:02 -070065 android::vts::StartTcpServerForRunner(
Keun Soo Yim8e07a092016-05-04 16:30:35 -070066 (const char*) fuzzer_path32, (const char*) fuzzer_path64,
67 (const char*) spec_dir_path);
Keun Soo Yimbf804532016-05-07 22:40:38 -070068 return 0;
69}