X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=tests%2Fpdtest;h=8a760f2a71884e5384121bf5bf1ca2faba0339f2;hb=38ab4ed09ad08d12eb34b0e24765790b34d90cc7;hp=2a90f2c2e965f4e84d0b5037dccbad2b7be559b0;hpb=d7d693b51692aa7aae90f3ca8caf5a8e9c581ed9;p=libsigrokdecode.git diff --git a/tests/pdtest b/tests/pdtest index 2a90f2c..8a760f2 100755 --- a/tests/pdtest +++ b/tests/pdtest @@ -1,4 +1,22 @@ -#!/usr/bin/env /usr/bin/python3 +#!/usr/bin/env python3 +## +## This file is part of the libsigrokdecode project. +## +## Copyright (C) 2013 Bert Vermeulen +## +## This program is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program. If not, see . +## import os import sys @@ -205,7 +223,7 @@ def get_tests(testnames): return tests -def diff_textfiles(f1, f2): +def diff_text(f1, f2): t1 = open(f1).readlines() t2 = open(f2).readlines() diff = [] @@ -217,7 +235,7 @@ def diff_textfiles(f1, f2): return diff -def compare_binfiles(f1, f2): +def compare_binary(f1, f2): h1 = md5() h1.update(open(f1, 'rb').read()) h2 = md5() @@ -278,10 +296,10 @@ def run_tests(tests, fix=False): match = os.path.join(decoders_dir, op['pd'], 'test', op['match']) try: diff = diff_error = None - if op['type'] == 'annotation': - diff = diff_textfiles(match, outfile) + if op['type'] in ('annotation', 'python'): + diff = diff_text(match, outfile) elif op['type'] == 'binary': - diff = compare_binfiles(match, outfile) + diff = compare_binary(match, outfile) else: diff = ["Unsupported output type '%s'." % op['type']] except Exception as e: @@ -388,7 +406,7 @@ if len(sys.argv) == 1: opt_all = opt_run = opt_show = opt_list = opt_fix = False report_dir = None -opts, args = getopt(sys.argv[1:], "dvarslfRS:") +opts, args = getopt(sys.argv[1:], "dvarslfR:S:") for opt, arg in opts: if opt == '-d': DEBUG += 1