Commit da4fdea6 authored by olehougaard's avatar olehougaard

Fixing the flakiness of the serialization tests by assuring that serialization...

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
parent c5964cb7
...@@ -35,9 +35,9 @@ ...@@ -35,9 +35,9 @@
CcTest* CcTest::last_ = NULL; CcTest* CcTest::last_ = NULL;
CcTest::CcTest(TestFunction* callback, const char* file, CcTest::CcTest(TestFunction* callback, const char* file, const char* name,
const char* name, bool enabled) const char* dependency, bool enabled)
: callback_(callback), name_(name), prev_(last_) { : callback_(callback), name_(name), dependency_(dependency), prev_(last_) {
// Find the base name of this test (const_cast required on Windows). // Find the base name of this test (const_cast required on Windows).
char *basename = strrchr(const_cast<char *>(file), '/'); char *basename = strrchr(const_cast<char *>(file), '/');
if (!basename) { if (!basename) {
...@@ -62,7 +62,11 @@ CcTest::CcTest(TestFunction* callback, const char* file, ...@@ -62,7 +62,11 @@ CcTest::CcTest(TestFunction* callback, const char* file,
static void PrintTestList(CcTest* current) { static void PrintTestList(CcTest* current) {
if (current == NULL) return; if (current == NULL) return;
PrintTestList(current->prev()); 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());
}
} }
......
...@@ -29,16 +29,23 @@ ...@@ -29,16 +29,23 @@
#define CCTEST_H_ #define CCTEST_H_
#ifndef TEST #ifndef TEST
#define TEST(Name) \ #define TEST(Name) \
static void Test##Name(); \ static void Test##Name(); \
CcTest register_test_##Name(Test##Name, __FILE__, #Name, true); \ 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() static void Test##Name()
#endif #endif
#ifndef DISABLED_TEST #ifndef DISABLED_TEST
#define DISABLED_TEST(Name) \ #define DISABLED_TEST(Name) \
static void Test##Name(); \ static void Test##Name(); \
CcTest register_test_##Name(Test##Name, __FILE__, #Name, false); \ CcTest register_test_##Name(Test##Name, __FILE__, #Name, NULL, false); \
static void Test##Name() static void Test##Name()
#endif #endif
...@@ -46,18 +53,20 @@ class CcTest { ...@@ -46,18 +53,20 @@ class CcTest {
public: public:
typedef void (TestFunction)(); typedef void (TestFunction)();
CcTest(TestFunction* callback, const char* file, const char* name, CcTest(TestFunction* callback, const char* file, const char* name,
bool enabled); const char* dependency, bool enabled);
void Run() { callback_(); } void Run() { callback_(); }
static int test_count(); static int test_count();
static CcTest* last() { return last_; } static CcTest* last() { return last_; }
CcTest* prev() { return prev_; } CcTest* prev() { return prev_; }
const char* file() { return file_; } const char* file() { return file_; }
const char* name() { return name_; } const char* name() { return name_; }
const char* dependency() { return dependency_; }
bool enabled() { return enabled_; } bool enabled() { return enabled_; }
private: private:
TestFunction* callback_; TestFunction* callback_;
const char* file_; const char* file_;
const char* name_; const char* name_;
const char* dependency_;
bool enabled_; bool enabled_;
static CcTest* last_; static CcTest* last_;
CcTest* prev_; CcTest* prev_;
......
...@@ -221,7 +221,7 @@ static void SanityCheck() { ...@@ -221,7 +221,7 @@ static void SanityCheck() {
} }
TEST(Deserialize) { DEPENDENT_TEST(Deserialize, Serialize) {
v8::HandleScope scope; v8::HandleScope scope;
Deserialize(); Deserialize();
...@@ -229,7 +229,7 @@ TEST(Deserialize) { ...@@ -229,7 +229,7 @@ TEST(Deserialize) {
SanityCheck(); SanityCheck();
} }
TEST(DeserializeAndRunScript) { DEPENDENT_TEST(DeserializeAndRunScript, Serialize) {
v8::HandleScope scope; v8::HandleScope scope;
Deserialize(); Deserialize();
...@@ -241,7 +241,7 @@ TEST(DeserializeAndRunScript) { ...@@ -241,7 +241,7 @@ TEST(DeserializeAndRunScript) {
} }
TEST(DeserializeNatives) { DEPENDENT_TEST(DeserializeNatives, Serialize) {
v8::HandleScope scope; v8::HandleScope scope;
Deserialize(); Deserialize();
...@@ -254,7 +254,7 @@ TEST(DeserializeNatives) { ...@@ -254,7 +254,7 @@ TEST(DeserializeNatives) {
} }
TEST(DeserializeExtensions) { DEPENDENT_TEST(DeserializeExtensions, Serialize) {
v8::HandleScope scope; v8::HandleScope scope;
Deserialize(); Deserialize();
......
...@@ -36,26 +36,38 @@ DEBUG_FLAGS = ['--enable-slow-asserts', '--debug-code', '--verify-heap'] ...@@ -36,26 +36,38 @@ DEBUG_FLAGS = ['--enable-slow-asserts', '--debug-code', '--verify-heap']
class CcTestCase(test.TestCase): 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) super(CcTestCase, self).__init__(context, path)
self.executable = executable self.executable = executable
self.mode = mode self.mode = mode
self.raw_name = raw_name self.raw_name = raw_name
self.dependency = dependency
def GetLabel(self): def GetLabel(self):
return "%s %s %s" % (self.mode, self.path[-2], self.path[-1]) return "%s %s %s" % (self.mode, self.path[-2], self.path[-1])
def GetName(self): def GetName(self):
return self.path[-1] return self.path[-1]
def GetCommand(self): def BuildCommand(self, name):
serialization_file = join('obj', 'test', self.mode, 'serdes') serialization_file = join('obj', 'test', self.mode, 'serdes')
serialization_option = '--testing_serialization_file=' + serialization_file 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': if self.mode == 'debug':
result += DEBUG_FLAGS result += DEBUG_FLAGS
return result 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): class CcTestConfiguration(test.TestConfiguration):
...@@ -75,10 +87,14 @@ class CcTestConfiguration(test.TestConfiguration): ...@@ -75,10 +87,14 @@ class CcTestConfiguration(test.TestConfiguration):
print output.stderr print output.stderr
return [] return []
result = [] result = []
for raw_test in output.stdout.strip().split(): for test_desc in output.stdout.strip().split():
full_path = current_path + raw_test.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): 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 return result
def GetTestStatus(self, sections, defs): def GetTestStatus(self, sections, defs):
......
...@@ -345,13 +345,15 @@ class TestCase(object): ...@@ -345,13 +345,15 @@ class TestCase(object):
def GetSource(self): def GetSource(self):
return "(no source available)" return "(no source available)"
def Run(self): def RunCommand(self, command):
command = self.GetCommand()
full_command = self.context.processor(command) full_command = self.context.processor(command)
output = Execute(full_command, self.context, self.context.timeout) output = Execute(full_command, self.context, self.context.timeout)
return TestOutput(self, full_command, output) return TestOutput(self, full_command, output)
def Run(self):
return self.RunCommand(self.GetCommand())
class TestOutput(object): class TestOutput(object):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment