opencos-eda 0.3.8__py3-none-any.whl → 0.3.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- opencos/commands/deps_help.py +40 -21
- opencos/commands/sim.py +0 -1
- opencos/deps/deps_file.py +82 -79
- opencos/eda.py +108 -17
- opencos/eda_base.py +8 -4
- opencos/eda_config.py +8 -1
- opencos/eda_config_defaults.yml +14 -5
- opencos/eda_deps_bash_completion.bash +37 -15
- opencos/tools/modelsim_ase.py +19 -378
- opencos/tools/questa.py +42 -247
- opencos/tools/questa_common.py +480 -0
- opencos/tools/questa_fe.py +84 -0
- opencos/tools/questa_fse.py +7 -8
- opencos/tools/riviera.py +27 -10
- opencos/tools/verilator.py +1 -0
- opencos/utils/str_helpers.py +7 -0
- opencos/utils/vsim_helper.py +53 -21
- {opencos_eda-0.3.8.dist-info → opencos_eda-0.3.10.dist-info}/METADATA +2 -1
- {opencos_eda-0.3.8.dist-info → opencos_eda-0.3.10.dist-info}/RECORD +24 -40
- {opencos_eda-0.3.8.dist-info → opencos_eda-0.3.10.dist-info}/entry_points.txt +1 -0
- opencos/tests/__init__.py +0 -0
- opencos/tests/custom_config.yml +0 -13
- opencos/tests/deps_files/command_order/DEPS.yml +0 -44
- opencos/tests/deps_files/error_msgs/DEPS.yml +0 -55
- opencos/tests/deps_files/iverilog_test/DEPS.yml +0 -4
- opencos/tests/deps_files/no_deps_here/DEPS.yml +0 -0
- opencos/tests/deps_files/non_sv_reqs/DEPS.yml +0 -50
- opencos/tests/deps_files/tags_with_tools/DEPS.yml +0 -54
- opencos/tests/deps_files/test_err_fatal/DEPS.yml +0 -4
- opencos/tests/helpers.py +0 -354
- opencos/tests/test_build.py +0 -12
- opencos/tests/test_deps_helpers.py +0 -207
- opencos/tests/test_deps_schema.py +0 -30
- opencos/tests/test_eda.py +0 -921
- opencos/tests/test_eda_elab.py +0 -110
- opencos/tests/test_eda_synth.py +0 -150
- opencos/tests/test_oc_cli.py +0 -25
- opencos/tests/test_tools.py +0 -404
- {opencos_eda-0.3.8.dist-info → opencos_eda-0.3.10.dist-info}/WHEEL +0 -0
- {opencos_eda-0.3.8.dist-info → opencos_eda-0.3.10.dist-info}/licenses/LICENSE +0 -0
- {opencos_eda-0.3.8.dist-info → opencos_eda-0.3.10.dist-info}/licenses/LICENSE.spdx +0 -0
- {opencos_eda-0.3.8.dist-info → opencos_eda-0.3.10.dist-info}/top_level.txt +0 -0
opencos/tests/test_eda.py
DELETED
|
@@ -1,921 +0,0 @@
|
|
|
1
|
-
'''pytests for: eda
|
|
2
|
-
|
|
3
|
-
Using eda.main() entrypoint
|
|
4
|
-
|
|
5
|
-
If you want to run this, consider running from the root of opencos repo:
|
|
6
|
-
> pytest --verbose opencos/*/*.py
|
|
7
|
-
> python3 -m pytest --verbose opencos/*/*.py
|
|
8
|
-
> python3 -m pytest -rx opencos/*/*.py
|
|
9
|
-
which avoids using any pip installed opencos.eda
|
|
10
|
-
|
|
11
|
-
Throughout this file, if you see:
|
|
12
|
-
assert rc > 1
|
|
13
|
-
It is not a typo. We would prefer all expected errors to be caught and reported by
|
|
14
|
-
eda.py. Python errors tend to return with rc=1, and those are problematic for us
|
|
15
|
-
and should be more gracefully handled.
|
|
16
|
-
'''
|
|
17
|
-
|
|
18
|
-
# pylint: disable=R0801 # (similar lines in 2+ files)
|
|
19
|
-
|
|
20
|
-
import os
|
|
21
|
-
import shutil
|
|
22
|
-
import subprocess
|
|
23
|
-
|
|
24
|
-
import pytest
|
|
25
|
-
|
|
26
|
-
from opencos import eda
|
|
27
|
-
from opencos.utils.markup_helpers import yaml_safe_load
|
|
28
|
-
from opencos.tests import helpers
|
|
29
|
-
from opencos.tests.helpers import eda_wrap, eda_sim_wrap, eda_elab_wrap, \
|
|
30
|
-
Helpers, tools_loaded, can_run_eda_sim
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
THISPATH = os.path.dirname(__file__)
|
|
35
|
-
|
|
36
|
-
def chdir_remove_work_dir(relpath):
|
|
37
|
-
'''Changes dir to relpath, removes the work directories (eda.work, eda.export*)'''
|
|
38
|
-
return helpers.chdir_remove_work_dir(THISPATH, relpath)
|
|
39
|
-
|
|
40
|
-
@pytest.mark.skipif(
|
|
41
|
-
'verilator' not in tools_loaded and 'vivado' not in tools_loaded,
|
|
42
|
-
reason="requires verilator OR vivado"
|
|
43
|
-
)
|
|
44
|
-
def test_args_sim_default_tool():
|
|
45
|
-
'''Test that: eda sim <target>; works'''
|
|
46
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
47
|
-
rc = eda_sim_wrap('oclib_fifo_test')
|
|
48
|
-
print(f'{rc=}')
|
|
49
|
-
assert rc == 0
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
class TestTargets(Helpers):
|
|
53
|
-
'''Tests for: eda targets'''
|
|
54
|
-
|
|
55
|
-
DEFAULT_DIR = os.path.join(THISPATH, '..', '..', 'lib', 'tests')
|
|
56
|
-
|
|
57
|
-
def test_lib_tests__no_pattern(self):
|
|
58
|
-
'''Test that this works: eda targets'''
|
|
59
|
-
self.chdir()
|
|
60
|
-
rc = self.log_it('targets --debug', use_eda_wrap=False)
|
|
61
|
-
assert rc == 0
|
|
62
|
-
assert self.is_in_log('oclib_fifo_test')
|
|
63
|
-
assert self.is_in_log('oclib_rrarb_test')
|
|
64
|
-
|
|
65
|
-
def test_lib_tests__with_pattern(self):
|
|
66
|
-
'''Test that this works: eda targets oclib_fifo*test'''
|
|
67
|
-
self.chdir()
|
|
68
|
-
rc = self.log_it('targets oclib_fifo*test', use_eda_wrap=False)
|
|
69
|
-
assert rc == 0
|
|
70
|
-
assert self.is_in_log('oclib_fifo_test')
|
|
71
|
-
assert not self.is_in_log('oclib_rrarb_test')
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
@pytest.mark.skipif(
|
|
75
|
-
'verilator' not in tools_loaded, reason="requires verilator"
|
|
76
|
-
)
|
|
77
|
-
class TestsRequiresVerilator( # pylint: disable=too-many-public-methods
|
|
78
|
-
Helpers
|
|
79
|
-
):
|
|
80
|
-
'''Tests that require verilator, skip if not present (in some Github Action containers)'''
|
|
81
|
-
|
|
82
|
-
def test_verilator_cant_run_synth(self):
|
|
83
|
-
'''Checks eda.check_command_handler_cls(...) so we don't fallback to a different tool'''
|
|
84
|
-
# If you say you want verilator, then we will NOT choose a different default handler.
|
|
85
|
-
chdir_remove_work_dir('../../lib')
|
|
86
|
-
rc = eda_wrap('synth', '--tool', 'verilator', 'oclib_fifo')
|
|
87
|
-
print(f'{rc=}')
|
|
88
|
-
assert rc > 1
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def test_args_sim(self):
|
|
92
|
-
'''Basic sim with --tool verilator'''
|
|
93
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
94
|
-
rc = eda_sim_wrap('--tool', 'verilator', 'oclib_fifo_test')
|
|
95
|
-
print(f'{rc=}')
|
|
96
|
-
assert rc == 0
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
def test_args_sim_tool_with_path(self):
|
|
101
|
-
'''Test for calling a tool as --tool=<tool>=</path/to/tool-exe>'''
|
|
102
|
-
verilator_fullpath = shutil.which('verilator')
|
|
103
|
-
verilator_path, _ = os.path.split(verilator_fullpath)
|
|
104
|
-
|
|
105
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
106
|
-
rc = eda_sim_wrap('--tool', f'verilator={verilator_fullpath}', 'oclib_fifo_test')
|
|
107
|
-
assert rc == 0
|
|
108
|
-
|
|
109
|
-
rc = eda_sim_wrap('--tool', f'verilator:{verilator_fullpath}', 'oclib_fifo_test')
|
|
110
|
-
assert rc == 0
|
|
111
|
-
|
|
112
|
-
rc = eda_sim_wrap('--tool', f'verilator={verilator_path}', 'oclib_fifo_test')
|
|
113
|
-
assert rc == 0
|
|
114
|
-
|
|
115
|
-
rc = eda_sim_wrap('--tool', f'verilator:{verilator_fullpath}', 'oclib_fifo_test')
|
|
116
|
-
assert rc == 0
|
|
117
|
-
|
|
118
|
-
def test_args_sim_with_coverage(self):
|
|
119
|
-
'''Test for verilator --coverage'''
|
|
120
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
121
|
-
rc = eda_wrap('sim', '--coverage', '--tool', 'verilator', 'oclib_fifo_test')
|
|
122
|
-
print(f'{rc=}')
|
|
123
|
-
assert rc == 0
|
|
124
|
-
# We don't check the logs, but the command should succeed.
|
|
125
|
-
|
|
126
|
-
def test_args_lint_only_sim(self):
|
|
127
|
-
'''Confirm --lint-only works for Verilator with 'sim' command.'''
|
|
128
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
129
|
-
rc = eda_sim_wrap('--lint-only', '--tool', 'verilator', 'oclib_fifo_test')
|
|
130
|
-
print(f'{rc=}')
|
|
131
|
-
assert rc == 0
|
|
132
|
-
|
|
133
|
-
def test_args_elab(self):
|
|
134
|
-
'''Test for: eda elab'''
|
|
135
|
-
chdir_remove_work_dir('../../lib')
|
|
136
|
-
rc = eda_elab_wrap('--tool', 'verilator', 'oclib_priarb')
|
|
137
|
-
print(f'{rc=}')
|
|
138
|
-
assert rc == 0
|
|
139
|
-
|
|
140
|
-
def test_run_from_work_dir(self):
|
|
141
|
-
'''
|
|
142
|
-
Uses eda --stop-before-compile to craft the eda.work/(test)/ dirs and shell commands,
|
|
143
|
-
and confirms that we can run those shell commands.
|
|
144
|
-
'''
|
|
145
|
-
|
|
146
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
147
|
-
rc = eda_sim_wrap('--stop-before-compile', '--tool', 'verilator', 'oclib_fifo_test')
|
|
148
|
-
print(f'{rc=}')
|
|
149
|
-
assert rc == 0
|
|
150
|
-
|
|
151
|
-
os.chdir(os.path.join(THISPATH, '../../lib/tests/eda.work/oclib_fifo_test.sim'))
|
|
152
|
-
res = subprocess.run(
|
|
153
|
-
[ './lint_only.sh' ], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
|
154
|
-
check=True
|
|
155
|
-
)
|
|
156
|
-
rc = res.returncode
|
|
157
|
-
print(f'{rc=}')
|
|
158
|
-
assert rc == 0
|
|
159
|
-
assert res.stdout
|
|
160
|
-
assert res.stderr == b''
|
|
161
|
-
|
|
162
|
-
res = subprocess.run(
|
|
163
|
-
[ './all.sh' ], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
|
164
|
-
check=True
|
|
165
|
-
)
|
|
166
|
-
rc = res.returncode
|
|
167
|
-
print(f'{rc=}')
|
|
168
|
-
assert rc == 0
|
|
169
|
-
assert res.stdout
|
|
170
|
-
assert res.stderr == b''
|
|
171
|
-
|
|
172
|
-
res = subprocess.run(
|
|
173
|
-
[ './simulate.sh' ], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
|
174
|
-
check=True
|
|
175
|
-
)
|
|
176
|
-
rc = res.returncode
|
|
177
|
-
print(f'{rc=}')
|
|
178
|
-
assert rc == 0
|
|
179
|
-
assert res.stdout
|
|
180
|
-
assert res.stderr == b''
|
|
181
|
-
|
|
182
|
-
def test_args_sim_waves(self):
|
|
183
|
-
'''Test that --waves for verilator works (FST, not VCD)'''
|
|
184
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
185
|
-
rc = eda_sim_wrap('--tool', 'verilator', '--waves', 'oclib_fifo_test')
|
|
186
|
-
print(f'{rc=}')
|
|
187
|
-
assert os.path.exists(os.path.join('.', 'eda.work', 'oclib_fifo_test.sim', 'dump.fst'))
|
|
188
|
-
assert rc == 0
|
|
189
|
-
|
|
190
|
-
def test_args_sim_waves_dumpvcd(self):
|
|
191
|
-
'''Test that --waves --dump-vcd works for the opencos/ style SV tests'''
|
|
192
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
193
|
-
rc = eda_sim_wrap('--tool', 'verilator', '--waves', '--dump-vcd', 'oclib_fifo_test')
|
|
194
|
-
print(f'{rc=}')
|
|
195
|
-
assert os.path.exists(os.path.join('.', 'eda.work', 'oclib_fifo_test.sim', 'dump.vcd'))
|
|
196
|
-
assert rc == 0
|
|
197
|
-
|
|
198
|
-
def test_args_sim_dumpvcd_verilator_trace(self):
|
|
199
|
-
'''Do not set --dump-vcd, set --waves and do directly set +trace=vcd,
|
|
200
|
-
and confirm +trace works as a bare CLI plusarg'''
|
|
201
|
-
|
|
202
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
203
|
-
rc = self.log_it('sim --tool verilator --waves +trace=vcd oclib_fifo_test')
|
|
204
|
-
assert rc == 0
|
|
205
|
-
assert os.path.exists(os.path.join('.', 'eda.work', 'oclib_fifo_test.sim', 'dump.vcd'))
|
|
206
|
-
lines = self.get_log_lines_with('exec: ./obj_dir/sim.exe')
|
|
207
|
-
assert len(lines) == 1
|
|
208
|
-
assert ' +trace=vcd ' in lines[0]
|
|
209
|
-
assert ' +trace ' not in lines[0]
|
|
210
|
-
|
|
211
|
-
def test_args_seed1(self):
|
|
212
|
-
'''Test for: eda sim --tool verilator --seed <value>'''
|
|
213
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
214
|
-
rc = self.log_it('sim --tool verilator --seed=1 oclib_fifo_test')
|
|
215
|
-
assert rc == 0
|
|
216
|
-
lines = self.get_log_lines_with('exec: ./obj_dir/sim.exe')
|
|
217
|
-
assert len(lines) == 1
|
|
218
|
-
assert ' +verilator+seed+1 ' in lines[0]
|
|
219
|
-
|
|
220
|
-
def test_args_wno_fatal(self):
|
|
221
|
-
'''Test for: eda sim --tool verilator w/ --verilate-args'''
|
|
222
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
223
|
-
rc = self.log_it('sim --tool verilator --verilate-args=-Wno-fatal oclib_fifo_test')
|
|
224
|
-
assert rc == 0
|
|
225
|
-
lines = self.get_log_lines_with('exec: ')
|
|
226
|
-
assert len(lines) == 2
|
|
227
|
-
assert 'verilator' in lines[0]
|
|
228
|
-
assert ' -Wno-fatal ' in lines[0]
|
|
229
|
-
assert 'sim.exe' in lines[1]
|
|
230
|
-
|
|
231
|
-
def test_args_sim_should_fail(self):
|
|
232
|
-
'''Test that our command handler for verilator will fail b/c --xilinx set.'''
|
|
233
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
234
|
-
# We'd expect this to fail b/c --xilinx and --tool verilator flags an error. I do not
|
|
235
|
-
# want to use the xfail pytest decorator.
|
|
236
|
-
rc = eda_sim_wrap('--xilinx', '--tool', 'verilator', 'oclib_fifo_test')
|
|
237
|
-
print(f'{rc=}')
|
|
238
|
-
assert rc > 1
|
|
239
|
-
|
|
240
|
-
def test_more_plusargs_sim(self):
|
|
241
|
-
'''Test that unprocessed plusargs become sim-plusargs on CLI'''
|
|
242
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
243
|
-
rc = self.log_it('sim --tool verilator +info=300 +some_plusarg_novalue oclib_fifo_test')
|
|
244
|
-
assert rc == 0
|
|
245
|
-
lines = self.get_log_lines_with('exec: ./obj_dir/sim.exe')
|
|
246
|
-
assert len(lines) == 1
|
|
247
|
-
assert ' +info=300 ' in lines[0]
|
|
248
|
-
assert ' +info ' not in lines[0]
|
|
249
|
-
assert ' +some_plusarg_novalue ' in lines[0]
|
|
250
|
-
assert ' +some_plusarg_novalue=' not in lines[0]
|
|
251
|
-
|
|
252
|
-
def test_args_multi_sim(self):
|
|
253
|
-
'''Basic test for: eda multi sim, with common args, should pass.'''
|
|
254
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
255
|
-
rc = eda.main('multi', 'sim', '--fail-if-no-targets', '--seed=1', '--tool', 'verilator',
|
|
256
|
-
'oclib_fifo_test')
|
|
257
|
-
print(f'{rc=}')
|
|
258
|
-
assert rc == 0
|
|
259
|
-
|
|
260
|
-
def test_args_multi_sim_timeout(self):
|
|
261
|
-
'''Test for --single-timout in: eda multi'''
|
|
262
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
263
|
-
rc = eda.main('multi', 'sim', '--fail-if-no-targets', '--seed=1', '--tool', 'verilator',
|
|
264
|
-
'--single-timeout', '10', 'oclib_fifo_test')
|
|
265
|
-
print(f'{rc=}')
|
|
266
|
-
assert rc == 0
|
|
267
|
-
|
|
268
|
-
def test_args_multi_sim_should_fail(self):
|
|
269
|
-
'''Checks that: eda multi --fail-if-no-targets; will fail b/c the found target fails'''
|
|
270
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
271
|
-
# We'd expect this to fail b/c --xilinx and --tool verilator flags an error. I do not
|
|
272
|
-
# want to use the xfail pytest decorator.
|
|
273
|
-
rc = eda.main('multi', 'sim', '--fail-if-no-targets', '--seed=1', '--xilinx', '--tool',
|
|
274
|
-
'verilator', 'oclib_fifo_test')
|
|
275
|
-
print(f'{rc=}')
|
|
276
|
-
assert rc > 1
|
|
277
|
-
|
|
278
|
-
def test_args_multi_sim_no_targets_should_fail(self):
|
|
279
|
-
'''Checks that: eda multi --fail-if-no-targets; will fail if no targets expanded'''
|
|
280
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
281
|
-
# We'd expect this to fail b/c no_targets* should expand to nothing.
|
|
282
|
-
rc = eda.main('multi', 'sim', '--fail-if-no-targets', '--seed=1', '--tool', 'verilator',
|
|
283
|
-
'no_targets*')
|
|
284
|
-
print(f'{rc=}')
|
|
285
|
-
assert rc > 1
|
|
286
|
-
|
|
287
|
-
def test_elab_verilator_no_deps_files_involved(self):
|
|
288
|
-
'''Test that inferring the --top from last file in provides files works.'''
|
|
289
|
-
# no --top set, have to infer its final file name.
|
|
290
|
-
chdir_remove_work_dir('../../lib')
|
|
291
|
-
|
|
292
|
-
cmd_list = (
|
|
293
|
-
'elab --tool verilator +incdir+.. oclib_assert_pkg.sv oclib_pkg.sv'
|
|
294
|
-
' ../sim/ocsim_pkg.sv ../sim/ocsim_urand.sv ./rams/oclib_ram1r1w_infer.sv'
|
|
295
|
-
' ./rams/oclib_ram1r1w_infer_core.v oclib_fifo.sv'
|
|
296
|
-
).split()
|
|
297
|
-
|
|
298
|
-
rc = eda.main(*cmd_list)
|
|
299
|
-
print(f'{rc=}')
|
|
300
|
-
assert rc == 0
|
|
301
|
-
# We don't get a log for this, but we can check the output generated eda_output_config.yml.
|
|
302
|
-
eda_config_yml_path = os.path.join(
|
|
303
|
-
os.getcwd(), 'eda.work', 'oclib_fifo.elab', 'eda_output_config.yml'
|
|
304
|
-
)
|
|
305
|
-
data = yaml_safe_load(eda_config_yml_path)
|
|
306
|
-
assert 'args' in data
|
|
307
|
-
assert data['args'].get('top', '') == 'oclib_fifo'
|
|
308
|
-
assert 'config' in data
|
|
309
|
-
assert 'eda_original_args' in data['config']
|
|
310
|
-
assert 'oclib_fifo.sv' in data['config']['eda_original_args']
|
|
311
|
-
assert data.get('target', '') == 'oclib_fifo'
|
|
312
|
-
|
|
313
|
-
def test_elab_verilator_some_deps_files_involved(self):
|
|
314
|
-
'''Test calling targets (not files) on CLI.'''
|
|
315
|
-
# no --top set, have to infer its final file name.
|
|
316
|
-
chdir_remove_work_dir('../../lib')
|
|
317
|
-
cmd_list = 'elab --tool verilator +incdir+.. all_pkg oclib_ram1r1w oclib_fifo.sv'.split()
|
|
318
|
-
rc = eda.main(*cmd_list)
|
|
319
|
-
print(f'{rc=}')
|
|
320
|
-
assert rc == 0
|
|
321
|
-
# We don't get a log for this, but we can check the output generated eda_output_config.yml.
|
|
322
|
-
eda_config_yml_path = os.path.join(
|
|
323
|
-
os.getcwd(), 'eda.work', 'oclib_fifo.elab', 'eda_output_config.yml'
|
|
324
|
-
)
|
|
325
|
-
data = yaml_safe_load(eda_config_yml_path)
|
|
326
|
-
assert 'args' in data
|
|
327
|
-
assert data['args'].get('top', '') == 'oclib_fifo'
|
|
328
|
-
assert 'config' in data
|
|
329
|
-
assert 'eda_original_args' in data['config']
|
|
330
|
-
assert 'oclib_fifo.sv' in data['config']['eda_original_args']
|
|
331
|
-
assert 'all_pkg' in data['config']['eda_original_args']
|
|
332
|
-
assert 'oclib_ram1r1w' in data['config']['eda_original_args']
|
|
333
|
-
assert data.get('target', '') == 'oclib_fifo'
|
|
334
|
-
|
|
335
|
-
def test_elab_verilator_no_deps_files_involved_should_fail(self):
|
|
336
|
-
'''Test using no DEPS file on file that doesn't exist.'''
|
|
337
|
-
chdir_remove_work_dir('../../lib')
|
|
338
|
-
# pick some non-existent file oclib_doesnt_exist.nope.sv
|
|
339
|
-
cmd_list = 'elab --tool verilator +incdir+.. oclib_doesnt_exist.nope.sv'.split()
|
|
340
|
-
cmd_list +=' oclib_assert_pkg.sv oclib_pkg.sv oclib_fifo.sv'.split()
|
|
341
|
-
rc = eda.main(*cmd_list)
|
|
342
|
-
print(f'{rc=}')
|
|
343
|
-
assert rc > 1
|
|
344
|
-
|
|
345
|
-
def test_config_reduced_yml(self):
|
|
346
|
-
'''Test using provided EDA --config-yml=eda_config_reduced.yml, confirm installed w/ pip'''
|
|
347
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
348
|
-
rc = eda_sim_wrap('--config-yml', 'eda_config_reduced.yml', '--tool', 'verilator',
|
|
349
|
-
'oclib_fifo_test')
|
|
350
|
-
print(f'{rc=}')
|
|
351
|
-
assert rc == 0
|
|
352
|
-
|
|
353
|
-
def test_config_max_verilator_waivers_yml(self):
|
|
354
|
-
'''Test using provided EDA --config-yml, confirm installed w/ pip'''
|
|
355
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
356
|
-
rc = eda_sim_wrap('--config-yml', 'eda_config_max_verilator_waivers.yml', '--tool',
|
|
357
|
-
'verilator', 'oclib_fifo_test')
|
|
358
|
-
print(f'{rc=}')
|
|
359
|
-
assert rc == 0
|
|
360
|
-
|
|
361
|
-
def test_config_yml_custom(self):
|
|
362
|
-
'''Test using user-custom --config-yml arg'''
|
|
363
|
-
chdir_remove_work_dir('../../lib/tests')
|
|
364
|
-
rc = eda_sim_wrap('--config-yml', '../../opencos/tests/custom_config.yml', '--tool',
|
|
365
|
-
'verilator', 'oclib_fifo_test')
|
|
366
|
-
print(f'{rc=}')
|
|
367
|
-
assert rc == 0
|
|
368
|
-
eda_config_yml_path = os.path.join(os.getcwd(), 'eda.work', 'oclib_fifo_test.sim',
|
|
369
|
-
'eda_output_config.yml')
|
|
370
|
-
data = yaml_safe_load(eda_config_yml_path)
|
|
371
|
-
# make sure this config was actually used. We no longer re-add it to args
|
|
372
|
-
# (it won't show up in 'original_args') it will will show up in the config though:
|
|
373
|
-
used_yml_fname = data['config']['config-yml']
|
|
374
|
-
assert used_yml_fname.endswith('opencos/tests/custom_config.yml')
|
|
375
|
-
# this config overrides a value to False:
|
|
376
|
-
assert 'config' in data
|
|
377
|
-
local_config = data['config']
|
|
378
|
-
assert local_config['dep_command_enables']['shell'] is False
|
|
379
|
-
|
|
380
|
-
def test_verilator_rtl_missing_dumpfile_fst(self):
|
|
381
|
-
'''test for eda with --waves, on RTL that has no $dumpfile,
|
|
382
|
-
and we should auto-add _waves_pkg.sv with dump.fst'''
|
|
383
|
-
|
|
384
|
-
chdir_remove_work_dir('./deps_files/test_deps_noext')
|
|
385
|
-
rc = eda_wrap('sim', '--tool', 'verilator', '--waves', 'target_test')
|
|
386
|
-
print(f'{rc=}')
|
|
387
|
-
assert rc == 0
|
|
388
|
-
|
|
389
|
-
assert not os.path.exists(
|
|
390
|
-
os.path.join(os.getcwd(), 'eda.work', 'target_test.sim', 'dump.vcd')
|
|
391
|
-
)
|
|
392
|
-
assert os.path.exists(
|
|
393
|
-
os.path.join(os.getcwd(), 'eda.work', 'target_test.sim', 'dump.fst')
|
|
394
|
-
)
|
|
395
|
-
|
|
396
|
-
def test_verilator_rtl_missing_dumpfile_vcd(self):
|
|
397
|
-
'''test for eda with --waves, on RTL that has no $dumpfile,
|
|
398
|
-
and we should auto-add _waves_pkg.sv with dump.vcd'''
|
|
399
|
-
|
|
400
|
-
chdir_remove_work_dir('./deps_files/test_deps_noext')
|
|
401
|
-
rc = eda_wrap('sim', '--tool', 'verilator', '--waves', '+trace=vcd', 'target_test')
|
|
402
|
-
print(f'{rc=}')
|
|
403
|
-
assert rc == 0
|
|
404
|
-
|
|
405
|
-
assert os.path.exists(
|
|
406
|
-
os.path.join(os.getcwd(), 'eda.work', 'target_test.sim', 'dump.vcd')
|
|
407
|
-
)
|
|
408
|
-
assert not os.path.exists(
|
|
409
|
-
os.path.join(os.getcwd(), 'eda.work', 'target_test.sim', 'dump.fst')
|
|
410
|
-
)
|
|
411
|
-
|
|
412
|
-
def test_verilator_rtl_missing_dumpfile_none(self):
|
|
413
|
-
'''test for eda with NO --waves, on RTL that has no $dumpfile,
|
|
414
|
-
and we should see no auto-added _waves_pkg.sv and no dump.[vcd|fst]'''
|
|
415
|
-
|
|
416
|
-
chdir_remove_work_dir('./deps_files/test_deps_noext')
|
|
417
|
-
rc = eda_wrap('sim', '--tool', 'verilator', 'target_test')
|
|
418
|
-
print(f'{rc=}')
|
|
419
|
-
assert rc == 0
|
|
420
|
-
|
|
421
|
-
assert not os.path.exists(
|
|
422
|
-
os.path.join(os.getcwd(), 'eda.work', 'target_test.sim', 'dump.vcd')
|
|
423
|
-
)
|
|
424
|
-
assert not os.path.exists(
|
|
425
|
-
os.path.join(os.getcwd(), 'eda.work', 'target_test.sim', 'dump.fst')
|
|
426
|
-
)
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
class TestMissingDepsFileErrorMessages(Helpers):
|
|
430
|
-
'''Test for missing DEPS.yml file, using 'eda export' to avoid tools.'''
|
|
431
|
-
DEFAULT_DIR = os.path.join(THISPATH, 'deps_files', 'no_deps_here', 'empty')
|
|
432
|
-
|
|
433
|
-
def test_bad0(self):
|
|
434
|
-
'''Looks for target_bad0, but there is no DEPS file in .'''
|
|
435
|
-
self.chdir()
|
|
436
|
-
rc = self.log_it(command_str='export target_bad0')
|
|
437
|
-
assert rc > 1
|
|
438
|
-
assert self.is_in_log(
|
|
439
|
-
'Trying to resolve command-line target=./target_bad0:'
|
|
440
|
-
' but path ./ has no DEPS markup file',
|
|
441
|
-
windows_path_support=True
|
|
442
|
-
)
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
class TestDepsResolveErrorMessages(Helpers):
|
|
446
|
-
'''Tests to check that error messaging with DEPS.yml works as expected.
|
|
447
|
-
|
|
448
|
-
If this was not checked, we could have failing tests that produce a stacktrace
|
|
449
|
-
or other less helpful information to the user. This confirms that file/target/
|
|
450
|
-
linenumber information is printed when available.'''
|
|
451
|
-
|
|
452
|
-
DEFAULT_DIR = os.path.join(THISPATH, 'deps_files', 'error_msgs')
|
|
453
|
-
|
|
454
|
-
# files foo.sv, foo2.sv, target_bad0.sv, and target_bad1.sv exist.
|
|
455
|
-
# files missing*.sv and targets missing* do not exist.
|
|
456
|
-
# These all "export" targets, to avoid requiring an installed tool (for example, to elab)
|
|
457
|
-
|
|
458
|
-
def test_good0(self):
|
|
459
|
-
'''Simple test with good target (foo)'''
|
|
460
|
-
self.chdir()
|
|
461
|
-
rc = self.log_it('export foo')
|
|
462
|
-
assert rc == 0
|
|
463
|
-
|
|
464
|
-
def test_good1(self):
|
|
465
|
-
'''Simple test with good target (foo2)'''
|
|
466
|
-
self.chdir()
|
|
467
|
-
rc = self.log_it('export foo2')
|
|
468
|
-
assert rc == 0
|
|
469
|
-
|
|
470
|
-
def test_good2(self):
|
|
471
|
-
'''Simple test with good target (foo + top=foo using deps str)'''
|
|
472
|
-
self.chdir()
|
|
473
|
-
rc = self.log_it('export target_good2')
|
|
474
|
-
assert rc == 0
|
|
475
|
-
|
|
476
|
-
def test_good3(self):
|
|
477
|
-
'''Simple test with good target (foo2 + top=foo2 using deps list)'''
|
|
478
|
-
self.chdir()
|
|
479
|
-
rc = self.log_it('export target_good3')
|
|
480
|
-
assert rc == 0
|
|
481
|
-
|
|
482
|
-
# Bit of a change-detector-test here, but I want to make sure the
|
|
483
|
-
# line= numbers get reported correctly for the calling target.
|
|
484
|
-
def test_bad0(self):
|
|
485
|
-
'''Tests missing file in DEPS target using implicit deps str style'''
|
|
486
|
-
self.chdir()
|
|
487
|
-
rc = self.log_it(command_str='export target_bad0')
|
|
488
|
-
assert rc > 1
|
|
489
|
-
assert self.is_in_log(
|
|
490
|
-
"target=./missing0.sv (file?): called from ./DEPS.yml::target_bad0::line=20,",
|
|
491
|
-
"File=missing0.sv not found in directory=.",
|
|
492
|
-
windows_path_support=True
|
|
493
|
-
)
|
|
494
|
-
|
|
495
|
-
def test_bad1(self):
|
|
496
|
-
'''Tests missing file in DEPS target using implicit deps list style'''
|
|
497
|
-
self.chdir()
|
|
498
|
-
rc = self.log_it(command_str='export target_bad1')
|
|
499
|
-
assert rc > 1
|
|
500
|
-
assert self.is_in_log(
|
|
501
|
-
"target=./missing1.sv (file?): called from ./DEPS.yml::target_bad1::line=24,",
|
|
502
|
-
"File=missing1.sv not found in directory=.",
|
|
503
|
-
windows_path_support=True
|
|
504
|
-
)
|
|
505
|
-
|
|
506
|
-
def test_bad2(self):
|
|
507
|
-
'''Tests missing file in DEPS target using deps as str style'''
|
|
508
|
-
self.chdir()
|
|
509
|
-
rc = self.log_it(command_str='export target_bad2')
|
|
510
|
-
assert rc > 1
|
|
511
|
-
assert self.is_in_log(
|
|
512
|
-
"target=./missing2.sv (file?): called from ./DEPS.yml::target_bad2::line=28,",
|
|
513
|
-
"File=missing2.sv not found in directory=.",
|
|
514
|
-
windows_path_support=True
|
|
515
|
-
)
|
|
516
|
-
|
|
517
|
-
def test_bad3(self):
|
|
518
|
-
'''Tests missing file in DEPS target using deps as list style'''
|
|
519
|
-
self.chdir()
|
|
520
|
-
rc = self.log_it(command_str='export target_bad3')
|
|
521
|
-
assert rc > 1
|
|
522
|
-
assert self.is_in_log(
|
|
523
|
-
"target=./missing3.sv (file?): called from ./DEPS.yml::target_bad3::line=33,",
|
|
524
|
-
"File=missing3.sv not found in directory=.",
|
|
525
|
-
windows_path_support=True
|
|
526
|
-
)
|
|
527
|
-
|
|
528
|
-
def test_bad4(self):
|
|
529
|
-
'''EDA on a bad target (bad target within deps of 'target_bad4'), explicit deps str'''
|
|
530
|
-
self.chdir()
|
|
531
|
-
rc = self.log_it(command_str='export target_bad4')
|
|
532
|
-
assert rc > 1
|
|
533
|
-
assert self.is_in_log(
|
|
534
|
-
"target=./missing_target4: called from ./DEPS.yml::target_bad4::line=39,",
|
|
535
|
-
"Target not found in deps_file=./DEPS.yml",
|
|
536
|
-
windows_path_support=True
|
|
537
|
-
)
|
|
538
|
-
|
|
539
|
-
def test_bad5(self):
|
|
540
|
-
'''EDA on a bad target (bad target within deps of 'target_bad4'), explicit deps list'''
|
|
541
|
-
self.chdir()
|
|
542
|
-
rc = self.log_it(command_str='export target_bad5')
|
|
543
|
-
assert rc > 1
|
|
544
|
-
assert self.is_in_log(
|
|
545
|
-
"target=./missing_target5: called from ./DEPS.yml::target_bad5::line=43,",
|
|
546
|
-
"Target not found in deps_file=./DEPS.yml",
|
|
547
|
-
windows_path_support=True
|
|
548
|
-
)
|
|
549
|
-
|
|
550
|
-
def test_bad6(self):
|
|
551
|
-
'''EDA on a bad target (bad target within deps of 'target_bad4'), deps str'''
|
|
552
|
-
self.chdir()
|
|
553
|
-
rc = self.log_it(command_str='export target_bad6')
|
|
554
|
-
assert rc > 1
|
|
555
|
-
assert self.is_in_log(
|
|
556
|
-
"target=./missing_target6: called from ./DEPS.yml::target_bad6::line=47,",
|
|
557
|
-
"Target not found in deps_file=./DEPS.yml",
|
|
558
|
-
windows_path_support=True
|
|
559
|
-
|
|
560
|
-
)
|
|
561
|
-
|
|
562
|
-
def test_bad7(self):
|
|
563
|
-
'''EDA on a bad target (bad target within deps of 'target_bad4'), deps list'''
|
|
564
|
-
self.chdir()
|
|
565
|
-
rc = self.log_it(command_str='export target_bad7')
|
|
566
|
-
assert rc > 1
|
|
567
|
-
assert self.is_in_log(
|
|
568
|
-
"target=./missing_target7: called from ./DEPS.yml::target_bad7::line=52,",
|
|
569
|
-
"Target not found in deps_file=./DEPS.yml",
|
|
570
|
-
windows_path_support=True
|
|
571
|
-
)
|
|
572
|
-
|
|
573
|
-
def test_cmd_line_good0(self):
|
|
574
|
-
'''EDA w/ out DEPS, on file'''
|
|
575
|
-
self.chdir()
|
|
576
|
-
rc = self.log_it(command_str='export foo.sv')
|
|
577
|
-
assert rc == 0
|
|
578
|
-
|
|
579
|
-
def test_cmd_line_good1(self):
|
|
580
|
-
'''EDA w/ out DEPS, on two files'''
|
|
581
|
-
self.chdir()
|
|
582
|
-
rc = self.log_it(command_str='export foo.sv foo2.sv')
|
|
583
|
-
assert rc == 0
|
|
584
|
-
|
|
585
|
-
def test_cmd_line_bad0(self):
|
|
586
|
-
'''EDA calling a non-existent target in DEPS file'''
|
|
587
|
-
self.chdir()
|
|
588
|
-
rc = self.log_it(command_str='export nope_target0')
|
|
589
|
-
assert rc > 1
|
|
590
|
-
assert self.is_in_log(
|
|
591
|
-
"Trying to resolve command-line target=./nope_target0: was not",
|
|
592
|
-
"found in deps_file=./DEPS.yml",
|
|
593
|
-
windows_path_support=True
|
|
594
|
-
)
|
|
595
|
-
assert self.is_in_log(
|
|
596
|
-
"Targets available in deps_file=./DEPS.yml:",
|
|
597
|
-
windows_path_support=True
|
|
598
|
-
)
|
|
599
|
-
assert self.is_in_log(" foo")
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
def test_cmd_line_bad1(self):
|
|
603
|
-
'''EDA calling a non-existent target in DEPS file, with file that exists.'''
|
|
604
|
-
self.chdir()
|
|
605
|
-
rc = self.log_it(command_str='export foo.sv nope_target1')
|
|
606
|
-
assert rc > 1
|
|
607
|
-
assert self.is_in_log(
|
|
608
|
-
"Trying to resolve command-line target=./nope_target1: was not",
|
|
609
|
-
"found in deps_file=./DEPS.yml",
|
|
610
|
-
windows_path_support=True
|
|
611
|
-
)
|
|
612
|
-
assert self.is_in_log(
|
|
613
|
-
"Targets available in deps_file=./DEPS.yml:",
|
|
614
|
-
windows_path_support=True
|
|
615
|
-
)
|
|
616
|
-
assert self.is_in_log(" foo")
|
|
617
|
-
|
|
618
|
-
def test_cmd_line_bad2(self):
|
|
619
|
-
'''EDA calling a non-existent file w/out DEPS'''
|
|
620
|
-
self.chdir()
|
|
621
|
-
rc = self.log_it(command_str='export nope_file0.sv')
|
|
622
|
-
assert rc > 1
|
|
623
|
-
assert self.is_in_log(
|
|
624
|
-
"Trying to resolve command-line target=./nope_file0.sv",
|
|
625
|
-
"(file?): File=nope_file0.sv not found in directory=.",
|
|
626
|
-
windows_path_support=True
|
|
627
|
-
)
|
|
628
|
-
|
|
629
|
-
def test_cmd_line_bad3(self):
|
|
630
|
-
'''EDA calling a non-existent file w/out DEPS, and a file that does exist.'''
|
|
631
|
-
self.chdir()
|
|
632
|
-
rc = self.log_it(command_str='export foo2.sv nope_file1.sv')
|
|
633
|
-
assert rc > 1
|
|
634
|
-
assert self.is_in_log(
|
|
635
|
-
"Trying to resolve command-line target=./nope_file1.sv",
|
|
636
|
-
"(file?): File=nope_file1.sv not found in directory=.",
|
|
637
|
-
windows_path_support=True
|
|
638
|
-
)
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
@pytest.mark.skipif('iverilog' not in tools_loaded, reason="requires iverilog")
|
|
642
|
-
class TestsRequiresIVerilog(Helpers):
|
|
643
|
-
'''Test for Icarus Verilog'''
|
|
644
|
-
|
|
645
|
-
def test_iverilog_help(self):
|
|
646
|
-
'''Test for help'''
|
|
647
|
-
rc = self.log_it('sim --tool iverilog help', use_eda_wrap=False)
|
|
648
|
-
print(f'{rc=}')
|
|
649
|
-
assert rc == 0
|
|
650
|
-
assert self.is_in_log('Detected iverilog')
|
|
651
|
-
assert self.is_in_log("Generic help for command=sim tool=iverilog")
|
|
652
|
-
|
|
653
|
-
def test_iverilog_sim(self):
|
|
654
|
-
'''Test for command sim'''
|
|
655
|
-
chdir_remove_work_dir('deps_files/iverilog_test')
|
|
656
|
-
cmd_list = 'sim --tool iverilog target_test'.split()
|
|
657
|
-
rc = eda.main(*cmd_list)
|
|
658
|
-
print(f'{rc=}')
|
|
659
|
-
assert rc == 0
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
@pytest.mark.skipif(not can_run_eda_sim(), reason='no tool found to handle command: sim')
|
|
663
|
-
class TestArgs(Helpers):
|
|
664
|
-
'''Test some args features, needs a sim tool'''
|
|
665
|
-
DEFAULT_DIR = os.path.join(THISPATH, '..', '..', 'lib', 'tests')
|
|
666
|
-
|
|
667
|
-
def test_duplicate_args(self):
|
|
668
|
-
'''Use oclib_fifo_test to make sure we don't lose (do NOT uniquify) duplicate
|
|
669
|
-
list-style args'''
|
|
670
|
-
self.chdir()
|
|
671
|
-
rc = self.log_it(
|
|
672
|
-
'sim --stop-before-compile oclib_fifo_test --compile-args=-hi --compile-args=-hi',
|
|
673
|
-
use_eda_wrap=False
|
|
674
|
-
)
|
|
675
|
-
assert rc == 0
|
|
676
|
-
# Confirm we have two args in self.args['compile-args'] for: -hi
|
|
677
|
-
eda_config_yml_path = os.path.join(
|
|
678
|
-
os.getcwd(), 'eda.work', 'oclib_fifo_test.sim', 'eda_output_config.yml'
|
|
679
|
-
)
|
|
680
|
-
data = yaml_safe_load(eda_config_yml_path)
|
|
681
|
-
assert 'args' in data
|
|
682
|
-
assert 'compile-args' in data['args']
|
|
683
|
-
assert len(data['args']['compile-args']) == 2
|
|
684
|
-
assert data['args']['compile-args'] == ['-hi', '-hi']
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
@pytest.mark.skipif(not can_run_eda_sim(), reason='no tool found to handle command: sim')
|
|
688
|
-
class TestDepsReqs:
|
|
689
|
-
'''Tests for 'reqs' in the DEPS files. 'reqs' are requirements, like a .pcap or file
|
|
690
|
-
used by SV $readmemh. They do not fit into normal compilable files (.sv, .v, .vhd[l])
|
|
691
|
-
but are needed for export (command) and --export* (args on non-export command).'''
|
|
692
|
-
|
|
693
|
-
def test_deps_reqs(self):
|
|
694
|
-
'''Basic test using a .mem file in the 'deps' section of a target '''
|
|
695
|
-
chdir_remove_work_dir('deps_files/non_sv_reqs')
|
|
696
|
-
cmd_list = 'sim foo_test'.split()
|
|
697
|
-
rc = eda.main(*cmd_list)
|
|
698
|
-
assert rc == 0
|
|
699
|
-
|
|
700
|
-
def test_deps_reqs2(self):
|
|
701
|
-
'''Basic test using a .mem file in the 'reqs' section of a target'''
|
|
702
|
-
chdir_remove_work_dir('deps_files/non_sv_reqs')
|
|
703
|
-
cmd_list = 'sim foo_test2'.split()
|
|
704
|
-
rc = eda.main(*cmd_list)
|
|
705
|
-
assert rc == 0
|
|
706
|
-
|
|
707
|
-
def test_deps_reqs3(self):
|
|
708
|
-
'''Basic test using a .svh file in the 'reqs' section of a target'''
|
|
709
|
-
chdir_remove_work_dir('deps_files/non_sv_reqs')
|
|
710
|
-
cmd_list = 'sim foo_test3'.split()
|
|
711
|
-
rc = eda.main(*cmd_list)
|
|
712
|
-
assert rc == 0
|
|
713
|
-
|
|
714
|
-
def test_deps_reqs4(self):
|
|
715
|
-
'''Basic test using a .svh file with just incdirs (no reqs).'''
|
|
716
|
-
chdir_remove_work_dir('deps_files/non_sv_reqs')
|
|
717
|
-
cmd_list = 'sim foo_test4'.split()
|
|
718
|
-
rc = eda.main(*cmd_list)
|
|
719
|
-
assert rc == 0
|
|
720
|
-
|
|
721
|
-
def test_deps_reqs5(self):
|
|
722
|
-
'''Test that should fail due to reqs (bad file in reqs section)'''
|
|
723
|
-
chdir_remove_work_dir('deps_files/non_sv_reqs')
|
|
724
|
-
cmd_list = 'sim should_fail_foo_test5'.split()
|
|
725
|
-
rc = eda.main(*cmd_list)
|
|
726
|
-
assert rc > 1
|
|
727
|
-
|
|
728
|
-
def test_deps_reqs6(self):
|
|
729
|
-
'''Test that should fail due bad file in deps section (none in reqs)'''
|
|
730
|
-
chdir_remove_work_dir('deps_files/non_sv_reqs')
|
|
731
|
-
cmd_list = 'sim should_fail_foo_test6'.split()
|
|
732
|
-
rc = eda.main(*cmd_list)
|
|
733
|
-
assert rc > 1
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
@pytest.mark.skipif('verilator' not in tools_loaded, reason="requires verilator")
|
|
738
|
-
class TestDepsOtherMarkup:
|
|
739
|
-
'''Tests for DEPS files that aren't YAML file extension.'''
|
|
740
|
-
|
|
741
|
-
def test_deps_toml(self):
|
|
742
|
-
'''test for DEPS.toml'''
|
|
743
|
-
chdir_remove_work_dir('./deps_files/test_deps_toml')
|
|
744
|
-
rc = eda_wrap('sim', '--tool', 'verilator', 'target_test')
|
|
745
|
-
print(f'{rc=}')
|
|
746
|
-
assert rc == 0
|
|
747
|
-
|
|
748
|
-
def test_deps_json(self):
|
|
749
|
-
'''test for DEPS.json'''
|
|
750
|
-
chdir_remove_work_dir('./deps_files/test_deps_json')
|
|
751
|
-
rc = eda_wrap('sim', '--tool', 'verilator', 'target_test')
|
|
752
|
-
print(f'{rc=}')
|
|
753
|
-
assert rc == 0
|
|
754
|
-
|
|
755
|
-
def test_deps_no_extension(self):
|
|
756
|
-
'''test for DEPS, which is treated as YAML'''
|
|
757
|
-
chdir_remove_work_dir('./deps_files/test_deps_noext')
|
|
758
|
-
rc = eda_wrap('sim', '--tool', 'verilator', 'target_test')
|
|
759
|
-
print(f'{rc=}')
|
|
760
|
-
assert rc == 0
|
|
761
|
-
|
|
762
|
-
@pytest.mark.skipif('verilator' not in tools_loaded, reason="requires verilator")
|
|
763
|
-
class TestForceFileExt(Helpers):
|
|
764
|
-
'''Tests for treating non .sv files (.txt) as SV using sv@<file>'''
|
|
765
|
-
|
|
766
|
-
def test_sv_at(self):
|
|
767
|
-
'''test for file as sv@<file>'''
|
|
768
|
-
chdir_remove_work_dir('./deps_files/force_file_ext')
|
|
769
|
-
rc = self.log_it('sim --tool verilator sv@foo.txt')
|
|
770
|
-
assert rc == 0
|
|
771
|
-
assert self.is_in_log("force_file_ext/foo.txt:6: Verilog $finish")
|
|
772
|
-
|
|
773
|
-
def test_v_at(self):
|
|
774
|
-
'''test for file as v@<file>'''
|
|
775
|
-
chdir_remove_work_dir('./deps_files/force_file_ext')
|
|
776
|
-
rc = self.log_it('sim --tool verilator v@foo.txt')
|
|
777
|
-
assert rc == 0
|
|
778
|
-
assert self.is_in_log("force_file_ext/foo.txt:6: Verilog $finish")
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
@pytest.mark.skipif('verilator' not in tools_loaded, reason="requires verilator")
|
|
782
|
-
class TestDepsNoFilesTargets(Helpers):
|
|
783
|
-
'''series of tests for running EDA w/out a DEPS target, all CLI files.'''
|
|
784
|
-
|
|
785
|
-
def test_eda_sim__use_implicit_one_target(self):
|
|
786
|
-
'''This test should work if the DEPS markup has a single target only'''
|
|
787
|
-
# Using this b/c DEPS.toml has single target.
|
|
788
|
-
chdir_remove_work_dir('./deps_files/test_deps_toml')
|
|
789
|
-
rc = self.log_it('sim --tool verilator')
|
|
790
|
-
assert rc == 0
|
|
791
|
-
# Confirm the 'target_test' was used.
|
|
792
|
-
assert self.is_in_log("using 'target_test' from")
|
|
793
|
-
exec_lines = self.get_log_lines_with('exec: ')
|
|
794
|
-
assert 'verilator ' in exec_lines[0]
|
|
795
|
-
assert self.is_in_log("test_deps_toml/foo.sv:6: Verilog $finish")
|
|
796
|
-
|
|
797
|
-
def test_eda_sim__wrong_target_shouldfail(self):
|
|
798
|
-
'''This test should fail, wrong target name'''
|
|
799
|
-
# Using this b/c DEPS.toml has single target.
|
|
800
|
-
chdir_remove_work_dir('./deps_files/test_deps_toml')
|
|
801
|
-
rc = eda_wrap('sim', '--tool', 'verilator', 'target_whoops')
|
|
802
|
-
assert rc > 1
|
|
803
|
-
|
|
804
|
-
def test_eda_sim__no_files_or_targets_shouldfail(self):
|
|
805
|
-
'''This test should fail, there is DEPS.yml (empty, no implicit target), or missing file'''
|
|
806
|
-
chdir_remove_work_dir('./deps_files/no_deps_here')
|
|
807
|
-
rc = eda_wrap('sim', '--tool', 'verilator')
|
|
808
|
-
assert rc > 1
|
|
809
|
-
|
|
810
|
-
def test_eda_sim__no_files_or_targets_with_top_shouldfail(self):
|
|
811
|
-
'''This test should fail, there is DEPS.yml (empty, no implicit target), or missing file'''
|
|
812
|
-
chdir_remove_work_dir('./deps_files/no_deps_here')
|
|
813
|
-
rc = eda_wrap('sim', '--tool', 'verilator', '--top', 'empty_file')
|
|
814
|
-
assert rc > 1
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
class TestDepsTags(Helpers):
|
|
818
|
-
'''Series of tests for DEPS - target - tags, in ./deps_files/tags_with_tools'''
|
|
819
|
-
DEFAULT_DIR = os.path.join(THISPATH, 'deps_files', 'tags_with_tools')
|
|
820
|
-
|
|
821
|
-
@pytest.mark.skipif('verilator' not in tools_loaded, reason="requires verilator")
|
|
822
|
-
def test_tags_with_tools_verilator(self):
|
|
823
|
-
'''test for DEPS target that hits with-tools: verilator, so that
|
|
824
|
-
additional args are applied from the DEPS tag.'''
|
|
825
|
-
self.chdir()
|
|
826
|
-
logfile = '.pytest.verilator_eda.log'
|
|
827
|
-
rc = self.log_it('sim --tool verilator target_test', logfile=logfile)
|
|
828
|
-
assert rc == 0
|
|
829
|
-
|
|
830
|
-
# so the full sim should have not run
|
|
831
|
-
exec_lines = self.get_log_lines_with('exec: ', logfile=logfile)
|
|
832
|
-
assert len(exec_lines) == 1, \
|
|
833
|
-
f'{exec_lines=} should have only been the compile --lint-only'
|
|
834
|
-
assert 'exec: ' in exec_lines[0] and 'verilator ' in exec_lines[0], \
|
|
835
|
-
f'{exec_lines[0]=} should have been verilator compile'
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
@pytest.mark.skipif('verilator' not in tools_loaded, reason="requires verilator")
|
|
839
|
-
def test_tags_with_tools_replace_config_tools_verilator(self):
|
|
840
|
-
'''test for DEPS target with tags that perfoms replacement config.
|
|
841
|
-
|
|
842
|
-
AKA, lets you replace all the Verilator waivers to the DEPS target that only affect
|
|
843
|
-
with-tools: verilator'''
|
|
844
|
-
self.chdir()
|
|
845
|
-
logfile = '.pytest.target_with_replace_config_tools_test.log'
|
|
846
|
-
rc = self.log_it('sim --tool verilator target_with_replace_config_tools_test',
|
|
847
|
-
logfile=logfile)
|
|
848
|
-
assert rc == 0
|
|
849
|
-
# This target overrode all the Verilator waivers to nothing, so
|
|
850
|
-
# we should see zero -Wno- in the log for verilator exec lines.
|
|
851
|
-
exec_lines = self.get_log_lines_with('exec: ', logfile=logfile)
|
|
852
|
-
assert len(exec_lines) == 2
|
|
853
|
-
assert not '-Wno-' in exec_lines[0], f'-Wno- expected to be in one of: {exec_lines=}'
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
@pytest.mark.skipif('verilator' not in tools_loaded, reason="requires verilator")
|
|
857
|
-
def test_tags_with_tools_additive_config_tools_verilator(self):
|
|
858
|
-
'''test for DEPS target with tags that perfoms additive config.
|
|
859
|
-
|
|
860
|
-
AKA, lets you add Verilator waivers to the DEPS target that only affect
|
|
861
|
-
with-tools: verilator'''
|
|
862
|
-
self.chdir()
|
|
863
|
-
logfile = '.pytest.target_with_additive_config_tools_test.log'
|
|
864
|
-
rc = self.log_it('sim --tool verilator --debug target_with_additive_config_tools_test',
|
|
865
|
-
logfile=logfile)
|
|
866
|
-
assert rc == 0
|
|
867
|
-
# This target added to the Verilator waivers -Wno-style, -Wno-fatal,
|
|
868
|
-
# but the defaults should also be there (at least -Wno-UNSIGNED)
|
|
869
|
-
waivers = self.get_log_words_with('-Wno-', logfile=logfile)
|
|
870
|
-
assert '-Wno-style' in waivers
|
|
871
|
-
assert '-Wno-fatal' in waivers
|
|
872
|
-
assert '-Wno-UNSIGNED' in waivers
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
@pytest.mark.skipif('vivado' not in tools_loaded, reason="requires vivado")
|
|
876
|
-
def test_tags_with_tools_vivado(self):
|
|
877
|
-
'''test for DEPS target with tag using with-tools: verilator
|
|
878
|
-
|
|
879
|
-
Since we're running --tool=vivado (not verilator) this should not
|
|
880
|
-
apply the arg --lint-only in the DEPS tag, and instead run the
|
|
881
|
-
full simulation.'''
|
|
882
|
-
self.chdir()
|
|
883
|
-
logfile = '.pytest.vivado_eda.log'
|
|
884
|
-
rc = self.log_it('sim --tool vivado target_test', logfile=logfile)
|
|
885
|
-
assert rc == 0
|
|
886
|
-
|
|
887
|
-
# make sure the tag wasn't applied (should only be applied in verilator)
|
|
888
|
-
# so the full sim should have run (xvlog, xelab, xsim) (--lint-only not applied,
|
|
889
|
-
# b/c that should only apply in 'verilator' for this target.)
|
|
890
|
-
exec_lines = self.get_log_lines_with('exec: ', logfile=logfile)
|
|
891
|
-
assert len(exec_lines) == 3
|
|
892
|
-
assert 'xvlog' in exec_lines[0]
|
|
893
|
-
assert 'xelab' in exec_lines[1]
|
|
894
|
-
assert 'xsim' in exec_lines[2]
|
|
895
|
-
assert not self.is_in_log('--lint-only', logfile=logfile)
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
@pytest.mark.skipif('verilator' not in tools_loaded, reason="requires verilator")
|
|
899
|
-
def test_tags_with_tools_add_incdirs(self):
|
|
900
|
-
'''test for DEPS target with tag that adds incdirs'''
|
|
901
|
-
self.chdir()
|
|
902
|
-
logfile = '.pytest.target_foo_sv_add_incdirs.log'
|
|
903
|
-
rc = self.log_it('elab --tool verilator target_foo_sv_add_incdirs',
|
|
904
|
-
logfile=logfile)
|
|
905
|
-
assert rc == 0
|
|
906
|
-
# This target added . to incdirs in the DEPS.yml dir.
|
|
907
|
-
|
|
908
|
-
incdirs = self.get_log_words_with('+incdir+', logfile=logfile)
|
|
909
|
-
assert len(incdirs) == 1 # should only have 1
|
|
910
|
-
assert 'tests/deps_files/tags_with_tools' in incdirs[0]
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
@pytest.mark.skipif('verilator' not in tools_loaded, reason="requires verilator")
|
|
914
|
-
def test_tags_with_tools_add_defines(self):
|
|
915
|
-
'''test for DEPS target with tag that adds defines'''
|
|
916
|
-
self.chdir()
|
|
917
|
-
logfile = '.pytest.target_foo_sv_add_defines.log'
|
|
918
|
-
rc = self.log_it('elab --tool verilator --debug target_foo_sv_add_defines',
|
|
919
|
-
logfile=logfile)
|
|
920
|
-
assert rc == 0
|
|
921
|
-
assert self.is_in_log('+define+FOO_SV=3000', logfile=logfile)
|