From 85b91151dd6199d272edd03b2b86e9abc3117715 Mon Sep 17 00:00:00 2001 From: Illia Abernikhin Date: Wed, 27 Oct 2021 12:27:25 +0300 Subject: [PATCH] framework: fix run with valgrind option Add getter method for 'valgrind' with its keys to the ValgrindMixin class, also fix command generation in profiles, append the 'valgrind' option with its keys to the start of the command. Closes: https://gitlab.freedesktop.org/mesa/piglit/-/issues/20 Signed-of-by: Illia Abernikhin illia.abernikhin@globallogic.com --- framework/test/base.py | 8 +++++--- framework/test/glsl_parser_test.py | 5 +++-- framework/test/piglit_test.py | 15 ++++++++------- framework/test/shader_test.py | 8 ++++---- unittests/framework/test/test_base.py | 19 ++++++++++++++++--- 5 files changed, 36 insertions(+), 19 deletions(-) diff --git a/framework/test/base.py b/framework/test/base.py index a47fe8805..64c7db18c 100644 --- a/framework/test/base.py +++ b/framework/test/base.py @@ -380,12 +380,14 @@ class ValgrindMixin(object): """ @Test.command.getter def command(self): - command = super(ValgrindMixin, self).command + return super(ValgrindMixin, self).command + + def keys(self): if OPTIONS.valgrind: return ['valgrind', '--quiet', '--error-exitcode=1', - '--tool=memcheck'] + command + '--tool=memcheck'] else: - return command + return [] def interpret_result(self): """Set the status to the valgrind status. diff --git a/framework/test/glsl_parser_test.py b/framework/test/glsl_parser_test.py index 8274cbacf..45ea439a6 100644 --- a/framework/test/glsl_parser_test.py +++ b/framework/test/glsl_parser_test.py @@ -30,7 +30,7 @@ import sys import re import io -from framework import exceptions +from framework import exceptions, options from .base import TestIsSkip from .opengl import FastSkipMixin from .piglit_test import PiglitBaseTest, TEST_BIN_DIR, ROOT_DIR @@ -302,8 +302,9 @@ class GLSLParserTest(FastSkipMixin, PiglitBaseTest): @PiglitBaseTest.command.getter def command(self): command = super(GLSLParserTest, self).command + glslfile = os.path.join(ROOT_DIR, command[1]) - return [command[0], glslfile] + command[2:] + return self.keys() + [command[0], glslfile] + command[2:] @classmethod def new(cls, filepath, installpath=None): diff --git a/framework/test/piglit_test.py b/framework/test/piglit_test.py index 90fafebfd..b85bac0d5 100644 --- a/framework/test/piglit_test.py +++ b/framework/test/piglit_test.py @@ -179,9 +179,9 @@ class PiglitGLTest(WindowResizeMixin, PiglitBaseTest): def command(self): """ Automatically add -auto and -fbo as appropriate """ if not self.run_concurrent: - return super(PiglitGLTest, self).command + ['-auto'] + return self.keys() + super(PiglitGLTest, self).command + ['-auto'] else: - return super(PiglitGLTest, self).command + ['-auto', '-fbo'] + return self.keys() + super(PiglitGLTest, self).command + ['-auto', '-fbo'] @command.setter def command(self, new): @@ -199,7 +199,7 @@ class ASMParserTest(PiglitBaseTest): @PiglitBaseTest.command.getter def command(self): command = super(ASMParserTest, self).command - return command + [os.path.join(ROOT_DIR, self.filename)] + return self.keys() + command + [os.path.join(ROOT_DIR, self.filename)] class BuiltInConstantsTest(PiglitBaseTest): @@ -209,8 +209,9 @@ class BuiltInConstantsTest(PiglitBaseTest): @PiglitBaseTest.command.getter def command(self): command = super(BuiltInConstantsTest, self).command + command[1] = os.path.join(ROOT_DIR, 'tests', command[1]) - return command + return self.keys() + command; class PiglitCLTest(PiglitBaseTest): # pylint: disable=too-few-public-methods @@ -236,7 +237,7 @@ class CLProgramTester(PiglitCLTest): @PiglitCLTest.command.getter def command(self): command = super(CLProgramTester, self).command - return command + [os.path.join(ROOT_DIR, self.filename)] + return self.keys() + command + [os.path.join(ROOT_DIR, self.filename)] class VkRunnerTest(PiglitBaseTest): @@ -259,7 +260,7 @@ class VkRunnerTest(PiglitBaseTest): # self._command is used because we don't want PiglitBaseTest # to prepend TEST_BIN_DIR so that it will look for vkrunner in # the search path. - return self._command + [os.path.join(ROOT_DIR, self.filename)] + return self.keys() + self._command + [os.path.join(ROOT_DIR, self.filename)] class PiglitReplayerTest(PiglitBaseTest): @@ -284,7 +285,7 @@ class PiglitReplayerTest(PiglitBaseTest): command = super(PiglitReplayerTest, self).command if self.RESULTS_PATH is not None: command += ['--output', self.RESULTS_PATH] - return command + self.extra_args + return self.keys() + command + self.extra_args def interpret_result(self): # Python's unhandled exceptions use "1" as exit code value. We want to diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py index 15d2325c3..ee7d3a964 100644 --- a/framework/test/shader_test.py +++ b/framework/test/shader_test.py @@ -187,12 +187,12 @@ class ShaderTest(FastSkipMixin, PiglitBaseTest): """ Add -auto, -fbo and -glsl (if needed) to the test command """ command = super(ShaderTest, self).command - shaderfile = os.path.join(ROOT_DIR, command[1]) + shaderfile = os.path.join(ROOT_DIR, self._command[1]) if options.OPTIONS.force_glsl: - return [command[0]] + [shaderfile, '-auto', '-fbo', '-glsl'] + return self.keys() + [command[0]] + [shaderfile, '-auto', '-fbo', '-glsl'] else: - return [command[0]] + [shaderfile, '-auto', '-fbo'] + return self.keys() + [command[0]] + [shaderfile, '-auto', '-fbo'] @command.setter def command(self, new): @@ -298,7 +298,7 @@ class MultiShaderTest(ReducedProcessMixin, PiglitBaseTest): command = super(MultiShaderTest, self).command shaderfiles = (x for x in command[1:] if not x.startswith('-')) shaderfiles = [os.path.join(ROOT_DIR, s) for s in shaderfiles] - return [command[0]] + shaderfiles + ['-auto', '-report-subtests'] + return self.keys() + [command[0]] + shaderfiles + ['-auto', '-report-subtests'] def _is_subtest(self, line): return line.startswith('PIGLIT TEST:') diff --git a/unittests/framework/test/test_base.py b/unittests/framework/test/test_base.py index e29fc1e62..2daca3cc3 100644 --- a/unittests/framework/test/test_base.py +++ b/unittests/framework/test/test_base.py @@ -348,7 +348,7 @@ class TestValgrindMixin(object): """Tests for the ValgrindMixin class.""" def test_command(self, mocker): - """test.base.ValgrindMixin.command: overrides self.command.""" + """test.base.ValgrindMixin.command: self.command doesnt change.""" opts = mocker.patch('framework.test.base.OPTIONS', new_callable=Options) @@ -358,8 +358,21 @@ class TestValgrindMixin(object): opts.valgrind = True test = Test(['foo']) - assert test.command == ['valgrind', '--quiet', '--error-exitcode=1', - '--tool=memcheck', 'foo'] + assert test.command == ['foo'] + + def test_keys(self, mocker): + """test.base.ValgrindMixin.keys: return 'valgrind' with its keys.""" + opts = mocker.patch('framework.test.base.OPTIONS', + new_callable=Options) + + class Test(base.ValgrindMixin, _Test): + pass + + opts.valgrind = True + + test = Test(['foo']) + assert test.keys() == ['valgrind', '--quiet', '--error-exitcode=1', + '--tool=memcheck'] class TestRun(object): """Tests for the run method.""" -- 2.11.4.GIT