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
This commit is contained in:
olehougaard 2009-02-03 08:35:03 +00:00
parent c5964cb7ad
commit da4fdea61a
5 changed files with 56 additions and 25 deletions

View File

@ -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<char *>(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());
}
}

View File

@ -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_;

View File

@ -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();

View File

@ -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):

View File

@ -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):