def make_test(element): """Rebuild a test instance from xml.""" def process(elem, opt): k = elem.attrib['name'] v = elem.attrib['value'] try: opt[k] = ast.literal_eval(v) except ValueError: opt[k] = v type_ = element.attrib['type'] options = {} for e in element.findall('./option'): process(e, options) options['env'] = { e.attrib['name']: e.attrib['value'] for e in element.findall('./environment/env') } if type_ == 'gl': return PiglitGLTest(**options) if type_ == 'gl_builtin': return BuiltInConstantsTest(**options) if type_ == 'cl': return PiglitCLTest(**options) if type_ == 'cl_prog': return CLProgramTester(**options) if type_ == 'shader': return ShaderTest(**options) if type_ == 'glsl_parser': return GLSLParserTest(**options) if type_ == 'asm_parser': return ASMParserTest(**options) if type_ == 'vkrunner': return VkRunnerTest(**options) if type_ == 'multi_shader': options['skips'] = [] for e in element.findall('./Skips/Skip/option'): skips = {} process(e, skips) options['skips'].append(skips) return MultiShaderTest(**options) if type_ == 'xts': return XTSTest(**options) if type_ == 'rendercheck': return RendercheckTest(**options) raise Exception('Unreachable')
def test_PiglitGLTest_include_and_exclude(): """test.piglit_test.PiglitGLTest.is_skip(): raises if include and exclude are given.""" with nt.assert_raises(AssertionError): PiglitGLTest(['foo'], require_platforms=['glx'], exclude_platforms=['gbm'])
def test_piglittest_command_getter_concurrent(): """test.piglit_test.PiglitGLTest.command: adds -fbo and -auto to concurrent tests""" test = PiglitGLTest(['foo'], run_concurrent=True) nt.assert_in('-auto', test.command) nt.assert_in('-fbo', test.command)
def test_piglittest_command_getter_serial(): """ PiglitGLTest.command adds -auto to serial tests """ test = PiglitGLTest('foo') nt.assert_in('-auto', test.command)
def test_platform_in_exclude(self, mock_options): """skips if platform is in exclude_platforms.""" mock_options.env['PIGLIT_PLATFORM'] = 'glx' test = PiglitGLTest(['foo'], exclude_platforms=['glx']) with pytest.raises(_TestIsSkip): test.is_skip()
def test_platform_in_require(self, mock_options): """does not skip if platform is in require_platforms.""" mock_options.env['PIGLIT_PLATFORM'] = 'glx' test = PiglitGLTest(['foo'], require_platforms=['glx']) test.is_skip()
def test_getter_concurrent(self): """adds -fbo and -auto to concurrent tests.""" test = PiglitGLTest(['foo'], run_concurrent=True) assert '-auto' in test.command assert '-fbo' in test.command
def test_PiglitGLTest_platform_not_in_exclude(): """test.piglit_test.PiglitGLTest.is_skip(): does not skip if platform is in exclude_platforms""" PiglitGLTest.OPTS.env['PIGLIT_PLATFORM'] = 'gbm' test = PiglitGLTest(['foo'], exclude_platforms=['glx']) test.is_skip()
def test_initialize_piglitgltest(): """ Test that PiglitGLTest initializes correctly """ try: PiglitGLTest(['/bin/true']) except Exception as e: raise AssertionError(e)
def test_PiglitGLTest_platform_not_in_exclude(): """PiglitGLTest.is_skip() does not skip if platform is in exclude_platforms.""" PiglitGLTest.OPTS.env['PIGLIT_PLATFORM'] = 'gbm' test = PiglitGLTest(['foo'], exclude_platforms=['glx']) nt.assert_false(test.is_skip())
def test_PiglitGLTest_platform_in_exclude(): """PiglitGLTest.is_skip() skips if platform is in exclude_platforms..""" PiglitGLTest.OPTS.env['PIGLIT_PLATFORM'] = 'glx' test = PiglitGLTest(['foo'], exclude_platforms=['glx']) nt.assert_true(test.is_skip())
def test_PiglitGLTest_platform_not_in_require(): """PiglitGLTest.is_skip() skips if platform is not in require_platforms.""" PiglitGLTest.OPTS.env['PIGLIT_PLATFORM'] = 'gbm' test = PiglitGLTest(['foo'], require_platforms=['glx']) nt.assert_true(test.is_skip())
def test_PiglitGLTest_platform_in_exclude(mock_opts): """test.piglit_test.PiglitGLTest.is_skip(): skips if platform is in exclude_platforms""" mock_opts.env['PIGLIT_PLATFORM'] = 'glx' test = PiglitGLTest(['foo'], exclude_platforms=['glx']) test.is_skip()
def test_PiglitGLTest_platform_in_require(mock_opts): """test.piglit_test.PiglitGLTest.is_skip(): does not skip if platform is in require_platforms""" mock_opts.env['PIGLIT_PLATFORM'] = 'glx' test = PiglitGLTest(['foo'], require_platforms=['glx']) test.is_skip()
def test_setter_no_add_auto(self): """Doesn't add -fbo or -auto when setting.""" test = PiglitGLTest(['foo'], run_concurrent=True) test.command += ['bar'] assert '-auto' not in test._command assert '-fbo' not in test._command
def test_PiglitGLTest_platform_in_require(): """PiglitGLTest.is_skip() does not skip if platform is in require_platforms.""" PiglitGLTest.OPTS.env['PIGLIT_PLATFORM'] = 'glx' test = PiglitGLTest(['foo'], require_platforms=['glx']) nt.assert_false(test.is_skip())
def test_PiglitGLTest_platform_not_in_require(): """test.piglit_test.PiglitGLTest.is_skip(): skips if platform is not in require_platforms""" PiglitGLTest.OPTS.env['PIGLIT_PLATFORM'] = 'gbm' test = PiglitGLTest(['foo'], require_platforms=['glx']) test.is_skip()
def test_PiglitGLTest_platform_not_in_require(mock_opts): """test.piglit_test.PiglitGLTest.is_skip(): skips if platform is not in require_platforms""" mock_opts.env['PIGLIT_PLATFORM'] = 'gbm' test = PiglitGLTest(['foo'], require_platforms=['glx']) test.is_skip()
def test_getter_serial(self): """adds -auto to serial tests.""" test = PiglitGLTest(['foo']) assert '-auto' in test.command
def test_PiglitGLTest_platform_not_in_exclude(mock_opts): """test.piglit_test.PiglitGLTest.is_skip(): does not skip if platform is in exclude_platforms""" mock_opts.env['PIGLIT_PLATFORM'] = 'gbm' test = PiglitGLTest(['foo'], exclude_platforms=['glx']) test.is_skip()
def test_include_and_exclude(self): """ raises if include and exclude are given.""" with pytest.raises(AssertionError): PiglitGLTest(['foo'], require_platforms=['glx'], exclude_platforms=['gbm'])
def test_initialize_piglitgltest(): """test.piglit_test.PiglitGLTest: Class initializes""" PiglitGLTest(['/bin/true'])
def test_platform_not_in_require(self, mock_options): """skips if platform is not in require_platforms.""" mock_options.env['PIGLIT_PLATFORM'] = 'gbm' test = PiglitGLTest(['foo'], require_platforms=['glx']) with pytest.raises(_TestIsSkip): test.is_skip()
def test_piglittest_command_getter_serial(): """test.piglit_test.PiglitGLTest.command: adds -auto to serial tests""" test = PiglitGLTest(['foo']) nt.assert_in('-auto', test.command)
def test_platform_not_in_exclude(self, mock_options): """does not skip if platform is in exclude_platforms.""" mock_options.env['PIGLIT_PLATFORM'] = 'gbm' test = PiglitGLTest(['foo'], exclude_platforms=['glx']) test.is_skip()
def test_signature(self): test = PiglitGLTest(['foo'], env=None)