Keun Soo Yim | bf80453 | 2016-05-07 22:40:38 -0700 | [diff] [blame] | 1 | /* |
| 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 Yim | 04431a9 | 2016-05-24 16:26:42 -0700 | [diff] [blame] | 17 | #include <unistd.h> |
| 18 | |
Keun Soo Yim | 072337b | 2016-05-13 15:58:26 -0700 | [diff] [blame] | 19 | #include <iostream> |
| 20 | |
Keun Soo Yim | 154b14f | 2016-05-09 19:41:58 -0700 | [diff] [blame] | 21 | #include "TcpServer.h" |
Keun Soo Yim | bf80453 | 2016-05-07 22:40:38 -0700 | [diff] [blame] | 22 | |
Keun Soo Yim | 072337b | 2016-05-13 15:58:26 -0700 | [diff] [blame] | 23 | #define DEFAULT_FUZZER_FILE_PATH "./fuzzer" |
Keun Soo Yim | bf80453 | 2016-05-07 22:40:38 -0700 | [diff] [blame] | 24 | |
Keun Soo Yim | 072337b | 2016-05-13 15:58:26 -0700 | [diff] [blame] | 25 | |
| 26 | int main(int argc, char* argv[]) { |
| 27 | char* fuzzer_path; |
| 28 | char* spec_dir_path = NULL; |
| 29 | |
| 30 | if (argc == 1) { |
| 31 | fuzzer_path = DEFAULT_FUZZER_FILE_PATH; |
| 32 | } else if (argc == 2) { |
| 33 | fuzzer_path = argv[1]; |
| 34 | } else if (argc == 3) { |
| 35 | fuzzer_path = argv[1]; |
| 36 | spec_dir_path = argv[2]; |
| 37 | } else { |
| 38 | std::cerr << "usage: vts_hal_agent " |
| 39 | << "[<fuzzer binary path> [<spec file base dir path>]]" << std::endl; |
| 40 | return -1; |
| 41 | } |
Keun Soo Yim | 04431a9 | 2016-05-24 16:26:42 -0700 | [diff] [blame] | 42 | |
| 43 | char* dir_path; |
| 44 | dir_path = (char*) malloc(strlen(argv[0]) + 1); |
| 45 | strcpy(dir_path, argv[0]); |
| 46 | for (int index = strlen(argv[0]) - 2; index >= 0; index--) { |
| 47 | if (dir_path[index] == '/') { |
| 48 | dir_path[index] = '\0'; |
| 49 | break; |
| 50 | } |
| 51 | } |
| 52 | printf("chdir %s\n", dir_path); |
| 53 | chdir(dir_path); |
| 54 | |
Keun Soo Yim | 072337b | 2016-05-13 15:58:26 -0700 | [diff] [blame] | 55 | android::vts::StartTcpServer( |
| 56 | (const char*) fuzzer_path, (const char*) spec_dir_path); |
Keun Soo Yim | 04431a9 | 2016-05-24 16:26:42 -0700 | [diff] [blame] | 57 | |
Keun Soo Yim | bf80453 | 2016-05-07 22:40:38 -0700 | [diff] [blame] | 58 | return 0; |
| 59 | } |