--- /dev/null
+/******************************************************************************\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