blob: bd0f57edf535b69c9beb54746ea73d0bccab8f0a [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 Yim154b14f2016-05-09 19:41:58 -070021#include "TcpServer.h"
Keun Soo Yimbf804532016-05-07 22:40:38 -070022
Keun Soo Yim072337b2016-05-13 15:58:26 -070023#define DEFAULT_FUZZER_FILE_PATH "./fuzzer"
Keun Soo Yimbf804532016-05-07 22:40:38 -070024
Keun Soo Yim072337b2016-05-13 15:58:26 -070025
26int 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 Yim04431a92016-05-24 16:26:42 -070042
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 Yim072337b2016-05-13 15:58:26 -070055 android::vts::StartTcpServer(
56 (const char*) fuzzer_path, (const char*) spec_dir_path);
Keun Soo Yim04431a92016-05-24 16:26:42 -070057
Keun Soo Yimbf804532016-05-07 22:40:38 -070058 return 0;
59}