OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 185 |
186 | 186 |
187 // Test that the whole heap can be serialized. | 187 // Test that the whole heap can be serialized. |
188 TEST(Serialize) { | 188 TEST(Serialize) { |
189 Serializer::Enable(); | 189 Serializer::Enable(); |
190 v8::V8::Initialize(); | 190 v8::V8::Initialize(); |
191 Serialize(); | 191 Serialize(); |
192 } | 192 } |
193 | 193 |
194 | 194 |
| 195 // Test that heap serialization is non-destructive. |
| 196 TEST(SerializeTwice) { |
| 197 Serializer::Enable(); |
| 198 v8::V8::Initialize(); |
| 199 Serialize(); |
| 200 Serialize(); |
| 201 } |
| 202 |
| 203 |
195 //---------------------------------------------------------------------------- | 204 //---------------------------------------------------------------------------- |
196 // Tests that the heap can be deserialized. | 205 // Tests that the heap can be deserialized. |
197 | 206 |
198 static void Deserialize() { | 207 static void Deserialize() { |
199 CHECK(Snapshot::Initialize(FLAG_testing_serialization_file)); | 208 CHECK(Snapshot::Initialize(FLAG_testing_serialization_file)); |
200 } | 209 } |
201 | 210 |
202 | 211 |
203 static void SanityCheck() { | 212 static void SanityCheck() { |
204 v8::HandleScope scope; | 213 v8::HandleScope scope; |
205 #ifdef DEBUG | 214 #ifdef DEBUG |
206 Heap::Verify(); | 215 Heap::Verify(); |
207 #endif | 216 #endif |
208 CHECK(Top::global()->IsJSObject()); | 217 CHECK(Top::global()->IsJSObject()); |
209 CHECK(Top::global_context()->IsContext()); | 218 CHECK(Top::global_context()->IsContext()); |
210 CHECK(Top::special_function_table()->IsFixedArray()); | 219 CHECK(Top::special_function_table()->IsFixedArray()); |
211 CHECK(Heap::symbol_table()->IsSymbolTable()); | 220 CHECK(Heap::symbol_table()->IsSymbolTable()); |
212 CHECK(!Factory::LookupAsciiSymbol("Empty")->IsFailure()); | 221 CHECK(!Factory::LookupAsciiSymbol("Empty")->IsFailure()); |
213 } | 222 } |
214 | 223 |
215 | 224 |
216 DEPENDENT_TEST(Deserialize, Serialize) { | 225 DEPENDENT_TEST(Deserialize, Serialize) { |
217 v8::HandleScope scope; | 226 v8::HandleScope scope; |
218 | 227 |
219 Deserialize(); | 228 Deserialize(); |
220 | 229 |
221 fflush(stdout); | |
222 | |
223 v8::Persistent<v8::Context> env = v8::Context::New(); | 230 v8::Persistent<v8::Context> env = v8::Context::New(); |
224 env->Enter(); | 231 env->Enter(); |
225 | 232 |
| 233 SanityCheck(); |
| 234 } |
| 235 |
| 236 |
| 237 DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) { |
| 238 v8::HandleScope scope; |
| 239 |
| 240 Deserialize(); |
| 241 |
| 242 v8::Persistent<v8::Context> env = v8::Context::New(); |
| 243 env->Enter(); |
| 244 |
226 SanityCheck(); | 245 SanityCheck(); |
227 } | 246 } |
228 | 247 |
229 | 248 |
230 DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) { | 249 DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) { |
231 v8::HandleScope scope; | 250 v8::HandleScope scope; |
232 | 251 |
233 Deserialize(); | 252 Deserialize(); |
234 | 253 |
235 v8::Persistent<v8::Context> env = v8::Context::New(); | 254 v8::Persistent<v8::Context> env = v8::Context::New(); |
236 env->Enter(); | 255 env->Enter(); |
237 | 256 |
238 const char* c_source = "\"1234\".length"; | 257 const char* c_source = "\"1234\".length"; |
239 v8::Local<v8::String> source = v8::String::New(c_source); | 258 v8::Local<v8::String> source = v8::String::New(c_source); |
240 v8::Local<v8::Script> script = v8::Script::Compile(source); | 259 v8::Local<v8::Script> script = v8::Script::Compile(source); |
241 CHECK_EQ(4, script->Run()->Int32Value()); | 260 CHECK_EQ(4, script->Run()->Int32Value()); |
242 } | 261 } |
243 | 262 |
244 | 263 |
| 264 DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2, |
| 265 SerializeTwice) { |
| 266 v8::HandleScope scope; |
| 267 |
| 268 Deserialize(); |
| 269 |
| 270 v8::Persistent<v8::Context> env = v8::Context::New(); |
| 271 env->Enter(); |
| 272 |
| 273 const char* c_source = "\"1234\".length"; |
| 274 v8::Local<v8::String> source = v8::String::New(c_source); |
| 275 v8::Local<v8::Script> script = v8::Script::Compile(source); |
| 276 CHECK_EQ(4, script->Run()->Int32Value()); |
| 277 } |
| 278 |
| 279 |
245 TEST(TestThatAlwaysSucceeds) { | 280 TEST(TestThatAlwaysSucceeds) { |
246 } | 281 } |
247 | 282 |
248 | 283 |
249 TEST(TestThatAlwaysFails) { | 284 TEST(TestThatAlwaysFails) { |
250 bool ArtificialFailure = false; | 285 bool ArtificialFailure = false; |
251 CHECK(ArtificialFailure); | 286 CHECK(ArtificialFailure); |
252 } | 287 } |
253 | 288 |
254 | 289 |
255 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { | 290 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { |
256 bool ArtificialFailure2 = false; | 291 bool ArtificialFailure2 = false; |
257 CHECK(ArtificialFailure2); | 292 CHECK(ArtificialFailure2); |
258 } | 293 } |
OLD | NEW |