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

Side by Side Diff: test/cctest/test-log.cc

Issue 15964004: remove most V8_ALLOW_ACCESS_TO_* defines from test classes (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: comment addressed Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-lockers.cc ('k') | test/cctest/test-log-stack-tracer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
27 // 27 //
28 // Tests of logging functions from log.h 28 // Tests of logging functions from log.h
29 29
30 #ifdef __linux__ 30 #ifdef __linux__
31 #include <pthread.h> 31 #include <pthread.h>
32 #include <signal.h> 32 #include <signal.h>
33 #include <unistd.h> 33 #include <unistd.h>
34 #include <cmath> 34 #include <cmath>
35 #endif // __linux__ 35 #endif // __linux__
36 36
37 // TODO(dcarney): remove
38 #define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
39 #define V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
40 #define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
41
42 #include "v8.h" 37 #include "v8.h"
43 #include "log.h" 38 #include "log.h"
44 #include "cpu-profiler.h" 39 #include "cpu-profiler.h"
45 #include "natives.h" 40 #include "natives.h"
46 #include "v8threads.h" 41 #include "v8threads.h"
47 #include "v8utils.h" 42 #include "v8utils.h"
48 #include "cctest.h" 43 #include "cctest.h"
49 #include "vm-state-inl.h" 44 #include "vm-state-inl.h"
50 45
51 using v8::internal::Address; 46 using v8::internal::Address;
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 393
399 394
400 static v8::Handle<v8::Value> ObjMethod1(const v8::Arguments& args) { 395 static v8::Handle<v8::Value> ObjMethod1(const v8::Arguments& args) {
401 return v8::Handle<v8::Value>(); 396 return v8::Handle<v8::Value>();
402 } 397 }
403 398
404 TEST(LogCallbacks) { 399 TEST(LogCallbacks) {
405 ScopedLoggerInitializer initialize_logger(false); 400 ScopedLoggerInitializer initialize_logger(false);
406 Logger* logger = initialize_logger.logger(); 401 Logger* logger = initialize_logger.logger();
407 402
408 v8::Persistent<v8::FunctionTemplate> obj = 403 v8::Local<v8::FunctionTemplate> obj =
409 v8::Persistent<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(), 404 v8::Local<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(),
410 v8::FunctionTemplate::New()); 405 v8::FunctionTemplate::New());
411 obj->SetClassName(v8_str("Obj")); 406 obj->SetClassName(v8_str("Obj"));
412 v8::Handle<v8::ObjectTemplate> proto = obj->PrototypeTemplate(); 407 v8::Handle<v8::ObjectTemplate> proto = obj->PrototypeTemplate();
413 v8::Local<v8::Signature> signature = 408 v8::Local<v8::Signature> signature =
414 v8::Signature::New(v8::Handle<v8::FunctionTemplate>(*obj)); 409 v8::Signature::New(v8::Handle<v8::FunctionTemplate>(*obj));
415 proto->Set(v8_str("method1"), 410 proto->Set(v8_str("method1"),
416 v8::FunctionTemplate::New(ObjMethod1, 411 v8::FunctionTemplate::New(ObjMethod1,
417 v8::Handle<v8::Value>(), 412 v8::Handle<v8::Value>(),
418 signature), 413 signature),
419 static_cast<v8::PropertyAttribute>(v8::DontDelete)); 414 static_cast<v8::PropertyAttribute>(v8::DontDelete));
420 415
421 initialize_logger.env()->Global()->Set(v8_str("Obj"), obj->GetFunction()); 416 initialize_logger.env()->Global()->Set(v8_str("Obj"), obj->GetFunction());
422 CompileRun("Obj.prototype.method1.toString();"); 417 CompileRun("Obj.prototype.method1.toString();");
423 418
424 logger->LogCompiledFunctions(); 419 logger->LogCompiledFunctions();
425 420
426 bool exists = false; 421 bool exists = false;
427 i::Vector<const char> log( 422 i::Vector<const char> log(
428 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); 423 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true));
429 CHECK(exists); 424 CHECK(exists);
430 425
431 i::EmbeddedVector<char, 100> ref_data; 426 i::EmbeddedVector<char, 100> ref_data;
432 i::OS::SNPrintF(ref_data, 427 i::OS::SNPrintF(ref_data,
433 "code-creation,Callback,-3,0x%" V8PRIxPTR ",1,\"method1\"\0", 428 "code-creation,Callback,-3,0x%" V8PRIxPTR ",1,\"method1\"\0",
434 ObjMethod1); 429 ObjMethod1);
435 430
436 CHECK_NE(NULL, StrNStr(log.start(), ref_data.start(), log.length())); 431 CHECK_NE(NULL, StrNStr(log.start(), ref_data.start(), log.length()));
437
438 obj.Dispose(v8::Isolate::GetCurrent());
439 } 432 }
440 433
441 434
442 static v8::Handle<v8::Value> Prop1Getter(v8::Local<v8::String> property, 435 static v8::Handle<v8::Value> Prop1Getter(v8::Local<v8::String> property,
443 const v8::AccessorInfo& info) { 436 const v8::AccessorInfo& info) {
444 return v8::Handle<v8::Value>(); 437 return v8::Handle<v8::Value>();
445 } 438 }
446 439
447 static void Prop1Setter(v8::Local<v8::String> property, 440 static void Prop1Setter(v8::Local<v8::String> property,
448 v8::Local<v8::Value> value, 441 v8::Local<v8::Value> value,
449 const v8::AccessorInfo& info) { 442 const v8::AccessorInfo& info) {
450 } 443 }
451 444
452 static v8::Handle<v8::Value> Prop2Getter(v8::Local<v8::String> property, 445 static v8::Handle<v8::Value> Prop2Getter(v8::Local<v8::String> property,
453 const v8::AccessorInfo& info) { 446 const v8::AccessorInfo& info) {
454 return v8::Handle<v8::Value>(); 447 return v8::Handle<v8::Value>();
455 } 448 }
456 449
457 TEST(LogAccessorCallbacks) { 450 TEST(LogAccessorCallbacks) {
458 ScopedLoggerInitializer initialize_logger(false); 451 ScopedLoggerInitializer initialize_logger(false);
459 Logger* logger = initialize_logger.logger(); 452 Logger* logger = initialize_logger.logger();
460 453
461 v8::Persistent<v8::FunctionTemplate> obj = 454 v8::Local<v8::FunctionTemplate> obj =
462 v8::Persistent<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(), 455 v8::Local<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(),
463 v8::FunctionTemplate::New()); 456 v8::FunctionTemplate::New());
464 obj->SetClassName(v8_str("Obj")); 457 obj->SetClassName(v8_str("Obj"));
465 v8::Handle<v8::ObjectTemplate> inst = obj->InstanceTemplate(); 458 v8::Handle<v8::ObjectTemplate> inst = obj->InstanceTemplate();
466 inst->SetAccessor(v8_str("prop1"), Prop1Getter, Prop1Setter); 459 inst->SetAccessor(v8_str("prop1"), Prop1Getter, Prop1Setter);
467 inst->SetAccessor(v8_str("prop2"), Prop2Getter); 460 inst->SetAccessor(v8_str("prop2"), Prop2Getter);
468 461
469 logger->LogAccessorCallbacks(); 462 logger->LogAccessorCallbacks();
470 463
471 bool exists = false; 464 bool exists = false;
472 i::Vector<const char> log( 465 i::Vector<const char> log(
473 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); 466 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true));
(...skipping 12 matching lines...) Expand all
486 Prop1Setter); 479 Prop1Setter);
487 CHECK_NE(NULL, 480 CHECK_NE(NULL,
488 StrNStr(log.start(), prop1_setter_record.start(), log.length())); 481 StrNStr(log.start(), prop1_setter_record.start(), log.length()));
489 482
490 EmbeddedVector<char, 100> prop2_getter_record; 483 EmbeddedVector<char, 100> prop2_getter_record;
491 i::OS::SNPrintF(prop2_getter_record, 484 i::OS::SNPrintF(prop2_getter_record,
492 "code-creation,Callback,-3,0x%" V8PRIxPTR ",1,\"get prop2\"", 485 "code-creation,Callback,-3,0x%" V8PRIxPTR ",1,\"get prop2\"",
493 Prop2Getter); 486 Prop2Getter);
494 CHECK_NE(NULL, 487 CHECK_NE(NULL,
495 StrNStr(log.start(), prop2_getter_record.start(), log.length())); 488 StrNStr(log.start(), prop2_getter_record.start(), log.length()));
496
497 obj.Dispose(v8::Isolate::GetCurrent());
498 } 489 }
499 490
500 491
501 TEST(IsLoggingPreserved) { 492 TEST(IsLoggingPreserved) {
502 ScopedLoggerInitializer initialize_logger(false); 493 ScopedLoggerInitializer initialize_logger(false);
503 Logger* logger = initialize_logger.logger(); 494 Logger* logger = initialize_logger.logger();
504 495
505 CHECK(logger->is_logging()); 496 CHECK(logger->is_logging());
506 logger->ResumeProfiler(); 497 logger->ResumeProfiler();
507 CHECK(logger->is_logging()); 498 CHECK(logger->is_logging());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 v8::Local<v8::String> s = result->ToString(); 562 v8::Local<v8::String> s = result->ToString();
572 i::ScopedVector<char> data(s->Utf8Length() + 1); 563 i::ScopedVector<char> data(s->Utf8Length() + 1);
573 CHECK_NE(NULL, data.start()); 564 CHECK_NE(NULL, data.start());
574 s->WriteUtf8(data.start()); 565 s->WriteUtf8(data.start());
575 printf("%s\n", data.start()); 566 printf("%s\n", data.start());
576 // Make sure that our output is written prior crash due to CHECK failure. 567 // Make sure that our output is written prior crash due to CHECK failure.
577 fflush(stdout); 568 fflush(stdout);
578 CHECK(false); 569 CHECK(false);
579 } 570 }
580 } 571 }
OLDNEW
« no previous file with comments | « test/cctest/test-lockers.cc ('k') | test/cctest/test-log-stack-tracer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698