diff options
author | Gerhard Sittig <gerhard.sittig@gmx.net> | 2022-04-23 08:32:30 +0200 |
---|---|---|
committer | Gerhard Sittig <gerhard.sittig@gmx.net> | 2022-04-23 16:58:46 +0200 |
commit | 12f978c9d45b3bf5b5767cb3104fac4c38bfd3df (patch) | |
tree | e921f350d498b79269d3ffe95aa2501ca6dedc3d /decoder | |
parent | 80cc8a49a87e5f2e4ffc1cbb795419dab105d5b0 (diff) | |
download | sigrok-test-12f978c9d45b3bf5b5767cb3104fac4c38bfd3df.tar.gz sigrok-test-12f978c9d45b3bf5b5767cb3104fac4c38bfd3df.zip |
pdtest: add support for input format specs in test.conf files
The pdtest(1) utility interprets test.conf files. Extend the syntax of
'input' lines. These used to accept one filename only. Add support for
'format' and 'option' keywords. These translate to runtc(1) -I options.
Diffstat (limited to 'decoder')
-rwxr-xr-x | decoder/pdtest | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/decoder/pdtest b/decoder/pdtest index 5948325..a2a33fc 100755 --- a/decoder/pdtest +++ b/decoder/pdtest @@ -146,9 +146,26 @@ def parse_testfile(path, pd, tc, op_type, op_class): raise E_syntax tclist[-1]['stack'] = f elif key == 'input': - if len(f) != 1: + if len(f) < 1: raise E_syntax - tclist[-1]['input'] = f[0] + input_spec = { + 'name': f.pop(0), + 'format': None, + 'options': [], + } + while len(f): + if len(f) < 2: + # Always needs <key> <value> + raise E_syntax + a, b = f[:2] + f = f[2:] + if a == 'format': + input_spec['format'] = b + elif a == 'option': + input_spec['options'].append(b) + else: + raise E_syntax + tclist[-1]['input'] = input_spec elif key == 'output': op_spec = { 'pd': f.pop(0), @@ -325,7 +342,15 @@ def run_tests(tests, fix=False): args.extend(['-o', "%s=%s" % (option, value)]) for label, initial_pin in spd['initial_pins']: args.extend(['-N', "%s=%d" % (label, initial_pin)]) - args.extend(['-i', os.path.join(dumps_dir, tc['input'])]) + # Setup input spec for this test (optional format spec). + in_spec = tc['input'] + infile = os.path.join(dumps_dir, in_spec['name']) + args.extend(['-i', infile]) + if in_spec['format']: + args.extend(['-I', in_spec['format']]) + for opt in in_spec['options']: + args.extend(['-I', opt]) + # Setup output spec for this test. for op in tc['output']: name = "%s/%s/%s" % (pd, tc['name'], op['type']) opargs = ['-O', "%s:%s" % (op['pd'], op['type'])] |