Reviewers: Sven, Søren Gjesse,
Description:
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).
[email protected],[email protected]
BUG=
TEST=
Please review this at http://codereview.chromium.org/7354027/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/natives.h
M test/cctest/SConscript
M test/cctest/log-eq-of-logging-and-traversal.js
M test/cctest/test-log.cc
Index: src/natives.h
diff --git a/src/natives.h b/src/natives.h
index
a2831863ad006a5111f2eeaef4328fd0509f922b..5f34420d0b2d94d4037416df393583160d3131f0
100644
--- a/src/natives.h
+++ b/src/natives.h
@@ -36,7 +36,7 @@ typedef bool (*NativeSourceCallback)(Vector<const char>
name,
int index);
enum NativeType {
- CORE, EXPERIMENTAL, D8
+ CORE, EXPERIMENTAL, D8, TEST
};
template <NativeType type>
Index: test/cctest/SConscript
diff --git a/test/cctest/SConscript b/test/cctest/SConscript
index
0ef5667abd286e1c7238080a8e18edd8ff74c7d4..9dc41517acfb151621956ac275f2f44588c98a88
100644
--- a/test/cctest/SConscript
+++ b/test/cctest/SConscript
@@ -29,9 +29,23 @@ import sys
from os.path import join, dirname, abspath
root_dir = dirname(File('SConstruct').rfile().abspath)
sys.path.append(join(root_dir, 'tools'))
+import js2c
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
+'''.split()
+
+
SOURCES = {
'all': [
'gay-fixed.cc',
@@ -109,9 +123,19 @@ def Build():
env = Environment(tools=tools)
env.Replace(**context.flags['cctest'])
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
# PDB files when compiling using MSVC so we specify it manually.
# This should not affect any other platforms.
+ object_files.append(js_files_obj)
return env.Program('cctest', ['cctest.cc', cctest_files, object_files],
PDB='cctest.exe.pdb')
Index: test/cctest/log-eq-of-logging-and-traversal.js
diff --git a/test/cctest/log-eq-of-logging-and-traversal.js
b/test/cctest/log-eq-of-logging-and-traversal.js
index
e661efe023a532da4786e0b9e986c7cc24598b36..cd52da545a6d9ae24d69c61b52aa28349769cfbd
100644
--- a/test/cctest/log-eq-of-logging-and-traversal.js
+++ b/test/cctest/log-eq-of-logging-and-traversal.js
@@ -137,36 +137,38 @@ function RunTest() {
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 equal = true;
// 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
// functions traversal may erroneously recognize them as functions, so
we are
// expecting more functions in traversal vs. logging.
- while (i < k && j < l) {
- var entryA = logging_entries[i], entryB = traversal_entries[j];
+ while (l_pos < l_len && t_pos < t_len) {
+ var entryA = logging_entries[l_pos];
+ var entryB = traversal_entries[t_pos];
var cmp = addressComparator(entryA, entryB);
var entityA = entryA[1], entityB = entryB[1];
var address = entryA[0];
if (cmp < 0) {
- ++i;
+ ++l_pos;
entityB = null;
} else if (cmp > 0) {
- ++j;
+ ++t_pos;
entityA = null;
address = entryB[0];
} else {
- ++i;
- ++j;
+ ++l_pos;
+ ++t_pos;
}
var entities_equal = entitiesEqual(entityA, entityB);
if (!entities_equal) equal = false;
comparison.push([entities_equal, address, entityA, entityB]);
}
- if (i < k) equal = false;
- while (i < k) {
- var entryA = logging_entries[i++];
+ if (l_pos < l_len) equal = false;
+ while (l_pos < l_len) {
+ var entryA = logging_entries[l_pos++];
comparison.push([false, entryA[0], entryA[1], null]);
}
return [equal, comparison];
Index: test/cctest/test-log.cc
diff --git a/test/cctest/test-log.cc b/test/cctest/test-log.cc
index
5704b07ace5fce9fe2e89027b5a92973477253df..262e7bb505264909b277ecc406d2f9cf30028ac4
100644
--- a/test/cctest/test-log.cc
+++ b/test/cctest/test-log.cc
@@ -12,6 +12,7 @@
#include "v8.h"
#include "log.h"
#include "cpu-profiler.h"
+#include "natives.h"
#include "v8threads.h"
#include "v8utils.h"
#include "cctest.h"
@@ -469,6 +470,8 @@ TEST(IsLoggingPreserved) {
}
+typedef i::NativesCollection<i::TEST> TestSources;
+
// Test that logging of code create / move / delete events
// is equivalent to traversal of a resulting heap.
TEST(EquivalenceOfLoggingAndTraversal) {
@@ -505,38 +508,25 @@ TEST(EquivalenceOfLoggingAndTraversal) {
v8::Handle<v8::String> log_str = v8::String::New(log.start(),
log.length());
initialize_logger.env()->Global()->Set(v8_str("_log"), log_str);
- const char* scripts[] = {
- "tools/splaytree.js", "tools/codemap.js", "tools/csvparser.js",
- "tools/consarray.js", "tools/profile.js", "tools/profile_view.js",
- "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::Handle<v8::Script> script =
- v8::Script::Compile(source_str, v8_str(scripts[i]));
- if (script.IsEmpty()) {
- v8::String::Utf8Value exception(try_catch.Exception());
- printf("compile %s: %s\n", scripts[i], *exception);
- CHECK(false);
- }
- last_result = script->Run();
- if (last_result.IsEmpty()) {
- v8::String::Utf8Value exception(try_catch.Exception());
- printf("run %s: %s\n", scripts[i], *exception);
- CHECK(false);
- }
+ i::Vector<const unsigned char> source = TestSources::GetScriptsSource();
+ v8::Handle<v8::String> source_str = v8::String::New(
+ reinterpret_cast<const char*>(source.start()), source.length());
+ v8::TryCatch try_catch;
+ v8::Handle<v8::Script> script = v8::Script::Compile(source_str,
v8_str(""));
+ if (script.IsEmpty()) {
+ v8::String::Utf8Value exception(try_catch.Exception());
+ printf("compile: %s\n", *exception);
+ CHECK(false);
+ }
+ v8::Handle<v8::Value> result = script->Run();
+ if (result.IsEmpty()) {
+ v8::String::Utf8Value exception(try_catch.Exception());
+ printf("run: %s\n", *exception);
+ CHECK(false);
}
// The result either be a "true" literal or problem description.
- if (!last_result->IsTrue()) {
- v8::Local<v8::String> s = last_result->ToString();
+ if (!result->IsTrue()) {
+ v8::Local<v8::String> s = result->ToString();
i::ScopedVector<char> data(s->Length() + 1);
CHECK_NE(NULL, data.start());
s->WriteAscii(data.start());
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev