Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3055)

Unified Diff: runtime/vm/snapshot_test.cc

Issue 1168223002: Fix for issue 23598, add a Dart_CreateLibrarySnapshot entrypoint to the API. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address code review comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/snapshot_test.cc
diff --git a/runtime/vm/snapshot_test.cc b/runtime/vm/snapshot_test.cc
index 6707566f534756675fd1bd4f27eabab5aa754b5a..5c9a28a5d3c739105a5d6abe4595042a78dbbbd6 100644
--- a/runtime/vm/snapshot_test.cc
+++ b/runtime/vm/snapshot_test.cc
@@ -1253,6 +1253,8 @@ UNIT_TEST_CASE(ScriptSnapshot) {
}
FLAG_load_deferred_eagerly = saved_load_deferred_eagerly_mode;
+
+ // Test for Dart_CreateScriptSnapshot.
{
// Create an Isolate using the full snapshot, load a script and create
// a script snapshot of the script.
@@ -1310,8 +1312,50 @@ UNIT_TEST_CASE(ScriptSnapshot) {
result = Dart_Invoke(cls, NewString("testMain"), 0, NULL);
EXPECT_VALID(result);
Dart_ExitScope();
+ Dart_ShutdownIsolate();
+ }
+ free(script_snapshot);
+
+ // Test for Dart_CreateLibrarySnapshot.
+ {
+ // Create an Isolate using the full snapshot, load a script and create
+ // a script snapshot of the script.
+ TestCase::CreateTestIsolateFromSnapshot(full_snapshot);
+ Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
+
+ // Load the library.
+ Dart_Handle lib = Dart_LoadLibrary(NewString("dart_lib"),
+ NewString(kScriptChars),
+ 0, 0);
+ EXPECT_VALID(lib);
+
+ // Write out the script snapshot.
+ result = Dart_CreateLibrarySnapshot(lib, &buffer, &size);
+ EXPECT_VALID(result);
+ script_snapshot = reinterpret_cast<uint8_t*>(malloc(size));
+ memmove(script_snapshot, buffer, size);
+ Dart_ExitScope();
+ Dart_ShutdownIsolate();
+ }
+
+ {
+ // Now Create an Isolate using the full snapshot and load the
+ // script snapshot created above and execute it.
+ TestCase::CreateTestIsolateFromSnapshot(full_snapshot);
+ Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
+
+ // Load the test library from the snapshot.
+ EXPECT(script_snapshot != NULL);
+ result = Dart_LoadScriptFromSnapshot(script_snapshot, size);
+ EXPECT_VALID(result);
+
+ // Invoke a function which returns an object.
+ Dart_Handle cls = Dart_GetClass(result, NewString("FieldsTest"));
+ result = Dart_Invoke(cls, NewString("testMain"), 0, NULL);
+ EXPECT_VALID(result);
+ Dart_ExitScope();
+ Dart_ShutdownIsolate();
}
- Dart_ShutdownIsolate();
free(full_snapshot);
free(script_snapshot);
}
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698