Kea 2.6.0
perfdhcp/main.cc
Go to the documentation of this file.
1// Copyright (C) 2012-2021 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 <config.h>
8
10#include <perfdhcp/basic_scen.h>
12
14
15#include <iostream>
16#include <stdint.h>
17
18using namespace isc::perfdhcp;
19
20int
21main(int argc, char* argv[]) {
22 int ret_code = 0;
23 std::string diags;
24 bool parser_error = true;
25 try {
26 CommandOptions command_options;
27 diags = command_options.getDiags();
28 // If parser returns true it means that user specified
29 // 'h' or 'v' command line option. Program shows the
30 // help or version message and exits here.
31 // The third argument indicates that the command line
32 // should be printed when it gets parsed. This is useful
33 // in particular when the command line needs to be
34 // extracted from the log file.
35 if (command_options.parse(argc, argv, true)) {
36 return (ret_code);
37 }
38 parser_error = false;
39 auto scenario = command_options.getScenario();
40 PerfSocket socket(command_options);
41 if (scenario == Scenario::BASIC) {
42 BasicScen scen(command_options, socket);
43 ret_code = scen.run();
44 } else if (scenario == Scenario::AVALANCHE) {
45 AvalancheScen scen(command_options, socket);
46 ret_code = scen.run();
47 }
48 } catch (const std::exception& e) {
49 ret_code = 1;
50 if (!parser_error) {
51 std::cerr << std::endl << "ERROR: running perfdhcp: "
52 << e.what() << std::endl;
53 } else {
55 std::cerr << std::endl << "ERROR: parsing command line options: "
56 << e.what() << std::endl;
57 }
58 if (diags.find('e') != std::string::npos) {
59 std::cerr << "Fatal error" << std::endl;
60 }
61 } catch (...) {
62 ret_code = 1;
63 if (!parser_error) {
64 std::cerr << std::endl << "ERROR: running perfdhcp"
65 << std::endl;
66 } else {
68 std::cerr << std::endl << "ERROR: parsing command line options"
69 << std::endl;
70 }
71 if (diags.find('e') != std::string::npos) {
72 std::cerr << "Fatal error" << std::endl;
73 }
74 }
75 return (ret_code);
76}
Avalanche Scenario class.
int run() override
brief\ Run performance test.
Basic Scenario class.
Definition: basic_scen.h:23
int run() override
brief\ Run performance test.
Definition: basic_scen.cc:125
Scenario getScenario() const
Returns selected scenario.
static void usage()
Print usage.
bool parse(int argc, char **const argv, bool print_cmd_line=false)
Parse command line.
std::string getDiags() const
Returns diagnostic selectors.
Socket wrapper structure.
Definition: perf_socket.h:64
int main(int argc, char *argv[])