hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/tools/testing/selftests/tc-testing/plugin-lib/valgrindPlugin.py
....@@ -11,6 +11,7 @@
1111 import subprocess
1212 import time
1313 from TdcPlugin import TdcPlugin
14
+from TdcResults import *
1415
1516 from tdc_config import *
1617
....@@ -21,6 +22,7 @@
2122 def __init__(self):
2223 self.sub_class = 'valgrind/SubPlugin'
2324 self.tap = ''
25
+ self._tsr = TestSuiteReport()
2426 super().__init__()
2527
2628 def pre_suite(self, testcount, testidlist):
....@@ -34,10 +36,14 @@
3436 def post_suite(self, index):
3537 '''run commands after test_runner goes into a test loop'''
3638 super().post_suite(index)
37
- self._add_to_tap('\n|---\n')
3839 if self.args.verbose > 1:
3940 print('{}.post_suite'.format(self.sub_class))
40
- print('{}'.format(self.tap))
41
+ #print('{}'.format(self.tap))
42
+ for xx in range(index - 1, self.testcount):
43
+ res = TestResult('{}-mem'.format(self.testidlist[xx]), 'Test skipped')
44
+ res.set_result(ResultState.skip)
45
+ res.set_errormsg('Skipped because of prior setup/teardown failure')
46
+ self._add_results(res)
4147 if self.args.verbose < 4:
4248 subprocess.check_output('rm -f vgnd-*.log', shell=True)
4349
....@@ -96,6 +102,14 @@
96102 if not self.args.valgrind:
97103 return
98104
105
+ res = TestResult('{}-mem'.format(self.args.testid),
106
+ '{} memory leak check'.format(self.args.test_name))
107
+ if self.args.test_skip:
108
+ res.set_result(ResultState.skip)
109
+ res.set_errormsg('Test case designated as skipped.')
110
+ self._add_results(res)
111
+ return
112
+
99113 self.definitely_lost_re = re.compile(
100114 r'definitely lost:\s+([,0-9]+)\s+bytes in\s+([,0-9]+)\sblocks', re.MULTILINE | re.DOTALL)
101115 self.indirectly_lost_re = re.compile(
....@@ -130,13 +144,17 @@
130144 mem_results = ''
131145 if (def_num > 0) or (ind_num > 0) or (pos_num > 0) or (nle_num > 0):
132146 mem_results += 'not '
147
+ res.set_result(ResultState.fail)
148
+ res.set_failmsg('Memory leak detected')
149
+ res.append_failmsg(content)
150
+ else:
151
+ res.set_result(ResultState.success)
133152
134
- mem_results += 'ok {} - {}-mem # {}\n'.format(
135
- self.args.test_ordinal, self.args.testid, 'memory leak check')
136
- self._add_to_tap(mem_results)
137
- if mem_results.startswith('not '):
138
- print('{}'.format(content))
139
- self._add_to_tap(content)
153
+ self._add_results(res)
154
+
155
+
156
+ def _add_results(self, res):
157
+ self._tsr.add_resultdata(res)
140158
141159 def _add_to_tap(self, more_tap_output):
142160 self.tap += more_tap_output