Convert *.js files of cctest/test-log into "resources".

This allows running cctest from anywhere.

I was to rename single-letter variables in my script due to an encountered issue
in JSMin (http://code.google.com/p/v8/issues/detail?id=1557).

R=svenpanne@chromium.org,sgjesse@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/7354027

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8654 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 615add84
...@@ -36,7 +36,7 @@ typedef bool (*NativeSourceCallback)(Vector<const char> name, ...@@ -36,7 +36,7 @@ typedef bool (*NativeSourceCallback)(Vector<const char> name,
int index); int index);
enum NativeType { enum NativeType {
CORE, EXPERIMENTAL, D8 CORE, EXPERIMENTAL, D8, TEST
}; };
template <NativeType type> template <NativeType type>
......
...@@ -29,9 +29,23 @@ import sys ...@@ -29,9 +29,23 @@ import sys
from os.path import join, dirname, abspath from os.path import join, dirname, abspath
root_dir = dirname(File('SConstruct').rfile().abspath) root_dir = dirname(File('SConstruct').rfile().abspath)
sys.path.append(join(root_dir, 'tools')) sys.path.append(join(root_dir, 'tools'))
import js2c
Import('context object_files tools') Import('context object_files tools')
# Needed for test-log. Paths are relative to the cctest dir.
JS_FILES_FOR_TESTS = [
'../../../tools/splaytree.js',
'../../../tools/codemap.js',
'../../../tools/csvparser.js',
'../../../tools/consarray.js',
'../../../tools/profile.js',
'../../../tools/profile_view.js',
'../../../tools/logreader.js',
'log-eq-of-logging-and-traversal.js',
]
SOURCES = { SOURCES = {
'all': [ 'all': [
'gay-fixed.cc', 'gay-fixed.cc',
...@@ -109,9 +123,19 @@ def Build(): ...@@ -109,9 +123,19 @@ def Build():
env = Environment(tools=tools) env = Environment(tools=tools)
env.Replace(**context.flags['cctest']) env.Replace(**context.flags['cctest'])
context.ApplyEnvOverrides(env) context.ApplyEnvOverrides(env)
env['BUILDERS']['JS2C'] = Builder(action=js2c.JS2C)
# Combine the JavaScript library files into a single C++ file and
# compile it.
js_files = [s for s in JS_FILES_FOR_TESTS]
js_files_src = env.JS2C(
['js-files-for-cctest.cc'], js_files, **{'TYPE': 'TEST', 'COMPRESSION': 'off'})
js_files_obj = context.ConfigureObject(env, js_files_src, CPPPATH=['.'])
# There seems to be a glitch in the way scons decides where to put # There seems to be a glitch in the way scons decides where to put
# PDB files when compiling using MSVC so we specify it manually. # PDB files when compiling using MSVC so we specify it manually.
# This should not affect any other platforms. # This should not affect any other platforms.
object_files.append(js_files_obj)
return env.Program('cctest', ['cctest.cc', cctest_files, object_files], return env.Program('cctest', ['cctest.cc', cctest_files, object_files],
PDB='cctest.exe.pdb') PDB='cctest.exe.pdb')
......
...@@ -137,36 +137,38 @@ function RunTest() { ...@@ -137,36 +137,38 @@ function RunTest() {
return entityA.size === entityB.size && entityNamesEqual(entityA, entityB); return entityA.size === entityB.size && entityNamesEqual(entityA, entityB);
} }
var i = 0, j = 0, k = logging_entries.length, l = traversal_entries.length; var l_pos = 0, t_pos = 0;
var l_len = logging_entries.length, t_len = traversal_entries.length;
var comparison = []; var comparison = [];
var equal = true; var equal = true;
// Do a merge-like comparison of entries. At the same address we expect to // Do a merge-like comparison of entries. At the same address we expect to
// find the same entries. We skip builtins during log parsing, but compiled // find the same entries. We skip builtins during log parsing, but compiled
// functions traversal may erroneously recognize them as functions, so we are // functions traversal may erroneously recognize them as functions, so we are
// expecting more functions in traversal vs. logging. // expecting more functions in traversal vs. logging.
while (i < k && j < l) { while (l_pos < l_len && t_pos < t_len) {
var entryA = logging_entries[i], entryB = traversal_entries[j]; var entryA = logging_entries[l_pos];
var entryB = traversal_entries[t_pos];
var cmp = addressComparator(entryA, entryB); var cmp = addressComparator(entryA, entryB);
var entityA = entryA[1], entityB = entryB[1]; var entityA = entryA[1], entityB = entryB[1];
var address = entryA[0]; var address = entryA[0];
if (cmp < 0) { if (cmp < 0) {
++i; ++l_pos;
entityB = null; entityB = null;
} else if (cmp > 0) { } else if (cmp > 0) {
++j; ++t_pos;
entityA = null; entityA = null;
address = entryB[0]; address = entryB[0];
} else { } else {
++i; ++l_pos;
++j; ++t_pos;
} }
var entities_equal = entitiesEqual(entityA, entityB); var entities_equal = entitiesEqual(entityA, entityB);
if (!entities_equal) equal = false; if (!entities_equal) equal = false;
comparison.push([entities_equal, address, entityA, entityB]); comparison.push([entities_equal, address, entityA, entityB]);
} }
if (i < k) equal = false; if (l_pos < l_len) equal = false;
while (i < k) { while (l_pos < l_len) {
var entryA = logging_entries[i++]; var entryA = logging_entries[l_pos++];
comparison.push([false, entryA[0], entryA[1], null]); comparison.push([false, entryA[0], entryA[1], null]);
} }
return [equal, comparison]; return [equal, comparison];
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "v8.h" #include "v8.h"
#include "log.h" #include "log.h"
#include "cpu-profiler.h" #include "cpu-profiler.h"
#include "natives.h"
#include "v8threads.h" #include "v8threads.h"
#include "v8utils.h" #include "v8utils.h"
#include "cctest.h" #include "cctest.h"
...@@ -469,6 +470,8 @@ TEST(IsLoggingPreserved) { ...@@ -469,6 +470,8 @@ TEST(IsLoggingPreserved) {
} }
typedef i::NativesCollection<i::TEST> TestSources;
// Test that logging of code create / move / delete events // Test that logging of code create / move / delete events
// is equivalent to traversal of a resulting heap. // is equivalent to traversal of a resulting heap.
TEST(EquivalenceOfLoggingAndTraversal) { TEST(EquivalenceOfLoggingAndTraversal) {
...@@ -505,38 +508,25 @@ TEST(EquivalenceOfLoggingAndTraversal) { ...@@ -505,38 +508,25 @@ TEST(EquivalenceOfLoggingAndTraversal) {
v8::Handle<v8::String> log_str = v8::String::New(log.start(), log.length()); v8::Handle<v8::String> log_str = v8::String::New(log.start(), log.length());
initialize_logger.env()->Global()->Set(v8_str("_log"), log_str); initialize_logger.env()->Global()->Set(v8_str("_log"), log_str);
const char* scripts[] = { i::Vector<const unsigned char> source = TestSources::GetScriptsSource();
"tools/splaytree.js", "tools/codemap.js", "tools/csvparser.js", v8::Handle<v8::String> source_str = v8::String::New(
"tools/consarray.js", "tools/profile.js", "tools/profile_view.js", reinterpret_cast<const char*>(source.start()), source.length());
"tools/logreader.js", "test/cctest/log-eq-of-logging-and-traversal.js"
};
int scripts_count = sizeof(scripts) / sizeof(scripts[0]);
v8::Handle<v8::Value> last_result;
for (int i = 0; i < scripts_count; ++i) {
bool exists = true;
i::Vector<const char> source(i::ReadFile(scripts[i], &exists, true));
CHECK(exists);
CHECK_GT(source.length(), 0);
v8::Handle<v8::String> source_str =
v8::String::New(source.start(), source.length());
v8::TryCatch try_catch; v8::TryCatch try_catch;
v8::Handle<v8::Script> script = v8::Handle<v8::Script> script = v8::Script::Compile(source_str, v8_str(""));
v8::Script::Compile(source_str, v8_str(scripts[i]));
if (script.IsEmpty()) { if (script.IsEmpty()) {
v8::String::Utf8Value exception(try_catch.Exception()); v8::String::Utf8Value exception(try_catch.Exception());
printf("compile %s: %s\n", scripts[i], *exception); printf("compile: %s\n", *exception);
CHECK(false); CHECK(false);
} }
last_result = script->Run(); v8::Handle<v8::Value> result = script->Run();
if (last_result.IsEmpty()) { if (result.IsEmpty()) {
v8::String::Utf8Value exception(try_catch.Exception()); v8::String::Utf8Value exception(try_catch.Exception());
printf("run %s: %s\n", scripts[i], *exception); printf("run: %s\n", *exception);
CHECK(false); CHECK(false);
} }
}
// The result either be a "true" literal or problem description. // The result either be a "true" literal or problem description.
if (!last_result->IsTrue()) { if (!result->IsTrue()) {
v8::Local<v8::String> s = last_result->ToString(); v8::Local<v8::String> s = result->ToString();
i::ScopedVector<char> data(s->Length() + 1); i::ScopedVector<char> data(s->Length() + 1);
CHECK_NE(NULL, data.start()); CHECK_NE(NULL, data.start());
s->WriteAscii(data.start()); s->WriteAscii(data.start());
......
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