-/******************************************************************************\r
-*\r
-* Copyright (c) 2019 Intel.\r
-*\r
-* Licensed under the Apache License, Version 2.0 (the "License");\r
-* you may not use this file except in compliance with the License.\r
-* You may obtain a copy of the License at\r
-*\r
-* http://www.apache.org/licenses/LICENSE-2.0\r
-*\r
-* Unless required by applicable law or agreed to in writing, software\r
-* distributed under the License is distributed on an "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-* See the License for the specific language governing permissions and\r
-* limitations under the License.\r
-*\r
-*******************************************************************************/\r
-\r
-#include <rte_config.h>\r
-#include <rte_eal.h>\r
-#include <rte_debug.h>\r
-\r
-#include "common.hpp"\r
-#include "xran_lib_wrap.hpp"\r
-\r
-static int parse_input_parameter(std::string executable, std::string option)\r
-{\r
- std::size_t delim_pos = option.find("=");\r
- std::string param = option.substr(delim_pos + 1);\r
-\r
- try\r
- {\r
- return std::stoi(param);\r
- }\r
- catch(std::logic_error &e)\r
- {\r
- std::cout << executable << ": invalid argument '"<< param << "' for '" << option << "'" << std::endl;\r
- std::cout << "Try '" << executable << " --usage' for more information." << std::endl;\r
- exit(-1);\r
- }\r
-}\r
-\r
-//xranLibWraper xranlib;\r
-xranLibWraper *xranlib;\r
-\r
-int main(int argc, char** argv) {\r
- int all_test_ret = 0;\r
-\r
- /* Enable xml output by default */\r
- ::testing::GTEST_FLAG(output) = "xml:test_results.xml";\r
-\r
- ::testing::InitGoogleTest(&argc, argv);\r
-\r
- const std::string executable = argv[0];\r
-\r
- for(int index = 1; index < argc; index++) {\r
-\r
- const std::string option = argv[index];\r
-\r
- if (option.find("--nb_repetitions=") != std::string::npos)\r
- {\r
- BenchmarkParameters::repetition = parse_input_parameter(executable, option);\r
- }\r
- else if (option.find("--nb_loops=") != std::string::npos)\r
- {\r
- BenchmarkParameters::loop = parse_input_parameter(executable, option);\r
- }\r
- else if (option.find("--cpu_nb=") != std::string::npos)\r
- {\r
- BenchmarkParameters::cpu_id = (unsigned) parse_input_parameter(executable, option);\r
-\r
- if (BenchmarkParameters::cpu_id == 0)\r
- std::cout << std::endl << "Warning: Core #0 is running the VM's OS. "\r
- << "Measurements won't be accurate. It shouldn't be used!"\r
- << std::endl << std::endl;\r
- }\r
- /* --usage used instead of --help to avoid conflict with gtest --help */\r
- else if (!option.compare("--usage"))\r
- {\r
- std::cout << "Usage: " << executable << " [GTEST_OPTION]... [OPTION]..." << std::endl;\r
- std::cout << "Runs unittests with given gtest options." << std::endl;\r
- std::cout << std::endl;\r
- std::cout << "Available options: " << std::endl;\r
- std::cout << "--nb_repetitions=NUMBER Sets how many times results are measured" << std::endl;\r
- std::cout << "--nb_loops=NUMBER Sets how many times function is called per repetition"\r
- << std::endl;\r
- std::cout << "--cpu_nb=NUMBER Sets core number to run tests on" << std::endl;\r
- std::cout << "--usage Prints this message" << std::endl;\r
-\r
- return 0;\r
- }\r
- else\r
- {\r
- std::cout << executable << ": inavlid option " << option << std::endl;\r
- std::cout << "Try '" << executable << " --usage' for more information." << std::endl;\r
-\r
- return -1;\r
- }\r
- }\r
-\r
- xranlib = new xranLibWraper;\r
-\r
- if(xranlib->SetUp() < 0) {\r
- return (-1);\r
- }\r
-\r
- all_test_ret = RUN_ALL_TESTS();\r
-\r
- xranlib->TearDown();\r
-\r
- if(xranlib != nullptr) {\r
- delete xranlib;\r
- xranlib == nullptr;\r
- }\r
-\r
- return all_test_ret;\r
-}\r
-\r
-\r
-\r
+/******************************************************************************
+*
+* Copyright (c) 2019 Intel.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*******************************************************************************/
+
+#include <rte_config.h>
+#include <rte_eal.h>
+#include <rte_debug.h>
+
+#include "common.hpp"
+#include "xran_lib_wrap.hpp"
+
+static int parse_input_parameter(std::string executable, std::string option)
+{
+ std::size_t delim_pos = option.find("=");
+ std::string param = option.substr(delim_pos + 1);
+
+ try
+ {
+ return std::stoi(param);
+ }
+ catch(std::logic_error &e)
+ {
+ std::cout << executable << ": invalid argument '"<< param << "' for '" << option << "'" << std::endl;
+ std::cout << "Try '" << executable << " --usage' for more information." << std::endl;
+ exit(-1);
+ }
+}
+
+//xranLibWraper xranlib;
+xranLibWraper *xranlib;
+
+int main(int argc, char** argv) {
+ int all_test_ret = 0;
+
+ /* Enable xml output by default */
+ ::testing::GTEST_FLAG(output) = "xml:test_results.xml";
+
+ ::testing::InitGoogleTest(&argc, argv);
+
+ const std::string executable = argv[0];
+
+ for(int index = 1; index < argc; index++) {
+
+ const std::string option = argv[index];
+
+ if (option.find("--nb_repetitions=") != std::string::npos)
+ {
+ BenchmarkParameters::repetition = parse_input_parameter(executable, option);
+ }
+ else if (option.find("--nb_loops=") != std::string::npos)
+ {
+ BenchmarkParameters::loop = parse_input_parameter(executable, option);
+ }
+ else if (option.find("--cpu_nb=") != std::string::npos)
+ {
+ BenchmarkParameters::cpu_id = (unsigned) parse_input_parameter(executable, option);
+
+ if (BenchmarkParameters::cpu_id == 0)
+ std::cout << std::endl << "Warning: Core #0 is running the VM's OS. "
+ << "Measurements won't be accurate. It shouldn't be used!"
+ << std::endl << std::endl;
+ }
+ /* --usage used instead of --help to avoid conflict with gtest --help */
+ else if (!option.compare("--usage"))
+ {
+ std::cout << "Usage: " << executable << " [GTEST_OPTION]... [OPTION]..." << std::endl;
+ std::cout << "Runs unittests with given gtest options." << std::endl;
+ std::cout << std::endl;
+ std::cout << "Available options: " << std::endl;
+ std::cout << "--nb_repetitions=NUMBER Sets how many times results are measured" << std::endl;
+ std::cout << "--nb_loops=NUMBER Sets how many times function is called per repetition"
+ << std::endl;
+ std::cout << "--cpu_nb=NUMBER Sets core number to run tests on" << std::endl;
+ std::cout << "--usage Prints this message" << std::endl;
+
+ return 0;
+ }
+ else
+ {
+ std::cout << executable << ": inavlid option " << option << std::endl;
+ std::cout << "Try '" << executable << " --usage' for more information." << std::endl;
+
+ return -1;
+ }
+ }
+
+ xranlib = new xranLibWraper;
+
+ if(xranlib->SetUp() < 0) {
+ return (-1);
+ }
+
+ all_test_ret = RUN_ALL_TESTS();
+
+ xranlib->TearDown();
+
+ if(xranlib != nullptr) {
+ delete xranlib;
+ xranlib == nullptr;
+ }
+
+ return all_test_ret;
+}
+
+
+