X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=docs%2FAPI%2Fxranlib__unit__test__main_8cc_source.html;fp=docs%2FAPI%2Fxranlib__unit__test__main_8cc_source.html;h=0000000000000000000000000000000000000000;hb=bdbd414e8038630c154ee3c6b8bc9b3aeb954be6;hp=676f2373cad85b69c56fcdaa432fe45435b0997b;hpb=e9403c457453dba780e64af7de9462fad7217aa3;p=o-du%2Fphy.git diff --git a/docs/API/xranlib__unit__test__main_8cc_source.html b/docs/API/xranlib__unit__test__main_8cc_source.html deleted file mode 100644 index 676f237..0000000 --- a/docs/API/xranlib__unit__test__main_8cc_source.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - -o-du/phy: xranlib_unit_test_main.cc Source File - - - - - - - - - -
-
- - - - - - -
-
o-du/phy -
-
Intel O-RAN/X-RAN Generated Doxygen Documentation
-
-
- - - - - - - - -
-
- - -
- -
- - -
-
-
-
xranlib_unit_test_main.cc
-
-
-Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * Copyright (c) 2019 Intel.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *******************************************************************************/
18 
19 #include <rte_config.h>
20 #include <rte_eal.h>
21 #include <rte_debug.h>
22 
23 #include "common.hpp"
24 #include "xran_lib_wrap.hpp"
25 
26 static int parse_input_parameter(std::string executable, std::string option)
27 {
28  std::size_t delim_pos = option.find("=");
29  std::string param = option.substr(delim_pos + 1);
30 
31  try
32  {
33  return std::stoi(param);
34  }
35  catch(std::logic_error &e)
36  {
37  std::cout << executable << ": invalid argument '"<< param << "' for '" << option << "'" << std::endl;
38  std::cout << "Try '" << executable << " --usage' for more information." << std::endl;
39  exit(-1);
40  }
41 }
42 
43 //xranLibWraper xranlib;
45 
46 int main(int argc, char** argv) {
47  int all_test_ret = 0;
48 
49  /* Enable xml output by default */
50  ::testing::GTEST_FLAG(output) = "xml:test_results.xml";
51 
52  ::testing::InitGoogleTest(&argc, argv);
53 
54  const std::string executable = argv[0];
55 
56  for(int index = 1; index < argc; index++) {
57 
58  const std::string option = argv[index];
59 
60  if (option.find("--nb_repetitions=") != std::string::npos)
61  {
62  BenchmarkParameters::repetition = parse_input_parameter(executable, option);
63  }
64  else if (option.find("--nb_loops=") != std::string::npos)
65  {
66  BenchmarkParameters::loop = parse_input_parameter(executable, option);
67  }
68  else if (option.find("--cpu_nb=") != std::string::npos)
69  {
70  BenchmarkParameters::cpu_id = (unsigned) parse_input_parameter(executable, option);
71 
73  std::cout << std::endl << "Warning: Core #0 is running the VM's OS. "
74  << "Measurements won't be accurate. It shouldn't be used!"
75  << std::endl << std::endl;
76  }
77  /* --usage used instead of --help to avoid conflict with gtest --help */
78  else if (!option.compare("--usage"))
79  {
80  std::cout << "Usage: " << executable << " [GTEST_OPTION]... [OPTION]..." << std::endl;
81  std::cout << "Runs unittests with given gtest options." << std::endl;
82  std::cout << std::endl;
83  std::cout << "Available options: " << std::endl;
84  std::cout << "--nb_repetitions=NUMBER Sets how many times results are measured" << std::endl;
85  std::cout << "--nb_loops=NUMBER Sets how many times function is called per repetition"
86  << std::endl;
87  std::cout << "--cpu_nb=NUMBER Sets core number to run tests on" << std::endl;
88  std::cout << "--usage Prints this message" << std::endl;
89 
90  return 0;
91  }
92  else
93  {
94  std::cout << executable << ": inavlid option " << option << std::endl;
95  std::cout << "Try '" << executable << " --usage' for more information." << std::endl;
96 
97  return -1;
98  }
99  }
100 
101  xranlib = new xranLibWraper;
102 
103  if(xranlib->SetUp() < 0) {
104  return (-1);
105  }
106 
107  all_test_ret = RUN_ALL_TESTS();
108 
109  xranlib->TearDown();
110 
111  if(xranlib != nullptr) {
112  delete xranlib;
113  xranlib == nullptr;
114  }
115 
116  return all_test_ret;
117 }
118 
119 
120 
xranLibWraper * xranlib
- - -
static unsigned cpu_id
Definition: common.hpp:68
-
int main(int argc, char **argv)
- - -
static long repetition
Definition: common.hpp:66
- -
static long loop
Definition: common.hpp:67
-
- - - -