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;
33 ut_version_print(void)
36 char *compilation_date = (char *)__DATE__;
37 char *compilation_time = (char *)__TIME__;
40 //snprintf(sysversion, 99, "Version: %s", VERSIONX);
42 #if defined(__clang__)
43 snprintf(compiler, 99, "family clang: %s", __clang_version__);
44 #elif defined(__ICC) || defined(__INTEL_COMPILER)
45 snprintf(compiler, 99, "family icc: version %d", __INTEL_COMPILER);
46 #elif defined(__INTEL_LLVM_COMPILER)
47 snprintf(compiler, 99, "family icx: version %d", __INTEL_LLVM_COMPILER);
48 #elif defined(__GNUC__) || defined(__GNUG__)
49 snprintf(compiler, 99, "family gcc: version %d.%d.%d", __GNUC__, __GNUC_MINOR__,__GNUC_PATCHLEVEL__);
53 printf("===========================================================================================================\n");
54 printf("UNITTESTS VERSION\n");
55 printf("===========================================================================================================\n");
57 //printf("%s\n", sysversion);
58 printf("build-date: %s\n", compilation_date);
59 printf("build-time: %s\n", compilation_time);
60 printf("build-with: %s\n", compiler);
63 int main(int argc, char** argv) {
66 /* Enable xml output by default */
67 ::testing::GTEST_FLAG(output) = "xml:test_results.xml";
69 ::testing::InitGoogleTest(&argc, argv);
71 const std::string executable = argv[0];
73 for(int index = 1; index < argc; index++) {
75 const std::string option = argv[index];
77 if (option.find("--nb_repetitions=") != std::string::npos)
79 BenchmarkParameters::repetition = parse_input_parameter(executable, option);
81 else if (option.find("--nb_loops=") != std::string::npos)
83 BenchmarkParameters::loop = parse_input_parameter(executable, option);
85 else if (option.find("--cpu_nb=") != std::string::npos)
87 BenchmarkParameters::cpu_id = (unsigned) parse_input_parameter(executable, option);
89 if (BenchmarkParameters::cpu_id == 0)
90 std::cout << std::endl << "Warning: Core #0 is running the VM's OS. "
91 << "Measurements won't be accurate. It shouldn't be used!"
92 << std::endl << std::endl;
94 /* --usage used instead of --help to avoid conflict with gtest --help */
95 else if (!option.compare("--usage"))
97 std::cout << "Usage: " << executable << " [GTEST_OPTION]... [OPTION]..." << std::endl;
98 std::cout << "Runs unittests with given gtest options." << std::endl;
99 std::cout << std::endl;
100 std::cout << "Available options: " << std::endl;
101 std::cout << "--nb_repetitions=NUMBER Sets how many times results are measured" << std::endl;
102 std::cout << "--nb_loops=NUMBER Sets how many times function is called per repetition"
104 std::cout << "--cpu_nb=NUMBER Sets core number to run tests on" << std::endl;
105 std::cout << "--usage Prints this message" << std::endl;
111 std::cout << executable << ": inavlid option " << option << std::endl;
112 std::cout << "Try '" << executable << " --usage' for more information." << std::endl;
118 xranlib = new xranLibWraper;
120 if(xranlib->SetUp() < 0) {
124 all_test_ret = RUN_ALL_TESTS();
128 if(xranlib != nullptr) {