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