Skip to content

Commit

Permalink
Add VCS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
olofk committed Feb 16, 2019
1 parent 85bfa21 commit 1b41f42
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/mock_commands/vcs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python
import os
import sys

output_file = sys.argv[sys.argv.index('-o')+1]

with open(output_file, 'w') as f:
s = """#!/usr/bin/env python
import sys
with open('run.cmd', 'w') as f:
f.write(' '.join(sys.argv[1:]) + '\\n')
"""
f.write(s)
os.chmod(output_file, 0o755)

with open('vcs.cmd', 'w') as f:
f.write(' '.join(sys.argv[1:]) + '\n')
62 changes: 62 additions & 0 deletions tests/test_vcs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import pytest

def test_vcs2():
import os
import shutil
from edalize_common import compare_files, setup_backend, tests_dir

ref_dir = os.path.join(tests_dir, __name__)
paramtypes = ['plusarg', 'vlogdefine', 'vlogparam']
name = 'test_vcs_0'
tool = 'vcs'
tool_options = {}
# tool_options = {
# 'iverilog_options' : ['some', 'iverilog_options'],
# 'timescale' : '1ns/1ns',
# }

(backend, args, work_root) = setup_backend(paramtypes, name, tool, tool_options, use_vpi=False)
backend.configure(args)

compare_files(ref_dir, work_root, ['Makefile',
name+'.scr',
])

backend.build()
compare_files(ref_dir, work_root, ['vcs.cmd'])

backend.run(args)

compare_files(ref_dir, work_root, ['run.cmd'])

def test_vcs_minimal():
import os
import shutil
import tempfile

from edalize import get_edatool

from edalize_common import compare_files, tests_dir

ref_dir = os.path.join(tests_dir, __name__, 'minimal')
os.environ['PATH'] = os.path.join(tests_dir, 'mock_commands')+':'+os.environ['PATH']
tool = 'vcs'
name = 'test_'+tool+'_minimal_0'
work_root = tempfile.mkdtemp(prefix=tool+'_')

edam = {'name' : name,
'toplevel' : 'top'}

backend = get_edatool(tool)(edam=edam, work_root=work_root)
backend.configure([])

compare_files(ref_dir, work_root, ['Makefile',
name+'.scr',
])

backend.build()
compare_files(ref_dir, work_root, ['vcs.cmd'])

backend.run([])

compare_files(ref_dir, work_root, ['run.cmd'])
8 changes: 8 additions & 0 deletions tests/test_vcs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
all: test_vcs_0

test_vcs_0: test_vcs_0.scr
vcs -full64 -t top_module -f test_vcs_0.scr -o $@
run: test_vcs_0
./test_vcs_0 -l vcs.log +plusarg_bool=1 +plusarg_int=42 +plusarg_str=hello
clean:
$(RM) test_vcs_0
8 changes: 8 additions & 0 deletions tests/test_vcs/minimal/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
all: test_vcs_minimal_0

test_vcs_minimal_0: test_vcs_minimal_0.scr
vcs -full64 -t top -f test_vcs_minimal_0.scr -o $@
run: test_vcs_minimal_0
./test_vcs_minimal_0 -l vcs.log
clean:
$(RM) test_vcs_minimal_0
1 change: 1 addition & 0 deletions tests/test_vcs/minimal/run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-l vcs.log
Empty file.
1 change: 1 addition & 0 deletions tests/test_vcs/minimal/vcs.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-full64 -t top -f test_vcs_minimal_0.scr -o test_vcs_minimal_0
1 change: 1 addition & 0 deletions tests/test_vcs/run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-l vcs.log +plusarg_bool=1 +plusarg_int=42 +plusarg_str=hello
10 changes: 10 additions & 0 deletions tests/test_vcs/test_vcs_0.scr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
+define+vlogdefine_bool=1
+define+vlogdefine_int=42
+define+vlogdefine_str=hello
+parameter+top_module.vlogparam_bool=1
+parameter+top_module.vlogparam_int=42
+parameter+top_module.vlogparam_str="hello"
+incdir+.
sv_file.sv
vlog_file.v
vlog05_file.v
1 change: 1 addition & 0 deletions tests/test_vcs/vcs.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-full64 -t top_module -f test_vcs_0.scr -o test_vcs_0

0 comments on commit 1b41f42

Please sign in to comment.