From: Bert Vermeulen Date: Wed, 11 Dec 2013 20:52:33 +0000 (+0100) Subject: pdtest: Use -dd to turn on SR/SRD debugging. X-Git-Tag: libsigrokdecode-0.3.0~196 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=caa4b2cc0cdb34570e0fe8e5a6dad05a2988cc89;p=libsigrokdecode.git pdtest: Use -dd to turn on SR/SRD debugging. --- diff --git a/tests/pdtest b/tests/pdtest index ac51165..ef0c350 100755 --- a/tests/pdtest +++ b/tests/pdtest @@ -7,7 +7,7 @@ from tempfile import mkstemp from subprocess import Popen, PIPE from difflib import Differ -DEBUG = False +DEBUG = 0 VERBOSE = False @@ -221,6 +221,8 @@ def run_tests(tests): for tclist in tests: for tc in tclist: args = [cmd] + if DEBUG > 1: + args.append('-d') for pd in tc['pdlist']: args.extend(['-P', pd['name']]) for label, probe in pd['probes']: @@ -358,7 +360,7 @@ report_dir = None opts, args = getopt(sys.argv[1:], "dvarslRS:") for opt, arg in opts: if opt == '-d': - DEBUG = True + DEBUG += 1 if opt == '-v': VERBOSE = True elif opt == '-a': diff --git a/tests/runtc.c b/tests/runtc.c index bb25950..04151f8 100644 --- a/tests/runtc.c +++ b/tests/runtc.c @@ -94,13 +94,25 @@ void ERR(const char *format, ...) va_end(args); } +int sr_log(void *cb_data, int loglevel, const char *format, va_list args) +{ + (void)cb_data; + + if (loglevel == SR_LOG_ERR || loglevel == SR_LOG_WARN) + logmsg("Error: sr: ", stderr, format, args); + else if (debug) + logmsg("DBG: sr: ", stdout, format, args); + + return SRD_OK; +} + int srd_log(void *cb_data, int loglevel, const char *format, va_list args) { (void)cb_data; if (loglevel == SRD_LOG_ERR || loglevel == SRD_LOG_WARN) logmsg("Error: srd: ", stderr, format, args); - else if (loglevel >= SRD_LOG_DBG && debug) + else if (debug) logmsg("DBG: srd: ", stdout, format, args); return SRD_OK; @@ -464,6 +476,7 @@ int main(int argc, char **argv) if (!op->pd || op->type == -1) usage(NULL); + sr_log_callback_set(sr_log, NULL); if (sr_init(&ctx) != SR_OK) return 1;