Revise generation of "END" messages in dejagnu.h
[dejagnu.git] / contrib / dejagnu.py
blobe2bfa2d6081ced73a200aa8412ed16f1e0f40145
1 #!/usr/bin/python3
3 # Copyright (C) 2018, 2019, 2020 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 class DejaGnu(object):
21 def __init__(self):
22 self.passed = 0
23 self.failed = 0
24 self.xfailed = 0
25 self.xpassed = 0
26 self.kfailed = 0
27 self.kpassed = 0
28 self.untested = 0
29 self.unresolved = 0
30 self.verbosity = 0
32 def verbose_level(self, level=0):
33 self.verbosity = level
35 def verbose(self, msg="", level=0):
36 if self.verbosity > level:
37 print(msg)
39 def fails(self, msg=""):
40 self.failed += 1
41 print("FAIL: " + msg)
43 def xfails(self, msg=""):
44 self.xfailed += 1
45 print("XFAIL: " + msg)
47 def untested(self, msg=""):
48 self.untested += 1
49 print("UNTESTED: " + msg)
51 def xpasses(self, msg=""):
52 self.xpassed += 1
53 print("XPASS: " + msg)
55 def passes(self, msg=""):
56 self.passed += 1
57 print("PASS: " + msg)
59 def matches(self, instr, expected, msg="", yes=True):
60 if instr == expected:
61 if yes == True:
62 self.passes(msg)
63 else:
64 self.xpasses(msg)
65 return True
66 else:
67 if yes == True:
68 self.fails(msg)
69 else:
70 self.xfails(msg)
71 # print("\tGot \'" + instr + "\', expected \'" + expected + "\'")
72 return False
74 def totals(self):
75 print("\nTotals")
76 print("-------")
77 if self.passed > 0:
78 print("Total passed: %r " % self.passed)
79 if self.xpassed > 0:
80 print("Total Xpassed: %r " % self.xpassed)
81 if self.failed > 0:
82 print("Total failed: %r " % self.failed)
83 if self.xfailed > 0:
84 print("Total Xfailed: %r " % self.xfailed)
85 if self.untested > 0:
86 print("Total untested: %r " % self.untested)
87 if self.unresolved > 0:
88 print("Total unresolved: %r " % self.unresolved)