Index: runtime/vm/snapshot_test.cc |
diff --git a/runtime/vm/snapshot_test.cc b/runtime/vm/snapshot_test.cc |
index 72e54f8065b4581c7b09bb8860f6f0cd59463621..3897786ffd189591996e0eed9233c352dfa0f505 100644 |
--- a/runtime/vm/snapshot_test.cc |
+++ b/runtime/vm/snapshot_test.cc |
@@ -50,19 +50,16 @@ static bool Equals(const Object& expected, const Object& actual) { |
return false; |
} |
- |
static uint8_t* malloc_allocator(uint8_t* ptr, |
intptr_t old_size, |
intptr_t new_size) { |
return reinterpret_cast<uint8_t*>(realloc(ptr, new_size)); |
} |
- |
static void malloc_deallocator(uint8_t* ptr) { |
free(ptr); |
} |
- |
static uint8_t* zone_allocator(uint8_t* ptr, |
intptr_t old_size, |
intptr_t new_size) { |
@@ -70,10 +67,8 @@ static uint8_t* zone_allocator(uint8_t* ptr, |
return zone->Realloc<uint8_t>(ptr, old_size, new_size); |
} |
- |
static void zone_deallocator(uint8_t* ptr) {} |
- |
// Compare two Dart_CObject object graphs rooted in first and |
// second. The second graph will be destroyed by this operation no matter |
// whether the graphs are equal or not. |
@@ -136,7 +131,6 @@ static void CompareDartCObjects(Dart_CObject* first, Dart_CObject* second) { |
} |
} |
- |
static void CheckEncodeDecodeMessage(Dart_CObject* root) { |
// Encode and decode the message. |
uint8_t* buffer = NULL; |
@@ -152,7 +146,6 @@ static void CheckEncodeDecodeMessage(Dart_CObject* root) { |
free(buffer); |
} |
- |
static void ExpectEncodeFail(Dart_CObject* root) { |
uint8_t* buffer = NULL; |
ApiMessageWriter writer(&buffer, &malloc_allocator); |
@@ -161,7 +154,6 @@ static void ExpectEncodeFail(Dart_CObject* root) { |
free(buffer); |
} |
- |
TEST_CASE(SerializeNull) { |
StackZone zone(thread); |
@@ -186,7 +178,6 @@ TEST_CASE(SerializeNull) { |
CheckEncodeDecodeMessage(root); |
} |
- |
TEST_CASE(SerializeSmi1) { |
StackZone zone(thread); |
@@ -212,7 +203,6 @@ TEST_CASE(SerializeSmi1) { |
CheckEncodeDecodeMessage(root); |
} |
- |
TEST_CASE(SerializeSmi2) { |
StackZone zone(thread); |
@@ -238,7 +228,6 @@ TEST_CASE(SerializeSmi2) { |
CheckEncodeDecodeMessage(root); |
} |
- |
Dart_CObject* SerializeAndDeserializeMint(const Mint& mint) { |
// Write snapshot with object content. |
uint8_t* buffer; |
@@ -264,7 +253,6 @@ Dart_CObject* SerializeAndDeserializeMint(const Mint& mint) { |
return root; |
} |
- |
void CheckMint(int64_t value) { |
ApiNativeScope scope; |
StackZone zone(Thread::Current()); |
@@ -290,7 +278,6 @@ void CheckMint(int64_t value) { |
#endif |
} |
- |
TEST_CASE(SerializeMints) { |
// Min positive mint. |
CheckMint(Smi::kMaxValue + 1); |
@@ -310,7 +297,6 @@ TEST_CASE(SerializeMints) { |
CheckMint(kMinInt64 + 1); |
} |
- |
TEST_CASE(SerializeDouble) { |
StackZone zone(thread); |
@@ -336,7 +322,6 @@ TEST_CASE(SerializeDouble) { |
CheckEncodeDecodeMessage(root); |
} |
- |
TEST_CASE(SerializeTrue) { |
StackZone zone(thread); |
@@ -364,7 +349,6 @@ TEST_CASE(SerializeTrue) { |
CheckEncodeDecodeMessage(root); |
} |
- |
TEST_CASE(SerializeFalse) { |
StackZone zone(thread); |
@@ -390,7 +374,6 @@ TEST_CASE(SerializeFalse) { |
CheckEncodeDecodeMessage(root); |
} |
- |
TEST_CASE(SerializeCapability) { |
// Write snapshot with object content. |
const Capability& capability = Capability::Handle(Capability::New(12345)); |
@@ -417,7 +400,6 @@ TEST_CASE(SerializeCapability) { |
CheckEncodeDecodeMessage(root); |
} |
- |
TEST_CASE(SerializeBigint) { |
// Write snapshot with object content. |
const char* cstr = "0x270FFFFFFFFFFFFFD8F0"; |
@@ -449,7 +431,6 @@ TEST_CASE(SerializeBigint) { |
CheckEncodeDecodeMessage(root); |
} |
- |
Dart_CObject* SerializeAndDeserializeBigint(const Bigint& bigint) { |
// Write snapshot with object content. |
uint8_t* buffer; |
@@ -479,7 +460,6 @@ Dart_CObject* SerializeAndDeserializeBigint(const Bigint& bigint) { |
return root; |
} |
- |
void CheckBigint(const char* bigint_value) { |
ApiNativeScope scope; |
StackZone zone(Thread::Current()); |
@@ -492,7 +472,6 @@ void CheckBigint(const char* bigint_value) { |
free(hex_value); |
} |
- |
TEST_CASE(SerializeBigint2) { |
CheckBigint("0x0"); |
CheckBigint("0x1"); |
@@ -541,7 +520,6 @@ TEST_CASE(SerializeSingletons) { |
free(buffer); |
} |
- |
static void TestString(const char* cstr) { |
Thread* thread = Thread::Current(); |
EXPECT(Utf8::IsValid(reinterpret_cast<const uint8_t*>(cstr), strlen(cstr))); |
@@ -567,7 +545,6 @@ static void TestString(const char* cstr) { |
CheckEncodeDecodeMessage(root); |
} |
- |
TEST_CASE(SerializeString) { |
TestString("This string shall be serialized"); |
TestString("æøå"); // This file is UTF-8 encoded. |
@@ -583,7 +560,6 @@ TEST_CASE(SerializeString) { |
// TODO(sgjesse): Add tests with non-BMP characters. |
} |
- |
TEST_CASE(SerializeArray) { |
// Write snapshot with object content. |
const int kArrayLength = 10; |
@@ -618,7 +594,6 @@ TEST_CASE(SerializeArray) { |
CheckEncodeDecodeMessage(root); |
} |
- |
TEST_CASE(FailSerializeLargeArray) { |
Dart_CObject root; |
root.type = Dart_CObject_kArray; |
@@ -627,7 +602,6 @@ TEST_CASE(FailSerializeLargeArray) { |
ExpectEncodeFail(&root); |
} |
- |
TEST_CASE(FailSerializeLargeNestedArray) { |
Dart_CObject parent; |
Dart_CObject child; |
@@ -641,7 +615,6 @@ TEST_CASE(FailSerializeLargeNestedArray) { |
ExpectEncodeFail(&parent); |
} |
- |
TEST_CASE(FailSerializeLargeTypedDataInt8) { |
Dart_CObject root; |
root.type = Dart_CObject_kTypedData; |
@@ -651,7 +624,6 @@ TEST_CASE(FailSerializeLargeTypedDataInt8) { |
ExpectEncodeFail(&root); |
} |
- |
TEST_CASE(FailSerializeLargeTypedDataUint8) { |
Dart_CObject root; |
root.type = Dart_CObject_kTypedData; |
@@ -661,7 +633,6 @@ TEST_CASE(FailSerializeLargeTypedDataUint8) { |
ExpectEncodeFail(&root); |
} |
- |
TEST_CASE(FailSerializeLargeExternalTypedData) { |
Dart_CObject root; |
root.type = Dart_CObject_kExternalTypedData; |
@@ -670,7 +641,6 @@ TEST_CASE(FailSerializeLargeExternalTypedData) { |
ExpectEncodeFail(&root); |
} |
- |
TEST_CASE(SerializeEmptyArray) { |
// Write snapshot with object content. |
const int kArrayLength = 0; |
@@ -696,7 +666,6 @@ TEST_CASE(SerializeEmptyArray) { |
CheckEncodeDecodeMessage(root); |
} |
- |
TEST_CASE(SerializeByteArray) { |
// Write snapshot with object content. |
const int kTypedDataLength = 256; |
@@ -728,7 +697,6 @@ TEST_CASE(SerializeByteArray) { |
CheckEncodeDecodeMessage(root); |
} |
- |
#define TEST_TYPED_ARRAY(darttype, ctype) \ |
{ \ |
StackZone zone(thread); \ |
@@ -752,7 +720,6 @@ TEST_CASE(SerializeByteArray) { |
} \ |
} |
- |
#define TEST_EXTERNAL_TYPED_ARRAY(darttype, ctype) \ |
{ \ |
StackZone zone(thread); \ |
@@ -775,7 +742,6 @@ TEST_CASE(SerializeByteArray) { |
} \ |
} |
- |
TEST_CASE(SerializeTypedArray) { |
TEST_TYPED_ARRAY(Int8, int8_t); |
TEST_TYPED_ARRAY(Uint8, uint8_t); |
@@ -789,7 +755,6 @@ TEST_CASE(SerializeTypedArray) { |
TEST_TYPED_ARRAY(Float64, double); |
} |
- |
TEST_CASE(SerializeExternalTypedArray) { |
TEST_EXTERNAL_TYPED_ARRAY(Int8, int8_t); |
TEST_EXTERNAL_TYPED_ARRAY(Uint8, uint8_t); |
@@ -803,7 +768,6 @@ TEST_CASE(SerializeExternalTypedArray) { |
TEST_EXTERNAL_TYPED_ARRAY(Float64, double); |
} |
- |
TEST_CASE(SerializeEmptyByteArray) { |
// Write snapshot with object content. |
const int kTypedDataLength = 0; |
@@ -831,7 +795,6 @@ TEST_CASE(SerializeEmptyByteArray) { |
CheckEncodeDecodeMessage(root); |
} |
- |
class TestSnapshotWriter : public SnapshotWriter { |
public: |
static const intptr_t kInitialSize = 64 * KB; |
@@ -859,7 +822,6 @@ class TestSnapshotWriter : public SnapshotWriter { |
DISALLOW_COPY_AND_ASSIGN(TestSnapshotWriter); |
}; |
- |
static void GenerateSourceAndCheck(const Script& script) { |
// Check if we are able to generate the source from the token stream. |
// Rescan this source and compare the token stream to see if they are |
@@ -895,7 +857,6 @@ static void GenerateSourceAndCheck(const Script& script) { |
} |
} |
- |
TEST_CASE(SerializeScript) { |
const char* kScriptChars = |
"class A {\n" |
@@ -1001,7 +962,6 @@ TEST_CASE(SerializeScript) { |
free(buffer); |
} |
- |
#if !defined(PRODUCT) // Uses mirrors. |
VM_UNIT_TEST_CASE(CanonicalizationInScriptSnapshots) { |
const char* kScriptChars = |
@@ -1108,7 +1068,6 @@ VM_UNIT_TEST_CASE(CanonicalizationInScriptSnapshots) { |
} |
#endif |
- |
VM_UNIT_TEST_CASE(ScriptSnapshotsUpdateSubclasses) { |
const char* kScriptChars = |
"class _DebugDuration extends Duration {\n" |
@@ -1222,7 +1181,6 @@ VM_UNIT_TEST_CASE(ScriptSnapshotsUpdateSubclasses) { |
#endif |
} |
- |
static void IterateScripts(const Library& lib) { |
const Array& lib_scripts = Array::Handle(lib.LoadedScripts()); |
Script& script = Script::Handle(); |
@@ -1260,7 +1218,6 @@ ISOLATE_UNIT_TEST_CASE(GenerateSource) { |
stack_trace_collection_enabled); |
} |
- |
VM_UNIT_TEST_CASE(FullSnapshot) { |
const char* kScriptChars = |
"class Fields {\n" |
@@ -1334,7 +1291,6 @@ VM_UNIT_TEST_CASE(FullSnapshot) { |
free(isolate_snapshot_data_buffer); |
} |
- |
VM_UNIT_TEST_CASE(FullSnapshot1) { |
// This buffer has to be static for this to compile with Visual Studio. |
// If it is not static compilation of this file with Visual Studio takes |
@@ -1400,10 +1356,8 @@ VM_UNIT_TEST_CASE(FullSnapshot1) { |
free(isolate_snapshot_data_buffer); |
} |
- |
#ifndef PRODUCT |
- |
VM_UNIT_TEST_CASE(ScriptSnapshot) { |
const char* kLibScriptChars = |
"library dart_import_lib;" |
@@ -1538,7 +1492,6 @@ VM_UNIT_TEST_CASE(ScriptSnapshot) { |
free(script_snapshot); |
} |
- |
VM_UNIT_TEST_CASE(ScriptSnapshot1) { |
const char* kScriptChars = |
"class _SimpleNumEnumerable<T extends num> {" |
@@ -1611,7 +1564,6 @@ VM_UNIT_TEST_CASE(ScriptSnapshot1) { |
free(script_snapshot); |
} |
- |
VM_UNIT_TEST_CASE(ScriptSnapshot2) { |
// The snapshot of this library is always created in production mode, but |
// loaded and executed in both production and checked modes. |
@@ -1727,7 +1679,6 @@ VM_UNIT_TEST_CASE(ScriptSnapshot2) { |
free(script_snapshot); |
} |
- |
VM_UNIT_TEST_CASE(MismatchedSnapshotKinds) { |
const char* kScriptChars = "main() { print('Hello, world!'); }"; |
Dart_Handle result; |
@@ -1811,10 +1762,8 @@ VM_UNIT_TEST_CASE(MismatchedSnapshotKinds) { |
free(script_snapshot); |
} |
- |
#endif // !PRODUCT |
- |
TEST_CASE(IntArrayMessage) { |
StackZone zone(Thread::Current()); |
uint8_t* buffer = NULL; |
@@ -1839,7 +1788,6 @@ TEST_CASE(IntArrayMessage) { |
CheckEncodeDecodeMessage(root); |
} |
- |
// Helper function to call a top level Dart function and serialize the result. |
static uint8_t* GetSerialized(Dart_Handle lib, |
const char* dart_function, |
@@ -1857,7 +1805,6 @@ static uint8_t* GetSerialized(Dart_Handle lib, |
return buffer; |
} |
- |
// Helper function to deserialize the result into a Dart_CObject structure. |
static Dart_CObject* GetDeserialized(uint8_t* buffer, intptr_t buffer_len) { |
// Read object back from the snapshot into a C structure. |
@@ -1865,7 +1812,6 @@ static Dart_CObject* GetDeserialized(uint8_t* buffer, intptr_t buffer_len) { |
return api_reader.ReadMessage(); |
} |
- |
static void CheckString(Dart_Handle dart_string, const char* expected) { |
StackZone zone(Thread::Current()); |
String& str = String::Handle(); |
@@ -1885,7 +1831,6 @@ static void CheckString(Dart_Handle dart_string, const char* expected) { |
CheckEncodeDecodeMessage(root); |
} |
- |
static void CheckStringInvalid(Dart_Handle dart_string) { |
StackZone zone(Thread::Current()); |
String& str = String::Handle(); |
@@ -1903,7 +1848,6 @@ static void CheckStringInvalid(Dart_Handle dart_string) { |
EXPECT_EQ(Dart_CObject_kUnsupported, root->type); |
} |
- |
VM_UNIT_TEST_CASE(DartGeneratedMessages) { |
static const char* kCustomIsolateScriptChars = |
"getSmi() {\n" |
@@ -2051,7 +1995,6 @@ VM_UNIT_TEST_CASE(DartGeneratedMessages) { |
Dart_ShutdownIsolate(); |
} |
- |
VM_UNIT_TEST_CASE(DartGeneratedListMessages) { |
const int kArrayLength = 10; |
static const char* kScriptChars = |
@@ -2162,7 +2105,6 @@ VM_UNIT_TEST_CASE(DartGeneratedListMessages) { |
Dart_ShutdownIsolate(); |
} |
- |
VM_UNIT_TEST_CASE(DartGeneratedArrayLiteralMessages) { |
const int kArrayLength = 10; |
static const char* kScriptChars = |
@@ -2383,7 +2325,6 @@ VM_UNIT_TEST_CASE(DartGeneratedArrayLiteralMessages) { |
Dart_ShutdownIsolate(); |
} |
- |
VM_UNIT_TEST_CASE(DartGeneratedListMessagesWithBackref) { |
const int kArrayLength = 10; |
static const char* kScriptChars = |
@@ -2603,7 +2544,6 @@ VM_UNIT_TEST_CASE(DartGeneratedListMessagesWithBackref) { |
Dart_ShutdownIsolate(); |
} |
- |
VM_UNIT_TEST_CASE(DartGeneratedArrayLiteralMessagesWithBackref) { |
const int kArrayLength = 10; |
static const char* kScriptChars = |
@@ -2830,7 +2770,6 @@ VM_UNIT_TEST_CASE(DartGeneratedArrayLiteralMessagesWithBackref) { |
Dart_ShutdownIsolate(); |
} |
- |
static void CheckTypedData(Dart_CObject* object, |
Dart_TypedData_Type typed_data_type, |
int len) { |
@@ -3025,7 +2964,6 @@ VM_UNIT_TEST_CASE(DartGeneratedListMessagesWithTypedData) { |
Dart_ShutdownIsolate(); |
} |
- |
VM_UNIT_TEST_CASE(PostCObject) { |
// Create a native port for posting from C to Dart |
TestIsolateScope __test_isolate__; |
@@ -3121,7 +3059,6 @@ VM_UNIT_TEST_CASE(PostCObject) { |
Dart_ExitScope(); |
} |
- |
TEST_CASE(OmittedObjectEncodingLength) { |
StackZone zone(Thread::Current()); |
uint8_t* buffer; |