blob: b15342eda03930b6576f8ff94956a6695f2fdea2 [file] [log] [blame]
ager@chromium.org9258b6b2008-09-11 09:11:10 +00001# Copyright 2008 the V8 project authors. All rights reserved.
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +00002# Redistribution and use in source and binary forms, with or without
3# modification, are permitted provided that the following conditions are
4# met:
5#
6# * Redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer.
8# * Redistributions in binary form must reproduce the above
9# copyright notice, this list of conditions and the following
10# disclaimer in the documentation and/or other materials provided
11# with the distribution.
12# * Neither the name of Google Inc. nor the names of its
13# contributors may be used to endorse or promote products derived
14# from this software without specific prior written permission.
15#
16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28import test
29import os
ager@chromium.orgc27e4e72008-09-04 13:52:27 +000030from os.path import join, dirname, exists
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000031import platform
ager@chromium.org870a0b62008-11-04 11:43:05 +000032import utils
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000033
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000034
35class CcTestCase(test.TestCase):
36
iposva@chromium.org245aa852009-02-10 00:49:54 +000037 def __init__(self, path, executable, mode, raw_name, dependency, context):
ricow@chromium.org65fae842010-08-25 15:26:24 +000038 super(CcTestCase, self).__init__(context, path, mode)
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000039 self.executable = executable
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000040 self.raw_name = raw_name
iposva@chromium.org245aa852009-02-10 00:49:54 +000041 self.dependency = dependency
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000042
43 def GetLabel(self):
44 return "%s %s %s" % (self.mode, self.path[-2], self.path[-1])
45
46 def GetName(self):
47 return self.path[-1]
ager@chromium.org41826e72009-03-30 13:30:57 +000048
iposva@chromium.org245aa852009-02-10 00:49:54 +000049 def BuildCommand(self, name):
50 serialization_file = join('obj', 'test', self.mode, 'serdes')
51 serialization_file += '_' + self.GetName()
52 serialization_option = '--testing_serialization_file=' + serialization_file
53 result = [ self.executable, name, serialization_option ]
ricow@chromium.org65fae842010-08-25 15:26:24 +000054 result += self.context.GetVmFlags(self, self.mode)
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000055 return result
56
iposva@chromium.org245aa852009-02-10 00:49:54 +000057 def GetCommand(self):
58 return self.BuildCommand(self.raw_name)
ager@chromium.org41826e72009-03-30 13:30:57 +000059
iposva@chromium.org245aa852009-02-10 00:49:54 +000060 def Run(self):
61 if self.dependency != '':
62 dependent_command = self.BuildCommand(self.dependency)
63 output = self.RunCommand(dependent_command)
ager@chromium.org41826e72009-03-30 13:30:57 +000064 if output.HasFailed():
iposva@chromium.org245aa852009-02-10 00:49:54 +000065 return output
66 return test.TestCase.Run(self)
67
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000068
69class CcTestConfiguration(test.TestConfiguration):
70
71 def __init__(self, context, root):
72 super(CcTestConfiguration, self).__init__(context, root)
73
74 def GetBuildRequirements(self):
75 return ['cctests']
76
77 def ListTests(self, current_path, path, mode):
78 executable = join('obj', 'test', mode, 'cctest')
ager@chromium.org870a0b62008-11-04 11:43:05 +000079 if utils.IsWindows():
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000080 executable += '.exe'
81 output = test.Execute([executable, '--list'], self.context)
82 if output.exit_code != 0:
83 print output.stdout
84 print output.stderr
85 return []
86 result = []
iposva@chromium.org245aa852009-02-10 00:49:54 +000087 for test_desc in output.stdout.strip().split():
88 raw_test, dependency = test_desc.split('<')
89 relative_path = raw_test.split('/')
90 full_path = current_path + relative_path
91 if dependency != '':
92 dependency = relative_path[0] + '/' + dependency
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000093 if self.Contains(path, full_path):
iposva@chromium.org245aa852009-02-10 00:49:54 +000094 result.append(CcTestCase(full_path, executable, mode, raw_test, dependency, self.context))
sgjesse@chromium.orgc6c57182011-01-17 12:24:25 +000095 result.sort()
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000096 return result
ager@chromium.org41826e72009-03-30 13:30:57 +000097
ager@chromium.orgc27e4e72008-09-04 13:52:27 +000098 def GetTestStatus(self, sections, defs):
99 status_file = join(self.root, 'cctest.status')
100 if exists(status_file):
101 test.ReadConfigurationInto(status_file, sections, defs)
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000102
103
104def GetConfiguration(context, root):
105 return CcTestConfiguration(context, root)