| 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 4485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4496 | 4496 |
| 4497 host_dispatch_v8_thread.Start(); | 4497 host_dispatch_v8_thread.Start(); |
| 4498 host_dispatch_debugger_thread.Start(); | 4498 host_dispatch_debugger_thread.Start(); |
| 4499 | 4499 |
| 4500 host_dispatch_v8_thread.Join(); | 4500 host_dispatch_v8_thread.Join(); |
| 4501 host_dispatch_debugger_thread.Join(); | 4501 host_dispatch_debugger_thread.Join(); |
| 4502 } | 4502 } |
| 4503 | 4503 |
| 4504 | 4504 |
| 4505 TEST(DebuggerAgent) { | 4505 TEST(DebuggerAgent) { |
| 4506 // Make sure this port is not used by other tests to allow tests to run in | 4506 // Make sure these ports is not used by other tests to allow tests to run in |
| 4507 // parallel. | 4507 // parallel. |
| 4508 const int kPort = 5858; | 4508 const int kPort1 = 5858; |
| 4509 const int kPort2 = 5857; |
| 4510 const int kPort3 = 5856; |
| 4509 | 4511 |
| 4510 // Make a string with the port number. | 4512 // Make a string with the port2 number. |
| 4511 const int kPortBufferLen = 6; | 4513 const int kPortBufferLen = 6; |
| 4512 char port_str[kPortBufferLen]; | 4514 char port2_str[kPortBufferLen]; |
| 4513 OS::SNPrintF(i::Vector<char>(port_str, kPortBufferLen), "%d", kPort); | 4515 OS::SNPrintF(i::Vector<char>(port2_str, kPortBufferLen), "%d", kPort2); |
| 4514 | 4516 |
| 4515 bool ok; | 4517 bool ok; |
| 4516 | 4518 |
| 4517 // Initialize the socket library. | 4519 // Initialize the socket library. |
| 4518 i::Socket::Setup(); | 4520 i::Socket::Setup(); |
| 4519 | 4521 |
| 4520 // Test starting and stopping the agent without any client connection. | 4522 // Test starting and stopping the agent without any client connection. |
| 4521 i::Debugger::StartAgent("test", kPort); | 4523 i::Debugger::StartAgent("test", kPort1); |
| 4522 i::Debugger::StopAgent(); | 4524 i::Debugger::StopAgent(); |
| 4523 | 4525 |
| 4524 // Test starting the agent, connecting a client and shutting down the agent | 4526 // Test starting the agent, connecting a client and shutting down the agent |
| 4525 // with the client connected. | 4527 // with the client connected. |
| 4526 ok = i::Debugger::StartAgent("test", kPort); | 4528 ok = i::Debugger::StartAgent("test", kPort2); |
| 4527 CHECK(ok); | 4529 CHECK(ok); |
| 4528 i::Socket* client = i::OS::CreateSocket(); | 4530 i::Socket* client = i::OS::CreateSocket(); |
| 4529 ok = client->Connect("localhost", port_str); | 4531 ok = client->Connect("localhost", port2_str); |
| 4530 CHECK(ok); | 4532 CHECK(ok); |
| 4531 i::Debugger::StopAgent(); | 4533 i::Debugger::StopAgent(); |
| 4532 delete client; | 4534 delete client; |
| 4533 | 4535 |
| 4534 // Test starting and stopping the agent with the required port already | 4536 // Test starting and stopping the agent with the required port already |
| 4535 // occoupied. | 4537 // occoupied. |
| 4536 i::Socket* server = i::OS::CreateSocket(); | 4538 i::Socket* server = i::OS::CreateSocket(); |
| 4537 server->Bind(kPort); | 4539 server->Bind(kPort3); |
| 4538 | 4540 |
| 4539 i::Debugger::StartAgent("test", kPort); | 4541 i::Debugger::StartAgent("test", kPort3); |
| 4540 i::Debugger::StopAgent(); | 4542 i::Debugger::StopAgent(); |
| 4541 | 4543 |
| 4542 delete server; | 4544 delete server; |
| 4543 } | 4545 } |
| 4544 | 4546 |
| 4545 | 4547 |
| 4546 class DebuggerAgentProtocolServerThread : public i::Thread { | 4548 class DebuggerAgentProtocolServerThread : public i::Thread { |
| 4547 public: | 4549 public: |
| 4548 explicit DebuggerAgentProtocolServerThread(int port) | 4550 explicit DebuggerAgentProtocolServerThread(int port) |
| 4549 : port_(port), server_(NULL), client_(NULL), | 4551 : port_(port), server_(NULL), client_(NULL), |
| (...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5363 v8::Script::New( | 5365 v8::Script::New( |
| 5364 v8::String::New( | 5366 v8::String::New( |
| 5365 "function runTest(mirror) {" | 5367 "function runTest(mirror) {" |
| 5366 " return mirror.isString() && (mirror.length() == 5);" | 5368 " return mirror.isString() && (mirror.length() == 5);" |
| 5367 "}" | 5369 "}" |
| 5368 "" | 5370 "" |
| 5369 "runTest;"))->Run()); | 5371 "runTest;"))->Run()); |
| 5370 v8::Handle<v8::Value> result = run_test->Call(env->Global(), 1, &obj); | 5372 v8::Handle<v8::Value> result = run_test->Call(env->Global(), 1, &obj); |
| 5371 CHECK(result->IsTrue()); | 5373 CHECK(result->IsTrue()); |
| 5372 } | 5374 } |
| OLD | NEW |