source: mod_gnutls/test/mgstest/valgrind.py

Last change on this file was 60a415a, checked in by Fiona Klute <fiona.klute@…>, 10 months ago

Fix simple formatting issues reported by flake8

  • Property mode set to 100644
File size: 1.2 KB
Line 
1# Copyright 2020 Fiona Klute
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""Helpers for Valgrind tests."""
16
17import re
18
19err_re = re.compile(r'^==\d+== ERROR SUMMARY: (\d+) errors from '
20                    r'\d+ contexts \(suppressed: (\d+) from \d+\)')
21
22
23def error_summary(log):
24    """Read all available error summaries from the given log (open text
25    file).
26
27    Returns a tuple of two ints, containing the number of reported and
28    suppressed errors, in that order.
29
30    """
31    # reported errors, suppressed errors
32    errors = (0, 0)
33    for line in log:
34        m = err_re.match(line)
35        if m:
36            add = (int(m.group(1)), int(m.group(2)))
37            errors = tuple(sum(x) for x in zip(errors, add))
38    return errors
Note: See TracBrowser for help on using the repository browser.