Kea 1.5.0
perfdhcp/main.cc
Go to the documentation of this file.
1// Copyright (C) 2012-2016 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <iostream>
8#include <stdint.h>
9
10#include <config.h>
12
13#include "test_control.h"
14#include "command_options.h"
15
16using namespace isc::perfdhcp;
17
18int
19main(int argc, char* argv[]) {
20 CommandOptions& command_options = CommandOptions::instance();
21 std::string diags(command_options.getDiags());
22 int ret_code = 0;
23 try {
24 // If parser returns true it means that user specified
25 // 'h' or 'v' command line option. Program shows the
26 // help or version message and exits here.
27 // The third argument indicates that the command line
28 // should be printed when it gets parsed. This is useful
29 // in particular when the command line needs to be
30 // extracted from the log file.
31 if (command_options.parse(argc, argv, true)) {
32 return (ret_code);
33 }
34 } catch(isc::Exception& e) {
35 ret_code = 1;
36 std::cerr << "Error parsing command line options: "
37 << e.what() << std::endl;
38 command_options.usage();
39 if (diags.find('e') != std::string::npos) {
40 std::cerr << "Fatal error" << std::endl;
41 }
42 return (ret_code);
43 }
44 try{
45 TestControl& test_control = TestControl::instance();
46 ret_code = test_control.run();
47 } catch (std::exception& e) {
48 ret_code = 1;
49 std::cerr << "Error running perfdhcp: " << e.what() << std::endl;
50 if (diags.find('e') != std::string::npos) {
51 std::cerr << "Fatal error" << std::endl;
52 }
53 }
54 return (ret_code);
55}
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
static CommandOptions & instance()
CommandOptions is a singleton class.
void usage() const
Print usage.
bool parse(int argc, char **const argv, bool print_cmd_line=false)
Parse command line.
std::string getDiags() const
Returns diagnostic selectors.
Test Control class.
Definition: test_control.h:121
static TestControl & instance()
TestControl is a singleton class.
int run()
brief\ Run performance test.
int main(int argc, char *argv[])