1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program Execution Server
3 * ---------------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief ExecServer main().
22 *//*--------------------------------------------------------------------*/
24 #include "xsExecutionServer.hpp"
25 #include "deCommandLine.hpp"
28 #if (DE_OS == DE_OS_WIN32)
29 # include "xsWin32TestProcess.hpp"
31 # include "xsPosixTestProcess.hpp"
39 DE_DECLARE_COMMAND_LINE_OPT(Port, int);
40 DE_DECLARE_COMMAND_LINE_OPT(SingleExec, bool);
42 void registerOptions (de::cmdline::Parser& parser)
44 using de::cmdline::Option;
45 using de::cmdline::NamedValue;
47 parser << Option<Port> ("p", "port", "Port", "50016")
48 << Option<SingleExec>("s", "single", "Kill execserver after first session");
53 int main (int argc, const char* const* argv)
55 de::cmdline::CommandLine cmdLine;
57 #if (DE_OS == DE_OS_WIN32)
58 xs::Win32TestProcess testProcess;
60 xs::PosixTestProcess testProcess;
62 // Set line buffered mode to stdout so executor gets any log messages in a timely manner.
63 setvbuf(stdout, DE_NULL, _IOLBF, 4*1024);
66 // Parse command line.
68 de::cmdline::Parser parser;
69 opt::registerOptions(parser);
71 if (!parser.parse(argc, argv, &cmdLine, std::cerr))
73 parser.help(std::cout);
80 const xs::ExecutionServer::RunMode runMode = cmdLine.getOption<opt::SingleExec>()
81 ? xs::ExecutionServer::RUNMODE_SINGLE_EXEC
82 : xs::ExecutionServer::RUNMODE_FOREVER;
83 const int port = cmdLine.getOption<opt::Port>();
84 xs::ExecutionServer server (&testProcess, DE_SOCKETFAMILY_INET4, port, runMode);
86 std::cout << "Listening on port " << port << ".\n";
89 catch (const std::exception& e)
91 std::cerr << e.what() << "\n";