diff options
author | Bert Vermeulen <bert@biot.com> | 2014-06-23 19:49:47 +0200 |
---|---|---|
committer | Bert Vermeulen <bert@biot.com> | 2014-06-23 19:49:47 +0200 |
commit | d510f7b3d5d03c6fca5b6af4e184dc2f46da9a1a (patch) | |
tree | 99a4bd9766c834c0faf547f890682dd21e70072b /tests | |
parent | 4e891b94cae1b3e83155721476137a900fe242a6 (diff) | |
download | libsigrokdecode-d510f7b3d5d03c6fca5b6af4e184dc2f46da9a1a.tar.gz libsigrokdecode-d510f7b3d5d03c6fca5b6af4e184dc2f46da9a1a.zip |
pdtest/runtc: Support for output type 'exception'.
The match value should be the name of the exception thrown, e.g.
AttributeError, IndexError or even a custom exception defined in
the protocol decoder, such as SamplerateError.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/pdtest | 7 | ||||
-rw-r--r-- | tests/runtc.c | 3 |
2 files changed, 10 insertions, 0 deletions
diff --git a/tests/pdtest b/tests/pdtest index 57a8b54..088ad91 100755 --- a/tests/pdtest +++ b/tests/pdtest @@ -20,6 +20,7 @@ import os import sys +import re from getopt import getopt from tempfile import mkstemp from subprocess import Popen, PIPE @@ -376,6 +377,12 @@ def run_tests(tests, fix=False): if coverage: results[-1]['coverage_report'] = coverage os.unlink(outfile) + if op['type'] == 'exception' and 'error' in results[-1]: + # filter out the exception we were looking for + reg = "^Error: srd: Protocol decoder instance %s: %s:" % (op['pd'], op['match']) + if re.match(reg, results[-1]['error']): + # found it, not an error + results[-1].pop('error') if VERBOSE: if 'diff' in results[-1]: INFO("Output mismatch") diff --git a/tests/runtc.c b/tests/runtc.c index 059262d..e376070 100644 --- a/tests/runtc.c +++ b/tests/runtc.c @@ -759,6 +759,9 @@ int main(int argc, char **argv) op->type = SRD_OUTPUT_BINARY; else if (!strcmp(opstr[1], "python")) op->type = SRD_OUTPUT_PYTHON; + else if (!strcmp(opstr[1], "exception")) + /* Doesn't matter, we just need it to bomb out. */ + op->type = SRD_OUTPUT_PYTHON; else { ERR("Unknown output type '%s'", opstr[1]); g_strfreev(opstr); |