From da4fdea61a04d0d9ea50451b1e57ebb332221194 Mon Sep 17 00:00:00 2001 From: olehougaard Date: Tue, 3 Feb 2009 08:35:03 +0000 Subject: [PATCH] Fixing the flakiness of the serialization tests by assuring that serialization is run before every deserialization test. Review URL: http://codereview.chromium.org/19541 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1214 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- test/cctest/cctest.cc | 12 ++++++++---- test/cctest/cctest.h | 23 ++++++++++++++++------- test/cctest/test-serialize.cc | 8 ++++---- test/cctest/testcfg.py | 30 +++++++++++++++++++++++------- tools/test.py | 8 +++++--- 5 files changed, 56 insertions(+), 25 deletions(-) diff --git a/test/cctest/cctest.cc b/test/cctest/cctest.cc index e9c8f0d..d4e1861 100644 --- a/test/cctest/cctest.cc +++ b/test/cctest/cctest.cc @@ -35,9 +35,9 @@ CcTest* CcTest::last_ = NULL; -CcTest::CcTest(TestFunction* callback, const char* file, - const char* name, bool enabled) - : callback_(callback), name_(name), prev_(last_) { +CcTest::CcTest(TestFunction* callback, const char* file, const char* name, + const char* dependency, bool enabled) + : callback_(callback), name_(name), dependency_(dependency), prev_(last_) { // Find the base name of this test (const_cast required on Windows). char *basename = strrchr(const_cast(file), '/'); if (!basename) { @@ -62,7 +62,11 @@ CcTest::CcTest(TestFunction* callback, const char* file, static void PrintTestList(CcTest* current) { if (current == NULL) return; PrintTestList(current->prev()); - printf("%s/%s\n", current->file(), current->name()); + if (current->dependency() != NULL) { + printf("%s/%s<%s\n", current->file(), current->name(), current->dependency()); + } else { + printf("%s/%s<\n", current->file(), current->name()); + } } diff --git a/test/cctest/cctest.h b/test/cctest/cctest.h index d6d1ba3..a95645e 100644 --- a/test/cctest/cctest.h +++ b/test/cctest/cctest.h @@ -29,16 +29,23 @@ #define CCTEST_H_ #ifndef TEST -#define TEST(Name) \ - static void Test##Name(); \ - CcTest register_test_##Name(Test##Name, __FILE__, #Name, true); \ +#define TEST(Name) \ + static void Test##Name(); \ + CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, true); \ + static void Test##Name() +#endif + +#ifndef DEPENDENT_TEST +#define DEPENDENT_TEST(Name, Dep) \ + static void Test##Name(); \ + CcTest register_test_##Name(Test##Name, __FILE__, #Name, #Dep, true); \ static void Test##Name() #endif #ifndef DISABLED_TEST -#define DISABLED_TEST(Name) \ - static void Test##Name(); \ - CcTest register_test_##Name(Test##Name, __FILE__, #Name, false); \ +#define DISABLED_TEST(Name) \ + static void Test##Name(); \ + CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, false); \ static void Test##Name() #endif @@ -46,18 +53,20 @@ class CcTest { public: typedef void (TestFunction)(); CcTest(TestFunction* callback, const char* file, const char* name, - bool enabled); + const char* dependency, bool enabled); void Run() { callback_(); } static int test_count(); static CcTest* last() { return last_; } CcTest* prev() { return prev_; } const char* file() { return file_; } const char* name() { return name_; } + const char* dependency() { return dependency_; } bool enabled() { return enabled_; } private: TestFunction* callback_; const char* file_; const char* name_; + const char* dependency_; bool enabled_; static CcTest* last_; CcTest* prev_; diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc index 03765a8..3b7fa90 100644 --- a/test/cctest/test-serialize.cc +++ b/test/cctest/test-serialize.cc @@ -221,7 +221,7 @@ static void SanityCheck() { } -TEST(Deserialize) { +DEPENDENT_TEST(Deserialize, Serialize) { v8::HandleScope scope; Deserialize(); @@ -229,7 +229,7 @@ TEST(Deserialize) { SanityCheck(); } -TEST(DeserializeAndRunScript) { +DEPENDENT_TEST(DeserializeAndRunScript, Serialize) { v8::HandleScope scope; Deserialize(); @@ -241,7 +241,7 @@ TEST(DeserializeAndRunScript) { } -TEST(DeserializeNatives) { +DEPENDENT_TEST(DeserializeNatives, Serialize) { v8::HandleScope scope; Deserialize(); @@ -254,7 +254,7 @@ TEST(DeserializeNatives) { } -TEST(DeserializeExtensions) { +DEPENDENT_TEST(DeserializeExtensions, Serialize) { v8::HandleScope scope; Deserialize(); diff --git a/test/cctest/testcfg.py b/test/cctest/testcfg.py index b6ee453..3200e41 100644 --- a/test/cctest/testcfg.py +++ b/test/cctest/testcfg.py @@ -36,26 +36,38 @@ DEBUG_FLAGS = ['--enable-slow-asserts', '--debug-code', '--verify-heap'] class CcTestCase(test.TestCase): - def __init__(self, path, executable, mode, raw_name, context): + def __init__(self, path, executable, mode, raw_name, dependency, context): super(CcTestCase, self).__init__(context, path) self.executable = executable self.mode = mode self.raw_name = raw_name + self.dependency = dependency def GetLabel(self): return "%s %s %s" % (self.mode, self.path[-2], self.path[-1]) def GetName(self): return self.path[-1] - - def GetCommand(self): + + def BuildCommand(self, name): serialization_file = join('obj', 'test', self.mode, 'serdes') serialization_option = '--testing_serialization_file=' + serialization_file - result = [ self.executable, self.raw_name, serialization_option ] + result = [ self.executable, name, serialization_option ] if self.mode == 'debug': result += DEBUG_FLAGS return result + def GetCommand(self): + return self.BuildCommand(self.raw_name) + + def Run(self): + if self.dependency != '': + dependent_command = self.BuildCommand(self.dependency) + output = self.RunCommand(dependent_command) + if output.HasFailed(): + return output + return test.TestCase.Run(self) + class CcTestConfiguration(test.TestConfiguration): @@ -75,10 +87,14 @@ class CcTestConfiguration(test.TestConfiguration): print output.stderr return [] result = [] - for raw_test in output.stdout.strip().split(): - full_path = current_path + raw_test.split('/') + for test_desc in output.stdout.strip().split(): + raw_test, dependency = test_desc.split('<') + relative_path = raw_test.split('/') + full_path = current_path + relative_path + if dependency != '': + dependency = relative_path[0] + '/' + dependency if self.Contains(path, full_path): - result.append(CcTestCase(full_path, executable, mode, raw_test, self.context)) + result.append(CcTestCase(full_path, executable, mode, raw_test, dependency, self.context)) return result def GetTestStatus(self, sections, defs): diff --git a/tools/test.py b/tools/test.py index 5cff304..ef9cd67 100755 --- a/tools/test.py +++ b/tools/test.py @@ -345,13 +345,15 @@ class TestCase(object): def GetSource(self): return "(no source available)" - - def Run(self): - command = self.GetCommand() + + def RunCommand(self, command): full_command = self.context.processor(command) output = Execute(full_command, self.context, self.context.timeout) return TestOutput(self, full_command, output) + def Run(self): + return self.RunCommand(self.GetCommand()) + class TestOutput(object): -- 2.7.4