diff options
-rwxr-xr-x | pactest/pactest.py | 9 | ||||
-rwxr-xr-x | pactest/pmenv.py | 34 | ||||
-rwxr-xr-x | pactest/pmtest.py | 6 | ||||
-rwxr-xr-x | pactest/util.py | 5 |
4 files changed, 28 insertions, 26 deletions
diff --git a/pactest/pactest.py b/pactest/pactest.py index 7cda2556..f95ef3c1 100755 --- a/pactest/pactest.py +++ b/pactest/pactest.py @@ -93,13 +93,18 @@ if __name__ == "__main__": env.pacman["valgrind"] = opts.valgrind env.pacman["manual-confirm"] = opts.manualconfirm - if len(opts.testcases) == 0: + if opts.testcases is None or len(opts.testcases) == 0: print "no tests defined, nothing to do" + sys.exit(2) else: - for i in opts.testcases: env.addtest(i) + for i in opts.testcases: + env.addtest(i) # run tests and print overall results env.run() env.results() + if env.failed > 0: + sys.exit(1) + # vim: set ts=4 sw=4 et: diff --git a/pactest/pmenv.py b/pactest/pmenv.py index b86abe94..e9d0b4c9 100755 --- a/pactest/pmenv.py +++ b/pactest/pmenv.py @@ -27,6 +27,12 @@ class pmenv: """Environment object """ + testcases = [] + passed = 0 + failed = 0 + expectedfail = 0 + unexpectedpass = 0 + def __init__(self, root = "root"): self.root = os.path.abspath(root) self.pacman = { @@ -36,7 +42,6 @@ class pmenv: "valgrind": 0, "nolog": 0 } - self.testcases = [] def __str__(self): return "root = %s\n" \ @@ -47,8 +52,7 @@ class pmenv: """ """ if not os.path.isfile(testcase): - err("file %s not found" % testcase) - return + raise IOError("test file %s not found" % testcase) test = pmtest.pmtest(testcase, self.root) self.testcases.append(test) @@ -84,27 +88,23 @@ class pmenv: def results(self): """ """ - passed = 0 tpassed = [] - failed = 0 tfailed = [] - expectedfail = 0 texpectedfail = [] - unexpectedpass = 0 tunexpectedpass = [] for test in self.testcases: fail = test.result["fail"] if fail == 0 and not test.expectfailure: - passed += 1 + self.passed += 1 tpassed.append(test) elif fail != 0 and test.expectfailure: - expectedfail += 1 + self.expectedfail += 1 texpectedfail.append(test) elif fail == 0: # and not test.expectfail - unexpectedpass += 1 + self.unexpectedpass += 1 tunexpectedpass.append(test) else: - failed += 1 + self.failed += 1 tfailed.append(test) def _printtest(t): @@ -142,13 +142,13 @@ class pmenv: total = len(self.testcases) print "Total = %3u" % total if total: - print "Pass = %3u (%6.2f%%)" % (passed, float(passed) * 100 / total) - print "Expected Fail = %3u (%6.2f%%)" % (expectedfail, float(expectedfail) * 100 / total) - print "Unexpected Pass = %3u (%6.2f%%)" % (unexpectedpass, float(unexpectedpass) * 100 / total) - print "Fail = %3u (%6.2f%%)" % (failed, float(failed) * 100 / total) + print "Pass = %3u (%6.2f%%)" % (self.passed, float(self.passed) * 100 / total) + print "Expected Fail = %3u (%6.2f%%)" % (self.expectedfail, float(self.expectedfail) * 100 / total) + print "Unexpected Pass = %3u (%6.2f%%)" % (self.unexpectedpass, float(self.unexpectedpass) * 100 / total) + print "Fail = %3u (%6.2f%%)" % (self.failed, float(self.failed) * 100 / total) print "" if __name__ == "__main__": - env = pmenv("/tmp") - print env + pass + # vim: set ts=4 sw=4 et: diff --git a/pactest/pmtest.py b/pactest/pmtest.py index f31563b1..39f4deab 100755 --- a/pactest/pmtest.py +++ b/pactest/pmtest.py @@ -95,7 +95,7 @@ class pmtest: if os.path.isfile(self.name): execfile(self.name) else: - err("file %s does not exist!" % self.name) + raise IOerror("file %s does not exist!" % self.name) def generate(self): """ @@ -268,6 +268,6 @@ class pmtest: if __name__ == "__main__": - test = pmtest("test1", "./root") - print test + pass + # vim: set ts=4 sw=4 et: diff --git a/pactest/util.py b/pactest/util.py index c6d5a594..db9560fe 100755 --- a/pactest/util.py +++ b/pactest/util.py @@ -43,10 +43,6 @@ LOGFILE = "var/log/pactest.log" verbose = 0 -def err(msg): - print "error: " + msg - sys.exit(1) - def vprint(msg): if verbose: print msg @@ -273,4 +269,5 @@ def mkdir(dir): if __name__ == "__main__": pass + # vim: set ts=4 sw=4 et: |