-
Notifications
You must be signed in to change notification settings - Fork 13
/
meson.build
85 lines (75 loc) · 3.38 KB
/
meson.build
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Copyright (c) 2022, Dell Inc. or its subsidiaries. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# See the LICENSE file for details.
#
# This file is part of NVMe STorage Appliance Services (nvme-stas).
#
# Authors: Martin Belanger <Martin.Belanger@dell.com>
#
libnvme_dep = dependency('python3-libnvme', fallback: ['libnvme', 'libnvme_dep'], version : '>= 1.2', required: false) # Only required to run the tests
if libnvme_dep.found()
test_env = environment({'MALLOC_PERTURB_': '0'})
test_env.prepend('PYTHONPATH', PYTHONPATH)
# pylint and pyflakes
if modules_to_lint.length() != 0
pylint = find_program('pylint', required: false)
pyflakes = find_program('pyflakes3', required: false)
if not pyflakes.found()
temp = find_program('pyflakes', required: false)
if temp.found() and run_command(temp, '--version', check: false).stdout().contains('Python 3')
pyflakes = temp
endif
endif
rcfile = join_paths(meson.current_source_dir(), 'pylint.rc')
if pylint.found()
test('pylint', pylint, args: ['--rcfile=' + rcfile] + modules_to_lint, env: test_env)
endif
if pyflakes.found()
test('pyflakes', pyflakes, args: modules_to_lint, env: test_env)
endif
endif
# Unit tests
things_to_test = [
['Test Avahi', 'test-avahi.py', []],
['Test Configuration', 'test-config.py', []],
['Test Controller', 'test-controller.py', ['pyfakefs']],
['Test GTimer', 'test-gtimer.py', []],
['Test iputil', 'test-iputil.py', []],
['Test KernelVersion', 'test-version.py', []],
['Test log', 'test-log.py', ['pyfakefs']],
['Test NvmeOptions', 'test-nvme_options.py', ['pyfakefs']],
['Test Service', 'test-service.py', ['pyfakefs']],
['Test TID', 'test-transport_id.py', []],
['Test Udev', 'test-udev.py', []],
]
foreach thing: things_to_test
msg = thing[0]
# Check whether all dependencies can be found
missing_deps = []
deps = thing[2]
foreach dep : deps
if run_command(python3, '-c', 'import @0@'.format(dep), check: false).returncode() != 0
missing_deps += [dep]
endif
endforeach
if missing_deps.length() == 0
# Run the test if all dependencies are available
script = join_paths(meson.current_source_dir(), thing[1])
test(msg, python3, args: script, env: test_env)
else
warning('"@0@" requires python module "@1@"'.format(msg, missing_deps))
endif
endforeach
# Make sure code complies with minimum Python version requirement.
tools = [
join_paths(meson.current_source_dir(), '../man'),
join_paths(meson.current_source_dir(), '../utils'),
]
vermin = find_program('vermin', required: false)
if vermin.found()
if modules_to_lint.length() != 0
test('vermin code', vermin, args: ['--config-file', join_paths(meson.current_source_dir(), 'vermin.conf')] + modules_to_lint, env: test_env)
endif
test('vermin tools', vermin, args: ['--config-file', join_paths(meson.current_source_dir(), 'vermin-tools.conf')] + tools, env: test_env)
endif
endif