Debian Codegraph @

tests/args_parser.py

raw
1 # SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB)
2 # Copyright (c) 2020 Kamal Heib <[email protected]>, All rights reserved. See COPYING file
3 # Copyright (c) 2021 Nvidia, Inc. All rights reserved. See COPYING file
4
5 import argparse
6 import sys
7
8
9 class ArgsParser(object):
10 def __init__(self):
11 self.args = None
12
13 def get_config(self):
14 return self.args
15
16 def parse_args(self):
17 parser = argparse.ArgumentParser()
18 parser.add_argument('--dev',
19 help='RDMA device to run the tests on')
20 parser.add_argument('--pci-dev',
21 help='PCI device to run the tests on, which is '
22 'needed by some tests where the RDMA device is '
23 'not available (e.g. VFIO)')
24 parser.add_argument('--port',
25 help='Use port <port> of RDMA device', type=int,
26 default=1)
27 parser.add_argument('--gid',
28 help='Use gid index <gid> of RDMA device', type=int)
29 parser.add_argument('--gpu', nargs='?', type=int, const=0, default=0,
30 help='GPU unit to allocate dmabuf from')
31 parser.add_argument('--gtt', action='store_true', default=False,
32 help='Allocate dmabuf from GTT instead of VRAM')
33 parser.add_argument('-v', '--verbose', dest='verbosity',
34 action='store_const',
35 const=2, help='Verbose output')
36 parser.add_argument('--list-tests', action='store_true', default=False,
37 help='Print a list of the full test names that are '
38 'loaded by default and exit without running '
39 'them.')
40 ns, args = parser.parse_known_args()
41 self.args = vars(ns)
42 if self.args['verbosity']:
43 args += ['--verbose']
44 sys.argv[1:] = args
45
46
47 parser = ArgsParser()