]> sigrok.org Git - libsigrokdecode.git/commitdiff
pdtest/runtc: Support for output type 'exception'.
authorBert Vermeulen <redacted>
Mon, 23 Jun 2014 17:49:47 +0000 (19:49 +0200)
committerBert Vermeulen <redacted>
Mon, 23 Jun 2014 17:49:47 +0000 (19:49 +0200)
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.

tests/pdtest
tests/runtc.c

index 57a8b54caf0d73957ef45463e7a2cd49c275ca6e..088ad91cdf2b387ec8d0127da66f83fc9a1ae2a3 100755 (executable)
@@ -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")
index 059262d3918660a83a9c5058bfa6ff802fa2388d..e376070bb1f7038655816cee075dd93007b74760 100644 (file)
@@ -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);