Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 1 | import argparse |
| 2 | import os |
| 3 | import psutil |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 4 | import time |
| 5 | |
| 6 | |
| 7 | def positive_int_or_default(default): |
| 8 | def positive_integer(v): |
| 9 | if v is None or v == "": |
| 10 | return default |
Andrew Yourtchenko | f56b007 | 2022-03-18 17:05:53 +0000 | [diff] [blame] | 11 | if int(v) <= 0: |
| 12 | raise ValueError("value must be positive") |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 13 | return int(v) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 14 | |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 15 | return positive_integer |
| 16 | |
| 17 | |
Andrew Yourtchenko | f56b007 | 2022-03-18 17:05:53 +0000 | [diff] [blame] | 18 | def positive_float_or_default(default): |
| 19 | def positive_float(v): |
| 20 | if v is None or v == "": |
| 21 | return default |
| 22 | if float(v) <= 0: |
| 23 | raise ValueError("value must be positive") |
| 24 | return float(v) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 25 | |
Andrew Yourtchenko | f56b007 | 2022-03-18 17:05:53 +0000 | [diff] [blame] | 26 | return positive_float |
| 27 | |
| 28 | |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 29 | def positive_int_or_auto(v): |
| 30 | if v is None or v in ("", "auto"): |
| 31 | return "auto" |
| 32 | if int(v) <= 0: |
| 33 | raise ValueError("value must be positive or auto") |
| 34 | return int(v) |
| 35 | |
| 36 | |
| 37 | def int_or_auto(v): |
| 38 | if v is None or v in ("", "auto"): |
| 39 | return "auto" |
| 40 | if int(v) < 0: |
| 41 | raise ValueError("value must be positive or auto") |
| 42 | return int(v) |
| 43 | |
| 44 | |
| 45 | def int_choice_or_default(options, default): |
| 46 | assert default in options |
| 47 | |
| 48 | def choice(v): |
| 49 | if v is None or v == "": |
| 50 | return default |
| 51 | if int(v) in options: |
| 52 | return int(v) |
| 53 | raise ValueError("invalid choice") |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 54 | |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 55 | return choice |
| 56 | |
| 57 | |
| 58 | def worker_config(v): |
| 59 | if v is None or v == "": |
| 60 | return 0 |
| 61 | if v.startswith("workers "): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 62 | return int(v.split(" ")[1]) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 63 | return int(v) |
| 64 | |
| 65 | |
| 66 | def directory(v): |
| 67 | if not os.path.isdir(v): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 68 | raise ValueError(f"provided path '{v}' doesn't exist or is not a directory") |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 69 | return v |
| 70 | |
| 71 | |
| 72 | def directory_verify_or_create(v): |
| 73 | if not os.path.isdir(v): |
| 74 | os.mkdir(v) |
| 75 | return v |
| 76 | |
| 77 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 78 | parser = argparse.ArgumentParser( |
| 79 | description="VPP unit tests", formatter_class=argparse.RawTextHelpFormatter |
| 80 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 81 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 82 | parser.add_argument( |
| 83 | "--failfast", action="store_true", help="stop running tests on first failure" |
| 84 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 85 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 86 | parser.add_argument( |
| 87 | "--test-src-dir", |
| 88 | action="append", |
| 89 | type=directory, |
| 90 | help="directory containing test files " |
| 91 | "(may be specified multiple times) " |
| 92 | "(VPP_WS_DIR/test is added automatically to the set)", |
| 93 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 94 | |
| 95 | default_verbose = 0 |
| 96 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 97 | parser.add_argument( |
| 98 | "--verbose", |
| 99 | action="store", |
| 100 | default=default_verbose, |
| 101 | type=int_choice_or_default((0, 1, 2), default_verbose), |
| 102 | help="verbosity setting - 0 - least verbose, 2 - most verbose (default: 0)", |
| 103 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 104 | |
| 105 | default_test_run_timeout = 600 |
| 106 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 107 | parser.add_argument( |
| 108 | "--timeout", |
| 109 | action="store", |
| 110 | type=positive_int_or_default(default_test_run_timeout), |
| 111 | default=default_test_run_timeout, |
| 112 | metavar="TEST_RUN_TIMEOUT", |
| 113 | help="test run timeout in seconds - per test " |
| 114 | f"(default: {default_test_run_timeout})", |
| 115 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 116 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 117 | parser.add_argument( |
| 118 | "--failed-dir", |
| 119 | action="store", |
| 120 | type=directory, |
Klement Sekera | 152a9b6 | 2022-05-13 18:01:36 +0200 | [diff] [blame] | 121 | help="directory containing failed tests (default: --tmp-dir)", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 122 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 123 | |
| 124 | filter_help_string = """\ |
| 125 | expression consists of 3 string selectors separated by '.' separators: |
| 126 | |
| 127 | <file>.<class>.<function> |
| 128 | |
| 129 | - selectors restrict which files/classes/functions are run |
| 130 | - selector can be replaced with '*' or omitted entirely if not needed |
| 131 | - <file> selector is automatically prepended with 'test_' if required |
| 132 | - '.' separators are required only if selector(s) follow(s) |
| 133 | |
| 134 | examples: |
| 135 | |
| 136 | 1. all of the following expressions are equivalent and will select |
| 137 | all test classes and functions from test_bfd.py: |
| 138 | 'test_bfd' 'bfd' 'test_bfd..' 'bfd.' 'bfd.*.*' 'test_bfd.*.*' |
| 139 | 2. 'bfd.BFDAPITestCase' selects all tests from test_bfd.py, |
| 140 | which are part of BFDAPITestCase class |
| 141 | 3. 'bfd.BFDAPITestCase.test_add_bfd' selects a single test named |
| 142 | test_add_bfd from test_bfd.py/BFDAPITestCase |
| 143 | 4. '.*.test_add_bfd' selects all test functions named test_add_bfd |
| 144 | from all files/classes |
| 145 | """ |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 146 | parser.add_argument( |
| 147 | "--filter", action="store", metavar="FILTER_EXPRESSION", help=filter_help_string |
| 148 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 149 | |
| 150 | default_retries = 0 |
| 151 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 152 | parser.add_argument( |
| 153 | "--retries", |
| 154 | action="store", |
| 155 | default=default_retries, |
| 156 | type=positive_int_or_default(default_retries), |
| 157 | help="retry failed tests RETRIES times", |
| 158 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 159 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 160 | parser.add_argument( |
| 161 | "--step", action="store_true", default=False, help="enable stepping through tests" |
| 162 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 163 | |
| 164 | debug_help_string = """\ |
| 165 | attach - attach to already running vpp |
| 166 | core - detect coredump and load core in gdb on crash |
| 167 | gdb - print VPP PID and pause allowing attaching gdb |
| 168 | gdbserver - same as above, but run gdb in gdbserver |
| 169 | """ |
| 170 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 171 | parser.add_argument( |
| 172 | "--debug", |
| 173 | action="store", |
| 174 | choices=["attach", "core", "gdb", "gdbserver"], |
| 175 | help=debug_help_string, |
| 176 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 177 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 178 | parser.add_argument( |
| 179 | "--debug-framework", |
| 180 | action="store_true", |
| 181 | help="enable internal test framework debugging", |
| 182 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 183 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 184 | parser.add_argument( |
| 185 | "--compress-core", |
| 186 | action="store_true", |
| 187 | help="compress core files if not debugging them", |
| 188 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 189 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 190 | parser.add_argument("--extended", action="store_true", help="run extended tests") |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 191 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 192 | parser.add_argument( |
| 193 | "--sanity", action="store_true", help="perform sanity vpp run before running tests" |
| 194 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 195 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 196 | parser.add_argument( |
| 197 | "--force-foreground", |
| 198 | action="store_true", |
| 199 | help="force running in foreground - don't fork", |
| 200 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 201 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 202 | parser.add_argument( |
| 203 | "--jobs", |
| 204 | action="store", |
| 205 | type=positive_int_or_auto, |
| 206 | default="auto", |
| 207 | help="maximum concurrent test jobs", |
| 208 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 209 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 210 | parser.add_argument( |
| 211 | "--venv-dir", action="store", type=directory, help="path to virtual environment" |
| 212 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 213 | |
| 214 | default_rnd_seed = time.time() |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 215 | parser.add_argument( |
| 216 | "--rnd-seed", |
| 217 | action="store", |
| 218 | default=default_rnd_seed, |
| 219 | type=positive_float_or_default(default_rnd_seed), |
| 220 | help="random generator seed (default: current time)", |
| 221 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 222 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 223 | parser.add_argument( |
| 224 | "--vpp-worker-count", |
| 225 | action="store", |
| 226 | type=worker_config, |
| 227 | default=0, |
| 228 | help="number of vpp workers", |
| 229 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 230 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 231 | parser.add_argument( |
| 232 | "--gcov", action="store_true", default=False, help="running gcov tests" |
| 233 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 234 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 235 | parser.add_argument( |
| 236 | "--cache-vpp-output", |
| 237 | action="store_true", |
| 238 | default=False, |
| 239 | help="cache VPP stdout/stderr and log as one block after test finishes", |
| 240 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 241 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 242 | parser.add_argument( |
| 243 | "--vpp-ws-dir", |
| 244 | action="store", |
| 245 | required=True, |
| 246 | type=directory, |
| 247 | help="vpp workspace directory", |
| 248 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 249 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 250 | parser.add_argument( |
| 251 | "--vpp-tag", |
| 252 | action="store", |
| 253 | default="vpp_debug", |
| 254 | metavar="VPP_TAG", |
| 255 | required=True, |
| 256 | help="vpp tag (e.g. vpp, vpp_debug, vpp_gcov)", |
| 257 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 258 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 259 | parser.add_argument( |
| 260 | "--vpp", |
| 261 | action="store", |
| 262 | help="path to vpp binary (default: derive from VPP_WS_DIR and VPP_TAG)", |
| 263 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 264 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 265 | parser.add_argument( |
| 266 | "--vpp-install-dir", |
| 267 | type=directory, |
| 268 | action="store", |
| 269 | help="path to vpp install directory" |
| 270 | "(default: derive from VPP_WS_DIR and VPP_TAG)", |
| 271 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 272 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 273 | parser.add_argument( |
| 274 | "--vpp-build-dir", |
| 275 | action="store", |
| 276 | type=directory, |
| 277 | help="vpp build directory (default: derive from VPP_WS_DIR and VPP_TAG)", |
| 278 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 279 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 280 | parser.add_argument( |
| 281 | "--vpp-plugin-dir", |
| 282 | action="append", |
| 283 | type=directory, |
| 284 | help="directory containing vpp plugins" |
| 285 | "(default: derive from VPP_WS_DIR and VPP_TAG)", |
| 286 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 287 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 288 | parser.add_argument( |
| 289 | "--vpp-test-plugin-dir", |
| 290 | action="append", |
| 291 | type=directory, |
| 292 | help="directory containing vpp api test plugins" |
| 293 | "(default: derive from VPP_WS_DIR and VPP_TAG)", |
| 294 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 295 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 296 | parser.add_argument( |
| 297 | "--extern-plugin-dir", |
| 298 | action="append", |
| 299 | type=directory, |
| 300 | default=[], |
| 301 | help="directory containing external plugins", |
| 302 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 303 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 304 | parser.add_argument( |
Ole Troan | 37157da | 2022-12-01 11:22:06 +0100 | [diff] [blame] | 305 | "--extern-apidir", |
| 306 | action="append", |
| 307 | type=directory, |
| 308 | default=[], |
| 309 | help="directory to look for API JSON files", |
| 310 | ) |
| 311 | |
| 312 | parser.add_argument( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 313 | "--coredump-size", |
| 314 | action="store", |
| 315 | default="unlimited", |
| 316 | help="specify vpp coredump size", |
| 317 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 318 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 319 | parser.add_argument( |
| 320 | "--max-vpp-cpus", |
| 321 | action="store", |
| 322 | type=int_or_auto, |
| 323 | default=0, |
| 324 | help="max cpus used by vpp", |
| 325 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 326 | |
| 327 | variant_help_string = """\ |
| 328 | specify which march node variant to unit test |
| 329 | e.g. --variant=skx - test the skx march variants |
| 330 | e.g. --variant=icl - test the icl march variants |
| 331 | """ |
| 332 | |
| 333 | parser.add_argument("--variant", action="store", help=variant_help_string) |
| 334 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 335 | parser.add_argument( |
| 336 | "--api-fuzz", action="store", default=None, help="specify api fuzzing parameters" |
| 337 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 338 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 339 | parser.add_argument( |
| 340 | "--wipe-tmp-dir", |
| 341 | action="store_true", |
| 342 | default=True, |
| 343 | help="remove test tmp directory before running test", |
| 344 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 345 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 346 | parser.add_argument( |
| 347 | "--tmp-dir", |
| 348 | action="store", |
| 349 | default="/tmp", |
| 350 | type=directory_verify_or_create, |
| 351 | help="directory where to store test temporary directories", |
| 352 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 353 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 354 | parser.add_argument( |
| 355 | "--log-dir", |
| 356 | action="store", |
| 357 | type=directory_verify_or_create, |
| 358 | help="directory where to store directories " |
| 359 | "containing log files (default: --tmp-dir)", |
| 360 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 361 | |
| 362 | default_keep_pcaps = False |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 363 | parser.add_argument( |
| 364 | "--keep-pcaps", |
| 365 | action="store_true", |
| 366 | default=default_keep_pcaps, |
Klement Sekera | 152a9b6 | 2022-05-13 18:01:36 +0200 | [diff] [blame] | 367 | help=f"if set, keep all pcap files from a test run (default: {default_keep_pcaps})", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 368 | ) |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 369 | |
Naveen Joy | c872cec | 2022-08-30 13:59:03 -0700 | [diff] [blame] | 370 | parser.add_argument( |
| 371 | "-r", |
| 372 | "--use-running-vpp", |
| 373 | dest="running_vpp", |
| 374 | required=False, |
| 375 | action="store_true", |
| 376 | default=False, |
| 377 | help="Runs tests against a running VPP.", |
| 378 | ) |
| 379 | |
| 380 | parser.add_argument( |
| 381 | "-d", |
| 382 | "--socket-dir", |
| 383 | dest="socket_dir", |
| 384 | required=False, |
| 385 | action="store", |
| 386 | default="", |
| 387 | help="Relative or absolute path to running VPP's socket directory.\n" |
| 388 | "The directory must contain VPP's socket files:api.sock & stats.sock.\n" |
| 389 | "Default: /var/run/vpp if VPP is started as the root user, else " |
| 390 | "/var/run/user/${uid}/vpp.", |
| 391 | ) |
| 392 | |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 393 | config = parser.parse_args() |
| 394 | |
| 395 | ws = config.vpp_ws_dir |
| 396 | br = f"{ws}/build-root" |
| 397 | tag = config.vpp_tag |
| 398 | |
| 399 | if config.vpp_install_dir is None: |
| 400 | config.vpp_install_dir = f"{br}/install-{tag}-native" |
| 401 | |
| 402 | if config.vpp is None: |
| 403 | config.vpp = f"{config.vpp_install_dir}/vpp/bin/vpp" |
| 404 | |
| 405 | if config.vpp_build_dir is None: |
| 406 | config.vpp_build_dir = f"{br}/build-{tag}-native" |
| 407 | |
| 408 | libs = ["lib", "lib64"] |
| 409 | |
| 410 | if config.vpp_plugin_dir is None: |
| 411 | config.vpp_plugin_dir = [ |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 412 | f"{config.vpp_install_dir}/vpp/{lib}/vpp_plugins" for lib in libs |
| 413 | ] |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 414 | |
| 415 | if config.vpp_test_plugin_dir is None: |
| 416 | config.vpp_test_plugin_dir = [ |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 417 | f"{config.vpp_install_dir}/vpp/{lib}/vpp_api_test_plugins" for lib in libs |
| 418 | ] |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 419 | |
| 420 | test_dirs = [f"{ws}/test"] |
| 421 | |
| 422 | if config.test_src_dir is not None: |
| 423 | test_dirs.extend(config.test_src_dir) |
| 424 | |
| 425 | config.test_src_dir = test_dirs |
| 426 | |
| 427 | |
| 428 | if config.venv_dir is None: |
Saima Yunus | c7f93b3 | 2022-08-10 03:25:31 -0400 | [diff] [blame] | 429 | config.venv_dir = f"{ws}/build-root/test/venv" |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 430 | |
Klement Sekera | 152a9b6 | 2022-05-13 18:01:36 +0200 | [diff] [blame] | 431 | if config.failed_dir is None: |
| 432 | config.failed_dir = f"{config.tmp_dir}" |
| 433 | |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 434 | available_cpus = psutil.Process().cpu_affinity() |
| 435 | num_cpus = len(available_cpus) |
| 436 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 437 | if config.max_vpp_cpus == "auto": |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 438 | max_vpp_cpus = num_cpus |
| 439 | elif config.max_vpp_cpus > 0: |
| 440 | max_vpp_cpus = min(config.max_vpp_cpus, num_cpus) |
| 441 | else: |
| 442 | max_vpp_cpus = num_cpus |
| 443 | |
| 444 | if __name__ == "__main__": |
| 445 | print("Provided arguments:") |
| 446 | for i in config.__dict__: |
| 447 | print(f" {i} is {config.__dict__[i]}") |