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>
11
#include <
exceptions/exceptions.h
>
12
13
#include "
test_control.h
"
14
#include "
command_options.h
"
15
16
using namespace
isc::perfdhcp
;
17
18
int
19
main
(
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
}
isc::perfdhcp::CommandOptions::parse
bool parse(int argc, char **const argv, bool print_cmd_line=false)
Parse command line.
Definition:
command_options.cc:161
isc::perfdhcp::TestControl::instance
static TestControl & instance()
TestControl is a singleton class.
Definition:
test_control.cc:136
isc::perfdhcp::TestControl::run
int run()
brief\ Run performance test.
Definition:
test_control.cc:1475
exceptions.h
isc::perfdhcp::CommandOptions::instance
static CommandOptions & instance()
CommandOptions is a singleton class.
Definition:
command_options.cc:99
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition:
exceptions/exceptions.cc:32
command_options.h
isc::perfdhcp::CommandOptions::usage
void usage() const
Print usage.
Definition:
command_options.cc:1022
main
int main(int argc, char *argv[])
Definition:
perfdhcp/main.cc:19
isc::Exception
This is a base class for exceptions thrown from the DNS library module.
Definition:
exceptions/exceptions.h:23
isc::perfdhcp::CommandOptions
Command Options.
Definition:
command_options.h:25
isc::perfdhcp
Definition:
command_options.cc:36
isc::perfdhcp::TestControl
Test Control class.
Definition:
test_control.h:121
isc::perfdhcp::CommandOptions::getDiags
std::string getDiags() const
Returns diagnostic selectors.
Definition:
command_options.h:334
test_control.h
src
bin
perfdhcp
main.cc
Generated on Wed Jan 23 2019 23:03:25 for Kea by
1.8.15