1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#!/usr/bin/python3
#
# Copyright (C) 2018, 2019, 2020 Free Software Foundation, Inc.
#
# 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, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
class DejaGnu(object):
def __init__(self):
self.passed = 0
self.failed = 0
self.xfailed = 0
self.xpassed = 0
self.kfailed = 0
self.kpassed = 0
self.untested = 0
self.unresolved = 0
self.verbosity = 0
def verbose_level(self, level=0):
self.verbosity = level
def verbose(self, msg="", level=0):
if self.verbosity > level:
print(msg)
def fails(self, msg=""):
self.failed += 1
print("FAIL: " + msg)
def xfails(self, msg=""):
self.xfailed += 1
print("XFAIL: " + msg)
def untested(self, msg=""):
self.untested += 1
print("UNTESTED: " + msg)
def xpasses(self, msg=""):
self.xpassed += 1
print("XPASS: " + msg)
def passes(self, msg=""):
self.passed += 1
print("PASS: " + msg)
def matches(self, instr, expected, msg="", yes=True):
if instr == expected:
if yes == True:
self.passes(msg)
else:
self.xpasses(msg)
return True
else:
if yes == True:
self.fails(msg)
else:
self.xfails(msg)
# print("\tGot \'" + instr + "\', expected \'" + expected + "\'")
return False
def totals(self):
print("\nTotals")
print("-------")
if self.passed > 0:
print("Total passed: %r " % self.passed)
if self.xpassed > 0:
print("Total Xpassed: %r " % self.xpassed)
if self.failed > 0:
print("Total failed: %r " % self.failed)
if self.xfailed > 0:
print("Total Xfailed: %r " % self.xfailed)
if self.untested > 0:
print("Total untested: %r " % self.untested)
if self.unresolved > 0:
print("Total unresolved: %r " % self.unresolved)
|