ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 1 | # Copyright 2008 the V8 project authors. All rights reserved. |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 2 | # 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 | |
| 28 | import test |
| 29 | import os |
ager@chromium.org | c27e4e7 | 2008-09-04 13:52:27 +0000 | [diff] [blame] | 30 | from os.path import join, dirname, exists |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 31 | import platform |
ager@chromium.org | 870a0b6 | 2008-11-04 11:43:05 +0000 | [diff] [blame] | 32 | import utils |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 33 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 34 | |
| 35 | class CcTestCase(test.TestCase): |
| 36 | |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 37 | def __init__(self, path, executable, mode, raw_name, dependency, context): |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 38 | super(CcTestCase, self).__init__(context, path, mode) |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 39 | self.executable = executable |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 40 | self.raw_name = raw_name |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 41 | self.dependency = dependency |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 42 | |
| 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.org | 41826e7 | 2009-03-30 13:30:57 +0000 | [diff] [blame] | 48 | |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 49 | 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.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 54 | result += self.context.GetVmFlags(self, self.mode) |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 55 | return result |
| 56 | |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 57 | def GetCommand(self): |
| 58 | return self.BuildCommand(self.raw_name) |
ager@chromium.org | 41826e7 | 2009-03-30 13:30:57 +0000 | [diff] [blame] | 59 | |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 60 | def Run(self): |
| 61 | if self.dependency != '': |
| 62 | dependent_command = self.BuildCommand(self.dependency) |
| 63 | output = self.RunCommand(dependent_command) |
ager@chromium.org | 41826e7 | 2009-03-30 13:30:57 +0000 | [diff] [blame] | 64 | if output.HasFailed(): |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 65 | return output |
| 66 | return test.TestCase.Run(self) |
| 67 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 68 | |
| 69 | class 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.org | 870a0b6 | 2008-11-04 11:43:05 +0000 | [diff] [blame] | 79 | if utils.IsWindows(): |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 80 | 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.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 87 | 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.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 93 | if self.Contains(path, full_path): |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 94 | result.append(CcTestCase(full_path, executable, mode, raw_test, dependency, self.context)) |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 95 | result.sort() |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 96 | return result |
ager@chromium.org | 41826e7 | 2009-03-30 13:30:57 +0000 | [diff] [blame] | 97 | |
ager@chromium.org | c27e4e7 | 2008-09-04 13:52:27 +0000 | [diff] [blame] | 98 | 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.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 102 | |
| 103 | |
| 104 | def GetConfiguration(context, root): |
| 105 | return CcTestConfiguration(context, root) |