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_NE(NULL, temp_file_); | 89 CHECK(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_NE(NULL, StrNStr(log.start(), ref_data.start(), log.length())); | 371 CHECK(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_NE(NULL, | 417 CHECK(StrNStr(log.start(), prop1_getter_record.start(), log.length())); |
418 StrNStr(log.start(), prop1_getter_record.start(), log.length())); | |
419 | 418 |
420 EmbeddedVector<char, 100> prop1_setter_record; | 419 EmbeddedVector<char, 100> prop1_setter_record; |
421 i::SNPrintF(prop1_setter_record, | 420 i::SNPrintF(prop1_setter_record, |
422 "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"set prop1\"", | 421 "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"set prop1\"", |
423 reinterpret_cast<intptr_t>(Prop1Setter)); | 422 reinterpret_cast<intptr_t>(Prop1Setter)); |
424 CHECK_NE(NULL, | 423 CHECK(StrNStr(log.start(), prop1_setter_record.start(), log.length())); |
425 StrNStr(log.start(), prop1_setter_record.start(), log.length())); | |
426 | 424 |
427 EmbeddedVector<char, 100> prop2_getter_record; | 425 EmbeddedVector<char, 100> prop2_getter_record; |
428 i::SNPrintF(prop2_getter_record, | 426 i::SNPrintF(prop2_getter_record, |
429 "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"get prop2\"", | 427 "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"get prop2\"", |
430 reinterpret_cast<intptr_t>(Prop2Getter)); | 428 reinterpret_cast<intptr_t>(Prop2Getter)); |
431 CHECK_NE(NULL, | 429 CHECK(StrNStr(log.start(), prop2_getter_record.start(), log.length())); |
432 StrNStr(log.start(), prop2_getter_record.start(), log.length())); | |
433 log.Dispose(); | 430 log.Dispose(); |
434 } | 431 } |
435 isolate->Dispose(); | 432 isolate->Dispose(); |
436 } | 433 } |
437 | 434 |
438 | 435 |
439 typedef i::NativesCollection<i::TEST> TestSources; | 436 typedef i::NativesCollection<i::TEST> TestSources; |
440 | 437 |
441 | 438 |
442 // Test that logging of code create / move events is equivalent to traversal of | 439 // 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... |
491 v8::Handle<v8::Value> result = script->Run(); | 488 v8::Handle<v8::Value> result = script->Run(); |
492 if (result.IsEmpty()) { | 489 if (result.IsEmpty()) { |
493 v8::String::Utf8Value exception(try_catch.Exception()); | 490 v8::String::Utf8Value exception(try_catch.Exception()); |
494 printf("run: %s\n", *exception); | 491 printf("run: %s\n", *exception); |
495 CHECK(false); | 492 CHECK(false); |
496 } | 493 } |
497 // The result either be a "true" literal or problem description. | 494 // The result either be a "true" literal or problem description. |
498 if (!result->IsTrue()) { | 495 if (!result->IsTrue()) { |
499 v8::Local<v8::String> s = result->ToString(isolate); | 496 v8::Local<v8::String> s = result->ToString(isolate); |
500 i::ScopedVector<char> data(s->Utf8Length() + 1); | 497 i::ScopedVector<char> data(s->Utf8Length() + 1); |
501 CHECK_NE(NULL, data.start()); | 498 CHECK(data.start()); |
502 s->WriteUtf8(data.start()); | 499 s->WriteUtf8(data.start()); |
503 printf("%s\n", data.start()); | 500 printf("%s\n", data.start()); |
504 // Make sure that our output is written prior crash due to CHECK failure. | 501 // Make sure that our output is written prior crash due to CHECK failure. |
505 fflush(stdout); | 502 fflush(stdout); |
506 CHECK(false); | 503 CHECK(false); |
507 } | 504 } |
508 } | 505 } |
509 isolate->Dispose(); | 506 isolate->Dispose(); |
510 } | 507 } |
511 | 508 |
512 | 509 |
513 TEST(LogVersion) { | 510 TEST(LogVersion) { |
514 v8::Isolate* isolate; | 511 v8::Isolate* isolate; |
515 { | 512 { |
516 ScopedLoggerInitializer initialize_logger; | 513 ScopedLoggerInitializer initialize_logger; |
517 isolate = initialize_logger.isolate(); | 514 isolate = initialize_logger.isolate(); |
518 bool exists = false; | 515 bool exists = false; |
519 i::Vector<const char> log( | 516 i::Vector<const char> log( |
520 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); | 517 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); |
521 CHECK(exists); | 518 CHECK(exists); |
522 i::EmbeddedVector<char, 100> ref_data; | 519 i::EmbeddedVector<char, 100> ref_data; |
523 i::SNPrintF(ref_data, "v8-version,%d,%d,%d,%d,%d", i::Version::GetMajor(), | 520 i::SNPrintF(ref_data, "v8-version,%d,%d,%d,%d,%d", i::Version::GetMajor(), |
524 i::Version::GetMinor(), i::Version::GetBuild(), | 521 i::Version::GetMinor(), i::Version::GetBuild(), |
525 i::Version::GetPatch(), i::Version::IsCandidate()); | 522 i::Version::GetPatch(), i::Version::IsCandidate()); |
526 CHECK_NE(NULL, StrNStr(log.start(), ref_data.start(), log.length())); | 523 CHECK(StrNStr(log.start(), ref_data.start(), log.length())); |
527 log.Dispose(); | 524 log.Dispose(); |
528 } | 525 } |
529 isolate->Dispose(); | 526 isolate->Dispose(); |
530 } | 527 } |
OLD | NEW |