コード例 #1
0
    def test_trace_fail(self):
        """compare_replay.trace: fail comparing a trace"""

        wrong_checksum = '917cbbf4f09dd62ea26d247a1c70c16f'
        f = io.StringIO()
        with contextlib.redirect_stdout(f):
            assert (compare_replay.trace(self.trace_path, wrong_checksum) is
                    compare_replay.Result.DIFFER)
        self.m_qty_load_yaml.assert_not_called()
        self.m_ensure_file.assert_called_once()
        self.m_backends_dump.assert_called_once()
        self.m_hexdigest_from_image.assert_called_once()
        assert not self.tmpdir.join(self.results_partial_path,
                                    self.trace_path + '-99.png').check()
        assert self.tmpdir.join(self.results_partial_path,
                                path.dirname(self.trace_path),
                                self.exp_checksum + '.png').check()
        s = f.getvalue()
        assert s.endswith(
            'PIGLIT: '
            '{"images": [{'
            '"image_desc": "' + self.trace_path + '", '
            '"image_ref": "' + wrong_checksum + '.png", '
            '"image_render": "' +
            self.tmpdir.join(self.results_partial_path,
                             path.dirname(self.trace_path), self.exp_checksum +
                             '.png').strpath + '"}], "result": "fail"}\n')
コード例 #2
0
ファイル: test_compare_replay.py プロジェクト: lcong/piglit
    def test_trace_success_keep_image(self):
        """compare_replay.trace: compare a trace successfully and set the option to keep the dumped image"""

        OPTIONS.keep_image = True
        f = io.StringIO()
        with contextlib.redirect_stdout(f):
            assert (compare_replay.trace(self.trace_path, self.exp_checksum) is
                    compare_replay.Result.MATCH)
        self.m_qty_load_yaml.assert_not_called()
        self.m_ensure_file.assert_called_once()
        self.m_backends_dump.assert_called_once()
        self.m_hexdigest_from_image.assert_called_once()
        dumped_image_path = '{}-99.png'.format(self.trace_path)
        root, ext = path.splitext(dumped_image_path)
        assert not self.tmpdir.join(self.results_partial_path,
                                    dumped_image_path).check()
        final_image_pathlib = self.tmpdir.join(
            self.results_partial_path,
            '{}-{}{}'.format(root, self.exp_checksum, ext))
        assert final_image_pathlib.check()
        s = f.getvalue()
        assert s.endswith('PIGLIT: '
                          '{"images": [{'
                          '"image_desc": "' + self.trace_path + '", '
                          '"image_ref": "' + self.exp_checksum + '.png", '
                          '"image_render": "' + final_image_pathlib.strpath +
                          '"}], "result": "pass"}\n')
コード例 #3
0
ファイル: compare.py プロジェクト: mesa3d/piglit
def _trace(args):
    options.OPTIONS.device_name = args.device_name
    options.OPTIONS.keep_image = args.keep_image
    options.OPTIONS.set_download_url(args.download_url)
    options.OPTIONS.download['force'] = args.force_download
    options.OPTIONS.db_path = args.db_path
    options.OPTIONS.results_path = args.output

    return compare_replay.trace(args.file_path, args.expected_checksum)
コード例 #4
0
    def test_trace_dump_crash(self, trace_path):
        """compare_replay.trace: dump crashes or fails comparing a trace"""

        third_exp_checksum = '6b6d27df609b8d086cc3335e6d103581'
        f = io.StringIO()
        with contextlib.redirect_stdout(f):
            assert (compare_replay.trace(trace_path, third_exp_checksum) is
                    compare_replay.Result.FAILURE)
        self.m_qty_load_yaml.assert_not_called()
        self.m_ensure_file.assert_called_once()
        self.m_backends_dump.assert_called_once()
        self.m_hexdigest_from_image.assert_not_called()
        assert not self.tmpdir.join(self.results_partial_path,
                                    path.dirname(trace_path),
                                    third_exp_checksum + '.png').check()
        s = f.getvalue()
        assert s.endswith('PIGLIT: {"result": "crash"}\n')
コード例 #5
0
    def test_trace_success(self):
        """compare_replay.trace: compare a trace successfully"""

        f = io.StringIO()
        with contextlib.redirect_stdout(f):
            assert (compare_replay.trace(self.trace_path, self.exp_checksum) is
                    compare_replay.Result.MATCH)
        self.m_qty_load_yaml.assert_not_called()
        self.m_ensure_file.assert_called_once()
        self.m_backends_dump.assert_called_once()
        self.m_hexdigest_from_image.assert_called_once()
        assert not self.tmpdir.join(self.results_partial_path,
                                    self.trace_path + '-99.png').check()
        assert not self.tmpdir.join(self.results_partial_path,
                                    path.dirname(self.trace_path),
                                    self.exp_checksum + '.png').check()
        s = f.getvalue()
        assert s.endswith('PIGLIT: {"result": "pass"}\n')
コード例 #6
0
ファイル: test_compare_replay.py プロジェクト: lcong/piglit
    def test_trace_dump_crash(self, trace_path):
        """compare_replay.trace: dump crashes or fails comparing a trace"""

        third_exp_checksum = '6b6d27df609b8d086cc3335e6d103581'
        f = io.StringIO()
        with contextlib.redirect_stdout(f):
            assert (compare_replay.trace(trace_path, third_exp_checksum) is
                    compare_replay.Result.FAILURE)
        self.m_qty_load_yaml.assert_not_called()
        self.m_ensure_file.assert_called_once()
        self.m_backends_dump.assert_called_once()
        self.m_hexdigest_from_image.assert_not_called()
        root, ext = path.splitext('{}-99.png'.format(self.trace_path))
        final_image_pathlib = self.tmpdir.join(
            self.results_partial_path,
            '{}-{}{}'.format(root, third_exp_checksum, ext))
        assert not final_image_pathlib.check()
        s = f.getvalue()
        assert s.endswith('PIGLIT: '
                          '{"images": [{'
                          '"image_desc": "' + trace_path + '", '
                          '"image_ref": "' + third_exp_checksum + '.png", '
                          '"image_render": null}], "result": "crash"}\n')
コード例 #7
0
    def test_trace_no_dumped_images(self, trace_path):
        """compare_replay.trace: dump succeeds but no images are generated"""

        third_exp_checksum = 'ebaa1e2d04d7dfe5a91499510722c46e'
        f = io.StringIO()
        with contextlib.redirect_stdout(f):
            assert (compare_replay.trace(trace_path, third_exp_checksum)
                    is compare_replay.Result.FAILURE)
        self.m_qty_load_yaml.assert_not_called()
        self.m_ensure_file.assert_called_once()
        self.m_backends_dump.assert_called_once()
        self.m_hexdigest_from_image.assert_not_called()
        root, ext = path.splitext('{}-99.png'.format(self.trace_path))
        final_image_pathlib = self.tmpdir.join(
            self.results_partial_path, '{}-{}{}'.format(
                root, third_exp_checksum, ext))
        assert not final_image_pathlib.check()
        s = f.getvalue()
        assert s.endswith('PIGLIT: '
                          '{"images": [{'
                          '"image_desc": "' + trace_path + '", '
                          '"image_ref": "' + third_exp_checksum + '.png", '
                          '"image_render": null}], "result": "crash"}\n')