tracitestclient_main.cpp
Go to the documentation of this file.00001
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029
00030 #include <iostream>
00031 #include <string>
00032 #include <cstdlib>
00033 #include "TraCITestClient.h"
00034
00035
00036
00037
00038
00039 using namespace testclient;
00040
00041
00042
00043
00044
00045 int main(int argc, char* argv[]) {
00046 std::string defFile = "";
00047 std::string outFileName = "testclient_out.txt";
00048 int port = -1;
00049 std::string host = "localhost";
00050 TraCITestClient* client;
00051
00052 if ((argc == 1) || (argc % 2 == 0)) {
00053 std::cout << "Usage: TraciTestClient -def <definition_file> -p <remote port>"
00054 << "[-h <remote host>] [-o <outputfile name>]" << std::endl;
00055 return 0;
00056 }
00057
00058 for (int i=1; i < argc; i++) {
00059 std::string arg = argv[i];
00060 if (arg.compare("-def") == 0) {
00061 defFile = argv[i+1];
00062 i++;
00063 } else if (arg.compare("-o") == 0) {
00064 outFileName = argv[i+1];
00065 i++;
00066 } else if (arg.compare("-p") == 0) {
00067 port = atoi(argv[i+1]);
00068 i++;
00069 } else if (arg.compare("-h") == 0) {
00070 host = argv[i+1];
00071 i++;
00072 } else {
00073 std::cout << "unknown parameter: " << argv[i] << std::endl;
00074 return 1;
00075 }
00076 }
00077
00078 if (port == -1) {
00079 std::cout << "Missing port" << std::endl;
00080 return 1;
00081 }
00082 if (defFile.compare("") == 0) {
00083 std::cout << "Missing definition file" << std::endl;
00084 return 1;
00085 }
00086
00087 client = new TraCITestClient(outFileName);
00088 bool success = client->run(defFile, port, host);
00089 delete client;
00090
00091 return !success;
00092 }