testcfg.py revision b8e0da25ee8efac3bb05cd6b2730aafbd96119f4
1a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# Copyright 2008 the V8 project authors. All rights reserved. 2a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# Redistribution and use in source and binary forms, with or without 3a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# modification, are permitted provided that the following conditions are 4a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# met: 5a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# 6a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# * Redistributions of source code must retain the above copyright 7a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# notice, this list of conditions and the following disclaimer. 8a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# * Redistributions in binary form must reproduce the above 9a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# copyright notice, this list of conditions and the following 10a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# disclaimer in the documentation and/or other materials provided 11a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# with the distribution. 12a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# * Neither the name of Google Inc. nor the names of its 13a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# contributors may be used to endorse or promote products derived 14a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# from this software without specific prior written permission. 15a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# 16a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 28a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockimport test 29a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockimport os 30a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockfrom os.path import join, dirname, exists 31a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockimport platform 32a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockimport utils 33a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 34a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 35a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass CcTestCase(test.TestCase): 36a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 37a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block def __init__(self, path, executable, mode, raw_name, dependency, context): 3880d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen super(CcTestCase, self).__init__(context, path, mode) 39a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block self.executable = executable 40a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block self.raw_name = raw_name 41a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block self.dependency = dependency 42a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 43a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block def GetLabel(self): 44a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block return "%s %s %s" % (self.mode, self.path[-2], self.path[-1]) 45a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 46a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block def GetName(self): 47a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block return self.path[-1] 48a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 49a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block def BuildCommand(self, name): 50a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block serialization_file = join('obj', 'test', self.mode, 'serdes') 51a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block serialization_file += '_' + self.GetName() 52a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block serialization_option = '--testing_serialization_file=' + serialization_file 53a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block result = [ self.executable, name, serialization_option ] 5480d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen result += self.context.GetVmFlags(self, self.mode) 55a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block return result 56a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 57a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block def GetCommand(self): 58a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block return self.BuildCommand(self.raw_name) 59a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 60a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block def Run(self): 61a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block if self.dependency != '': 62a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block dependent_command = self.BuildCommand(self.dependency) 63a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block output = self.RunCommand(dependent_command) 64a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block if output.HasFailed(): 65a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block return output 66a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block return test.TestCase.Run(self) 67a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 68a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 69a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass CcTestConfiguration(test.TestConfiguration): 70a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 71a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block def __init__(self, context, root): 72a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block super(CcTestConfiguration, self).__init__(context, root) 73a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 74a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block def GetBuildRequirements(self): 75a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block return ['cctests'] 76a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 77a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block def ListTests(self, current_path, path, mode): 78a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block executable = join('obj', 'test', mode, 'cctest') 79a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block if utils.IsWindows(): 80a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block executable += '.exe' 81a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block output = test.Execute([executable, '--list'], self.context) 82a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block if output.exit_code != 0: 83a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block print output.stdout 84a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block print output.stderr 85a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block return [] 86a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block result = [] 87a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block for test_desc in output.stdout.strip().split(): 88a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block raw_test, dependency = test_desc.split('<') 89a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block relative_path = raw_test.split('/') 90a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block full_path = current_path + relative_path 91a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block if dependency != '': 92a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block dependency = relative_path[0] + '/' + dependency 93a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block if self.Contains(path, full_path): 94a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block result.append(CcTestCase(full_path, executable, mode, raw_test, dependency, self.context)) 95b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch result.sort() 96a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block return result 97a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 98a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block def GetTestStatus(self, sections, defs): 99a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block status_file = join(self.root, 'cctest.status') 100a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block if exists(status_file): 101a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block test.ReadConfigurationInto(status_file, sections, defs) 102a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 103a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 104a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockdef GetConfiguration(context, root): 105a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block return CcTestConfiguration(context, root) 106