mirror of
https://github.com/YosysHQ/sby.git
synced 2025-08-28 07:28:57 +00:00
Add failing test case
This commit is contained in:
parent
13fef4a710
commit
ad5b9ceed5
4 changed files with 202 additions and 155 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,4 @@
|
|||
/docs/build
|
||||
/sbysrc/demo[0-9]
|
||||
/sbysrc/__pycache__
|
||||
|
||||
*.pyc
|
||||
|
|
|
@ -28,6 +28,7 @@ class DictAction(argparse.Action):
|
|||
name = option_string.lstrip(parser.prefix_chars).replace("-", "_")
|
||||
getattr(namespace, self.dest)[name] = values
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(prog="sby",
|
||||
usage="%(prog)s [options] [<jobname>.sby [tasknames] | <dirname>]")
|
||||
parser.set_defaults(exe_paths=dict())
|
||||
|
@ -143,11 +144,13 @@ prep -top top
|
|||
|
||||
early_logmsgs = list()
|
||||
|
||||
|
||||
def early_log(workdir, msg):
|
||||
tm = localtime()
|
||||
early_logmsgs.append("SBY {:2d}:{:02d}:{:02d} [{}] {}".format(tm.tm_hour, tm.tm_min, tm.tm_sec, workdir, msg))
|
||||
print(early_logmsgs[-1])
|
||||
|
||||
|
||||
def read_sbyconfig(sbydata, taskname):
|
||||
cfgdata = list()
|
||||
tasklist = list()
|
||||
|
@ -269,6 +272,7 @@ def read_sbyconfig(sbydata, taskname):
|
|||
return cfgdata, tasklist
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sbydata = list()
|
||||
with (open(sbyfile, "r") if sbyfile is not None else sys.stdin) as f:
|
||||
for line in f:
|
||||
|
@ -327,6 +331,7 @@ if (workdir is not None) and (len(tasknames) != 1):
|
|||
print("ERROR: Exactly one task is required when workdir is specified.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def run_job(taskname):
|
||||
my_workdir = workdir
|
||||
my_opt_tmpdir = opt_tmpdir
|
||||
|
@ -425,6 +430,7 @@ def run_job(taskname):
|
|||
return job.retcode
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
retcode = 0
|
||||
for t in tasknames:
|
||||
retcode |= run_job(t)
|
||||
|
|
|
@ -499,6 +499,7 @@ class SbyJob:
|
|||
for line in f:
|
||||
raw_line = line
|
||||
if mode in ["options", "engines", "files"]:
|
||||
# delete trailing whitespace and comments
|
||||
line = re.sub(r"\s*(\s#.*)?$", "", line)
|
||||
if line == "" or line[0] == "#":
|
||||
continue
|
||||
|
|
40
sbysrc/test_sby.py
Normal file
40
sbysrc/test_sby.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
import unittest
|
||||
|
||||
from sby import *
|
||||
|
||||
|
||||
class TestSby(unittest.TestCase):
|
||||
def test_read_sbyconfig(self):
|
||||
cfg = '''
|
||||
[tasks]
|
||||
a
|
||||
b
|
||||
|
||||
[options]
|
||||
a:
|
||||
mode prove
|
||||
depth 100
|
||||
|
||||
b:
|
||||
mode cover
|
||||
depth 100
|
||||
|
||||
[engines]
|
||||
smtbmc
|
||||
|
||||
[script]
|
||||
read -formal foo.v
|
||||
prep -top foo
|
||||
|
||||
[files]
|
||||
foo.v
|
||||
'''
|
||||
sbydata = cfg.split('\n')
|
||||
cfgdata, tasklist = read_sbyconfig(sbydata, 'a')
|
||||
|
||||
self.assertIn('[engines]', cfgdata)
|
||||
i = cfgdata.index('[engines]')
|
||||
self.assertSequenceEqual(['[engines]', 'smtbmc'], cfgdata[index:index+1])
|
||||
print(cfgdata)
|
||||
print(tasklist)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue