OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 79 } |
80 | 80 |
81 v8::Handle<v8::Context>& env() { return env_; } | 81 v8::Handle<v8::Context>& env() { return env_; } |
82 | 82 |
83 v8::Isolate* isolate() { return isolate_; } | 83 v8::Isolate* isolate() { return isolate_; } |
84 | 84 |
85 Logger* logger() { return logger_; } | 85 Logger* logger() { return logger_; } |
86 | 86 |
87 FILE* StopLoggingGetTempFile() { | 87 FILE* StopLoggingGetTempFile() { |
88 temp_file_ = logger_->TearDown(); | 88 temp_file_ = logger_->TearDown(); |
89 CHECK(temp_file_); | 89 CHECK_NE(NULL, temp_file_); |
90 fflush(temp_file_); | 90 fflush(temp_file_); |
91 rewind(temp_file_); | 91 rewind(temp_file_); |
92 return temp_file_; | 92 return temp_file_; |
93 } | 93 } |
94 | 94 |
95 private: | 95 private: |
96 static bool init_flags_() { | 96 static bool init_flags_() { |
97 i::FLAG_log = true; | 97 i::FLAG_log = true; |
98 i::FLAG_prof = true; | 98 i::FLAG_prof = true; |
99 i::FLAG_logfile = i::Log::kLogToTemporaryFile; | 99 i::FLAG_logfile = i::Log::kLogToTemporaryFile; |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 bool exists = false; | 361 bool exists = false; |
362 i::Vector<const char> log( | 362 i::Vector<const char> log( |
363 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); | 363 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); |
364 CHECK(exists); | 364 CHECK(exists); |
365 | 365 |
366 i::EmbeddedVector<char, 100> ref_data; | 366 i::EmbeddedVector<char, 100> ref_data; |
367 i::SNPrintF(ref_data, | 367 i::SNPrintF(ref_data, |
368 "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"method1\"", | 368 "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"method1\"", |
369 reinterpret_cast<intptr_t>(ObjMethod1)); | 369 reinterpret_cast<intptr_t>(ObjMethod1)); |
370 | 370 |
371 CHECK(StrNStr(log.start(), ref_data.start(), log.length())); | 371 CHECK_NE(NULL, StrNStr(log.start(), ref_data.start(), log.length())); |
372 log.Dispose(); | 372 log.Dispose(); |
373 } | 373 } |
374 isolate->Dispose(); | 374 isolate->Dispose(); |
375 } | 375 } |
376 | 376 |
377 | 377 |
378 static void Prop1Getter(v8::Local<v8::String> property, | 378 static void Prop1Getter(v8::Local<v8::String> property, |
379 const v8::PropertyCallbackInfo<v8::Value>& info) { | 379 const v8::PropertyCallbackInfo<v8::Value>& info) { |
380 } | 380 } |
381 | 381 |
(...skipping 25 matching lines...) Expand all Loading... |
407 | 407 |
408 bool exists = false; | 408 bool exists = false; |
409 i::Vector<const char> log( | 409 i::Vector<const char> log( |
410 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); | 410 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); |
411 CHECK(exists); | 411 CHECK(exists); |
412 | 412 |
413 EmbeddedVector<char, 100> prop1_getter_record; | 413 EmbeddedVector<char, 100> prop1_getter_record; |
414 i::SNPrintF(prop1_getter_record, | 414 i::SNPrintF(prop1_getter_record, |
415 "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"get prop1\"", | 415 "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"get prop1\"", |
416 reinterpret_cast<intptr_t>(Prop1Getter)); | 416 reinterpret_cast<intptr_t>(Prop1Getter)); |
417 CHECK(StrNStr(log.start(), prop1_getter_record.start(), log.length())); | 417 CHECK_NE(NULL, |
| 418 StrNStr(log.start(), prop1_getter_record.start(), log.length())); |
418 | 419 |
419 EmbeddedVector<char, 100> prop1_setter_record; | 420 EmbeddedVector<char, 100> prop1_setter_record; |
420 i::SNPrintF(prop1_setter_record, | 421 i::SNPrintF(prop1_setter_record, |
421 "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"set prop1\"", | 422 "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"set prop1\"", |
422 reinterpret_cast<intptr_t>(Prop1Setter)); | 423 reinterpret_cast<intptr_t>(Prop1Setter)); |
423 CHECK(StrNStr(log.start(), prop1_setter_record.start(), log.length())); | 424 CHECK_NE(NULL, |
| 425 StrNStr(log.start(), prop1_setter_record.start(), log.length())); |
424 | 426 |
425 EmbeddedVector<char, 100> prop2_getter_record; | 427 EmbeddedVector<char, 100> prop2_getter_record; |
426 i::SNPrintF(prop2_getter_record, | 428 i::SNPrintF(prop2_getter_record, |
427 "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"get prop2\"", | 429 "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"get prop2\"", |
428 reinterpret_cast<intptr_t>(Prop2Getter)); | 430 reinterpret_cast<intptr_t>(Prop2Getter)); |
429 CHECK(StrNStr(log.start(), prop2_getter_record.start(), log.length())); | 431 CHECK_NE(NULL, |
| 432 StrNStr(log.start(), prop2_getter_record.start(), log.length())); |
430 log.Dispose(); | 433 log.Dispose(); |
431 } | 434 } |
432 isolate->Dispose(); | 435 isolate->Dispose(); |
433 } | 436 } |
434 | 437 |
435 | 438 |
436 typedef i::NativesCollection<i::TEST> TestSources; | 439 typedef i::NativesCollection<i::TEST> TestSources; |
437 | 440 |
438 | 441 |
439 // Test that logging of code create / move events is equivalent to traversal of | 442 // Test that logging of code create / move events is equivalent to traversal of |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 v8::Handle<v8::Value> result = script->Run(); | 491 v8::Handle<v8::Value> result = script->Run(); |
489 if (result.IsEmpty()) { | 492 if (result.IsEmpty()) { |
490 v8::String::Utf8Value exception(try_catch.Exception()); | 493 v8::String::Utf8Value exception(try_catch.Exception()); |
491 printf("run: %s\n", *exception); | 494 printf("run: %s\n", *exception); |
492 CHECK(false); | 495 CHECK(false); |
493 } | 496 } |
494 // The result either be a "true" literal or problem description. | 497 // The result either be a "true" literal or problem description. |
495 if (!result->IsTrue()) { | 498 if (!result->IsTrue()) { |
496 v8::Local<v8::String> s = result->ToString(isolate); | 499 v8::Local<v8::String> s = result->ToString(isolate); |
497 i::ScopedVector<char> data(s->Utf8Length() + 1); | 500 i::ScopedVector<char> data(s->Utf8Length() + 1); |
498 CHECK(data.start()); | 501 CHECK_NE(NULL, data.start()); |
499 s->WriteUtf8(data.start()); | 502 s->WriteUtf8(data.start()); |
500 printf("%s\n", data.start()); | 503 printf("%s\n", data.start()); |
501 // Make sure that our output is written prior crash due to CHECK failure. | 504 // Make sure that our output is written prior crash due to CHECK failure. |
502 fflush(stdout); | 505 fflush(stdout); |
503 CHECK(false); | 506 CHECK(false); |
504 } | 507 } |
505 } | 508 } |
506 isolate->Dispose(); | 509 isolate->Dispose(); |
507 } | 510 } |
508 | 511 |
509 | 512 |
510 TEST(LogVersion) { | 513 TEST(LogVersion) { |
511 v8::Isolate* isolate; | 514 v8::Isolate* isolate; |
512 { | 515 { |
513 ScopedLoggerInitializer initialize_logger; | 516 ScopedLoggerInitializer initialize_logger; |
514 isolate = initialize_logger.isolate(); | 517 isolate = initialize_logger.isolate(); |
515 bool exists = false; | 518 bool exists = false; |
516 i::Vector<const char> log( | 519 i::Vector<const char> log( |
517 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); | 520 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); |
518 CHECK(exists); | 521 CHECK(exists); |
519 i::EmbeddedVector<char, 100> ref_data; | 522 i::EmbeddedVector<char, 100> ref_data; |
520 i::SNPrintF(ref_data, "v8-version,%d,%d,%d,%d,%d", i::Version::GetMajor(), | 523 i::SNPrintF(ref_data, "v8-version,%d,%d,%d,%d,%d", i::Version::GetMajor(), |
521 i::Version::GetMinor(), i::Version::GetBuild(), | 524 i::Version::GetMinor(), i::Version::GetBuild(), |
522 i::Version::GetPatch(), i::Version::IsCandidate()); | 525 i::Version::GetPatch(), i::Version::IsCandidate()); |
523 CHECK(StrNStr(log.start(), ref_data.start(), log.length())); | 526 CHECK_NE(NULL, StrNStr(log.start(), ref_data.start(), log.length())); |
524 log.Dispose(); | 527 log.Dispose(); |
525 } | 528 } |
526 isolate->Dispose(); | 529 isolate->Dispose(); |
527 } | 530 } |
OLD | NEW |