1 /*******************************************************************************
5 *******************************************************************************/
6 #include <rte_config.h>
11 #include "xran_lib_wrap.hpp"
13 static int parse_input_parameter(std::string executable, std::string option)
15 std::size_t delim_pos = option.find("=");
16 std::string param = option.substr(delim_pos + 1);
20 return std::stoi(param);
22 catch(std::logic_error &e)
24 std::cout << executable << ": invalid argument '"<< param << "' for '" << option << "'" << std::endl;
25 std::cout << "Try '" << executable << " --usage' for more information." << std::endl;
30 //xranLibWraper xranlib;
31 xranLibWraper *xranlib;
33 int main(int argc, char** argv) {
36 /* Enable xml output by default */
37 ::testing::GTEST_FLAG(output) = "xml:test_results.xml";
39 ::testing::InitGoogleTest(&argc, argv);
41 const std::string executable = argv[0];
43 for(int index = 1; index < argc; index++) {
45 const std::string option = argv[index];
47 if (option.find("--nb_repetitions=") != std::string::npos)
49 BenchmarkParameters::repetition = parse_input_parameter(executable, option);
51 else if (option.find("--nb_loops=") != std::string::npos)
53 BenchmarkParameters::loop = parse_input_parameter(executable, option);
55 else if (option.find("--cpu_nb=") != std::string::npos)
57 BenchmarkParameters::cpu_id = (unsigned) parse_input_parameter(executable, option);
59 if (BenchmarkParameters::cpu_id == 0)
60 std::cout << std::endl << "Warning: Core #0 is running the VM's OS. "
61 << "Measurements won't be accurate. It shouldn't be used!"
62 << std::endl << std::endl;
64 /* --usage used instead of --help to avoid conflict with gtest --help */
65 else if (!option.compare("--usage"))
67 std::cout << "Usage: " << executable << " [GTEST_OPTION]... [OPTION]..." << std::endl;
68 std::cout << "Runs unittests with given gtest options." << std::endl;
69 std::cout << std::endl;
70 std::cout << "Available options: " << std::endl;
71 std::cout << "--nb_repetitions=NUMBER Sets how many times results are measured" << std::endl;
72 std::cout << "--nb_loops=NUMBER Sets how many times function is called per repetition"
74 std::cout << "--cpu_nb=NUMBER Sets core number to run tests on" << std::endl;
75 std::cout << "--usage Prints this message" << std::endl;
81 std::cout << executable << ": inavlid option " << option << std::endl;
82 std::cout << "Try '" << executable << " --usage' for more information." << std::endl;
88 xranlib = new xranLibWraper;
90 if(xranlib->SetUp() < 0) {
94 all_test_ret = RUN_ALL_TESTS();
98 if(xranlib != nullptr) {