This file is indexed.

/usr/lib/python3/dist-packages/checkbox_support/scripts/tests/test_gputest_benchmark.py is in python3-checkbox-support 0.2-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
#
# This file is part of Checkbox.
#
# Copyright 2013 Canonical Ltd.
#
# Checkbox is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3,
# as published by the Free Software Foundation.

#
# Checkbox 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 Checkbox.  If not, see <http://www.gnu.org/licenses/>.
#
from tempfile import NamedTemporaryFile
import os
import unittest

from checkbox_support.scripts.gputest_benchmark import check_log
from checkbox_support.vendor.mock import patch


class LogParserTest(unittest.TestCase):

    def setUp(self):
        self.logfile = NamedTemporaryFile(delete=False)
        self.devnull = open(os.devnull, 'w')

    def test_logfile_not_found(self):
        os.unlink(self.logfile.name)
        with self.assertRaises(SystemExit) as cm:
            check_log(self.logfile.name)
        self.assertEqual(
            "[Errno 2] No such file or directory: "
            "'{}'".format(self.logfile.name),
            str(cm.exception))

    def test_logfile_with_score(self):
        with open(self.logfile.name, 'wt') as f:
            f.write('FurMark : init OK.\n')
            f.write('[Benchmark_Score] - module: FurMark - Score: 8 points'
                    '(800x600 windowed, duration:2000 ms).')
        with patch('sys.stdout', self.devnull):
            self.assertFalse(check_log(self.logfile.name))
        os.unlink(self.logfile.name)

    def test_logfile_without_score(self):
        with open(self.logfile.name, 'wt') as f:
            f.write('FurMark : init OK.\n')
            f.write('[No_Score] - module: FurMark - Score: _ points'
                    '(800x600 windowed, duration:2000 ms).')
        with patch('sys.stdout', self.devnull):
            with self.assertRaises(SystemExit) as cm:
                check_log(self.logfile.name)
            self.assertEqual(
                'Benchmark score not found, check the log for errors',
                str(cm.exception))
        os.unlink(self.logfile.name)

    def test_logfile_with_encoding_error(self):
        with open(self.logfile.name, 'wb') as f:
            f.write(b'\x80abc\n')
            f.write(b'FurMark : init OK.\n')
            f.write(b'[Benchmark_Score] - module: FurMark - Score: 116 points'
                    b'(800x600 windowed, duration:2000 ms).')
        with patch('sys.stdout', self.devnull):
            self.assertFalse(check_log(self.logfile.name))
        os.unlink(self.logfile.name)

    def tearDown(self):
        try:
            os.unlink(self.logfile.name)
        except OSError:
            pass