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

Side by Side Diff: runtime/vm/service_test.cc

Issue 1371193005: VM restart + shutdown fixes (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: more code review Created 5 years, 2 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
« no previous file with comments | « runtime/vm/service_isolate.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 6
7 #include "include/dart_tools_api.h" 7 #include "include/dart_tools_api.h"
8 #include "vm/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/debugger.h" 10 #include "vm/debugger.h"
(...skipping 11 matching lines...) Expand all
22 DEFINE_FLAG(bool, service_testing_flag, false, "Comment"); 22 DEFINE_FLAG(bool, service_testing_flag, false, "Comment");
23 23
24 class ServiceTestMessageHandler : public MessageHandler { 24 class ServiceTestMessageHandler : public MessageHandler {
25 public: 25 public:
26 ServiceTestMessageHandler() : _msg(NULL) {} 26 ServiceTestMessageHandler() : _msg(NULL) {}
27 27
28 ~ServiceTestMessageHandler() { 28 ~ServiceTestMessageHandler() {
29 free(_msg); 29 free(_msg);
30 } 30 }
31 31
32 bool HandleMessage(Message* message) { 32 MessageStatus HandleMessage(Message* message) {
33 if (_msg != NULL) { 33 if (_msg != NULL) {
34 free(_msg); 34 free(_msg);
35 } 35 }
36 36
37 // Parse the message. 37 // Parse the message.
38 Thread* thread = Thread::Current(); 38 Thread* thread = Thread::Current();
39 MessageSnapshotReader reader(message->data(), message->len(), thread); 39 MessageSnapshotReader reader(message->data(), message->len(), thread);
40 const Object& response_obj = Object::Handle(reader.ReadObject()); 40 const Object& response_obj = Object::Handle(reader.ReadObject());
41 String& response = String::Handle(); 41 String& response = String::Handle();
42 response ^= response_obj.raw(); 42 response ^= response_obj.raw();
43 _msg = strdup(response.ToCString()); 43 _msg = strdup(response.ToCString());
44 return true; 44 return kOK;
45 } 45 }
46 46
47 const char* msg() const { return _msg; } 47 const char* msg() const { return _msg; }
48 48
49 private: 49 private:
50 char* _msg; 50 char* _msg;
51 }; 51 };
52 52
53 53
54 static RawArray* Eval(Dart_Handle lib, const char* expr) { 54 static RawArray* Eval(Dart_Handle lib, const char* expr) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); 184 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
185 EXPECT_VALID(port); 185 EXPECT_VALID(port);
186 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 186 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
187 187
188 Array& service_msg = Array::Handle(); 188 Array& service_msg = Array::Handle();
189 189
190 // Request an invalid code object. 190 // Request an invalid code object.
191 service_msg = 191 service_msg =
192 Eval(lib, "[0, port, '0', 'getObject', ['objectId'], ['code/0']]"); 192 Eval(lib, "[0, port, '0', 'getObject', ['objectId'], ['code/0']]");
193 Service::HandleIsolateMessage(isolate, service_msg); 193 Service::HandleIsolateMessage(isolate, service_msg);
194 handler.HandleNextMessage(); 194 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
195 EXPECT_SUBSTRING("\"error\"", handler.msg()); 195 EXPECT_SUBSTRING("\"error\"", handler.msg());
196 196
197 // The following test checks that a code object can be found only 197 // The following test checks that a code object can be found only
198 // at compile_timestamp()-code.EntryPoint(). 198 // at compile_timestamp()-code.EntryPoint().
199 service_msg = EvalF(lib, "[0, port, '0', 'getObject', " 199 service_msg = EvalF(lib, "[0, port, '0', 'getObject', "
200 "['objectId'], ['code/%" Px64"-%" Px "']]", 200 "['objectId'], ['code/%" Px64"-%" Px "']]",
201 compile_timestamp, 201 compile_timestamp,
202 entry); 202 entry);
203 Service::HandleIsolateMessage(isolate, service_msg); 203 Service::HandleIsolateMessage(isolate, service_msg);
204 handler.HandleNextMessage(); 204 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
205 EXPECT_SUBSTRING("\"type\":\"Code\"", handler.msg()); 205 EXPECT_SUBSTRING("\"type\":\"Code\"", handler.msg());
206 { 206 {
207 // Only perform a partial match. 207 // Only perform a partial match.
208 const intptr_t kBufferSize = 512; 208 const intptr_t kBufferSize = 512;
209 char buffer[kBufferSize]; 209 char buffer[kBufferSize];
210 OS::SNPrint(buffer, kBufferSize-1, 210 OS::SNPrint(buffer, kBufferSize-1,
211 "\"fixedId\":true,\"id\":\"code\\/%" Px64 "-%" Px "\",", 211 "\"fixedId\":true,\"id\":\"code\\/%" Px64 "-%" Px "\",",
212 compile_timestamp, 212 compile_timestamp,
213 entry); 213 entry);
214 EXPECT_SUBSTRING(buffer, handler.msg()); 214 EXPECT_SUBSTRING(buffer, handler.msg());
215 } 215 }
216 216
217 // Request code object at compile_timestamp-code.EntryPoint() + 16 217 // Request code object at compile_timestamp-code.EntryPoint() + 16
218 // Expect this to fail because the address is not the entry point. 218 // Expect this to fail because the address is not the entry point.
219 uintptr_t address = entry + 16; 219 uintptr_t address = entry + 16;
220 service_msg = EvalF(lib, "[0, port, '0', 'getObject', " 220 service_msg = EvalF(lib, "[0, port, '0', 'getObject', "
221 "['objectId'], ['code/%" Px64"-%" Px "']]", 221 "['objectId'], ['code/%" Px64"-%" Px "']]",
222 compile_timestamp, 222 compile_timestamp,
223 address); 223 address);
224 Service::HandleIsolateMessage(isolate, service_msg); 224 Service::HandleIsolateMessage(isolate, service_msg);
225 handler.HandleNextMessage(); 225 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
226 EXPECT_SUBSTRING("\"error\"", handler.msg()); 226 EXPECT_SUBSTRING("\"error\"", handler.msg());
227 227
228 // Request code object at (compile_timestamp - 1)-code.EntryPoint() 228 // Request code object at (compile_timestamp - 1)-code.EntryPoint()
229 // Expect this to fail because the timestamp is wrong. 229 // Expect this to fail because the timestamp is wrong.
230 address = entry; 230 address = entry;
231 service_msg = EvalF(lib, "[0, port, '0', 'getObject', " 231 service_msg = EvalF(lib, "[0, port, '0', 'getObject', "
232 "['objectId'], ['code/%" Px64"-%" Px "']]", 232 "['objectId'], ['code/%" Px64"-%" Px "']]",
233 compile_timestamp - 1, 233 compile_timestamp - 1,
234 address); 234 address);
235 Service::HandleIsolateMessage(isolate, service_msg); 235 Service::HandleIsolateMessage(isolate, service_msg);
236 handler.HandleNextMessage(); 236 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
237 EXPECT_SUBSTRING("\"error\"", handler.msg()); 237 EXPECT_SUBSTRING("\"error\"", handler.msg());
238 238
239 // Request native code at address. Expect the null code object back. 239 // Request native code at address. Expect the null code object back.
240 address = last; 240 address = last;
241 service_msg = EvalF(lib, "[0, port, '0', 'getObject', " 241 service_msg = EvalF(lib, "[0, port, '0', 'getObject', "
242 "['objectId'], ['code/native-%" Px "']]", 242 "['objectId'], ['code/native-%" Px "']]",
243 address); 243 address);
244 Service::HandleIsolateMessage(isolate, service_msg); 244 Service::HandleIsolateMessage(isolate, service_msg);
245 handler.HandleNextMessage(); 245 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
246 // TODO(turnidge): It is pretty broken to return an Instance here. Fix. 246 // TODO(turnidge): It is pretty broken to return an Instance here. Fix.
247 EXPECT_SUBSTRING("\"kind\":\"Null\"", 247 EXPECT_SUBSTRING("\"kind\":\"Null\"",
248 handler.msg()); 248 handler.msg());
249 249
250 // Request malformed native code. 250 // Request malformed native code.
251 service_msg = EvalF(lib, "[0, port, '0', 'getObject', ['objectId'], " 251 service_msg = EvalF(lib, "[0, port, '0', 'getObject', ['objectId'], "
252 "['code/native%" Px "']]", 252 "['code/native%" Px "']]",
253 address); 253 address);
254 Service::HandleIsolateMessage(isolate, service_msg); 254 Service::HandleIsolateMessage(isolate, service_msg);
255 handler.HandleNextMessage(); 255 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
256 EXPECT_SUBSTRING("\"error\"", handler.msg()); 256 EXPECT_SUBSTRING("\"error\"", handler.msg());
257 } 257 }
258 258
259 259
260 TEST_CASE(Service_TokenStream) { 260 TEST_CASE(Service_TokenStream) {
261 const char* kScript = 261 const char* kScript =
262 "var port;\n" // Set to our mock port by C++. 262 "var port;\n" // Set to our mock port by C++.
263 "\n" 263 "\n"
264 "main() {\n" 264 "main() {\n"
265 "}"; 265 "}";
(...skipping 22 matching lines...) Expand all
288 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); 288 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
289 EXPECT_VALID(port); 289 EXPECT_VALID(port);
290 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 290 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
291 291
292 Array& service_msg = Array::Handle(); 292 Array& service_msg = Array::Handle();
293 293
294 // Fetch object. 294 // Fetch object.
295 service_msg = EvalF(lib, "[0, port, '0', 'getObject', " 295 service_msg = EvalF(lib, "[0, port, '0', 'getObject', "
296 "['objectId'], ['objects/%" Pd "']]", id); 296 "['objectId'], ['objects/%" Pd "']]", id);
297 Service::HandleIsolateMessage(isolate, service_msg); 297 Service::HandleIsolateMessage(isolate, service_msg);
298 handler.HandleNextMessage(); 298 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
299 299
300 // Check type. 300 // Check type.
301 EXPECT_SUBSTRING("\"type\":\"Object\"", handler.msg()); 301 EXPECT_SUBSTRING("\"type\":\"Object\"", handler.msg());
302 EXPECT_SUBSTRING("\"_vmType\":\"TokenStream\"", handler.msg()); 302 EXPECT_SUBSTRING("\"_vmType\":\"TokenStream\"", handler.msg());
303 // Check for members array. 303 // Check for members array.
304 EXPECT_SUBSTRING("\"members\":[", handler.msg()); 304 EXPECT_SUBSTRING("\"members\":[", handler.msg());
305 } 305 }
306 306
307 307
308 TEST_CASE(Service_PcDescriptors) { 308 TEST_CASE(Service_PcDescriptors) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); 350 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
351 EXPECT_VALID(port); 351 EXPECT_VALID(port);
352 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 352 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
353 353
354 Array& service_msg = Array::Handle(); 354 Array& service_msg = Array::Handle();
355 355
356 // Fetch object. 356 // Fetch object.
357 service_msg = EvalF(lib, "[0, port, '0', 'getObject', " 357 service_msg = EvalF(lib, "[0, port, '0', 'getObject', "
358 "['objectId'], ['objects/%" Pd "']]", id); 358 "['objectId'], ['objects/%" Pd "']]", id);
359 Service::HandleIsolateMessage(isolate, service_msg); 359 Service::HandleIsolateMessage(isolate, service_msg);
360 handler.HandleNextMessage(); 360 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
361 // Check type. 361 // Check type.
362 EXPECT_SUBSTRING("\"type\":\"Object\"", handler.msg()); 362 EXPECT_SUBSTRING("\"type\":\"Object\"", handler.msg());
363 EXPECT_SUBSTRING("\"_vmType\":\"PcDescriptors\"", handler.msg()); 363 EXPECT_SUBSTRING("\"_vmType\":\"PcDescriptors\"", handler.msg());
364 // Check for members array. 364 // Check for members array.
365 EXPECT_SUBSTRING("\"members\":[", handler.msg()); 365 EXPECT_SUBSTRING("\"members\":[", handler.msg());
366 } 366 }
367 367
368 368
369 TEST_CASE(Service_LocalVarDescriptors) { 369 TEST_CASE(Service_LocalVarDescriptors) {
370 const char* kScript = 370 const char* kScript =
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); 411 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
412 EXPECT_VALID(port); 412 EXPECT_VALID(port);
413 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 413 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
414 414
415 Array& service_msg = Array::Handle(); 415 Array& service_msg = Array::Handle();
416 416
417 // Fetch object. 417 // Fetch object.
418 service_msg = EvalF(lib, "[0, port, '0', 'getObject', " 418 service_msg = EvalF(lib, "[0, port, '0', 'getObject', "
419 "['objectId'], ['objects/%" Pd "']]", id); 419 "['objectId'], ['objects/%" Pd "']]", id);
420 Service::HandleIsolateMessage(isolate, service_msg); 420 Service::HandleIsolateMessage(isolate, service_msg);
421 handler.HandleNextMessage(); 421 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
422 // Check type. 422 // Check type.
423 EXPECT_SUBSTRING("\"type\":\"Object\"", handler.msg()); 423 EXPECT_SUBSTRING("\"type\":\"Object\"", handler.msg());
424 EXPECT_SUBSTRING("\"_vmType\":\"LocalVarDescriptors\"", handler.msg()); 424 EXPECT_SUBSTRING("\"_vmType\":\"LocalVarDescriptors\"", handler.msg());
425 // Check for members array. 425 // Check for members array.
426 EXPECT_SUBSTRING("\"members\":[", handler.msg()); 426 EXPECT_SUBSTRING("\"members\":[", handler.msg());
427 } 427 }
428 428
429 429
430 TEST_CASE(Service_Address) { 430 TEST_CASE(Service_Address) {
431 const char* kScript = 431 const char* kScript =
(...skipping 24 matching lines...) Expand all
456 bool ref = offset % 2 == 0; 456 bool ref = offset % 2 == 0;
457 OS::SNPrint(buf, sizeof(buf), 457 OS::SNPrint(buf, sizeof(buf),
458 (ref 458 (ref
459 ? "[0, port, '0', '_getObjectByAddress', " 459 ? "[0, port, '0', '_getObjectByAddress', "
460 "['address', 'ref'], ['%" Px "', 'true']]" 460 "['address', 'ref'], ['%" Px "', 'true']]"
461 : "[0, port, '0', '_getObjectByAddress', " 461 : "[0, port, '0', '_getObjectByAddress', "
462 "['address'], ['%" Px "']]"), 462 "['address'], ['%" Px "']]"),
463 addr); 463 addr);
464 service_msg = Eval(lib, buf); 464 service_msg = Eval(lib, buf);
465 Service::HandleIsolateMessage(isolate, service_msg); 465 Service::HandleIsolateMessage(isolate, service_msg);
466 handler.HandleNextMessage(); 466 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
467 EXPECT_SUBSTRING(ref ? "\"type\":\"@Instance\"" : 467 EXPECT_SUBSTRING(ref ? "\"type\":\"@Instance\"" :
468 "\"type\":\"Instance\"", 468 "\"type\":\"Instance\"",
469 handler.msg()); 469 handler.msg());
470 EXPECT_SUBSTRING("\"kind\":\"String\"", handler.msg()); 470 EXPECT_SUBSTRING("\"kind\":\"String\"", handler.msg());
471 EXPECT_SUBSTRING("foobar", handler.msg()); 471 EXPECT_SUBSTRING("foobar", handler.msg());
472 } 472 }
473 // Expect null when no object is found. 473 // Expect null when no object is found.
474 service_msg = Eval(lib, "[0, port, '0', '_getObjectByAddress', " 474 service_msg = Eval(lib, "[0, port, '0', '_getObjectByAddress', "
475 "['address'], ['7']]"); 475 "['address'], ['7']]");
476 Service::HandleIsolateMessage(isolate, service_msg); 476 Service::HandleIsolateMessage(isolate, service_msg);
477 handler.HandleNextMessage(); 477 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
478 // TODO(turnidge): Should this be a ServiceException instead? 478 // TODO(turnidge): Should this be a ServiceException instead?
479 EXPECT_SUBSTRING("{\"type\":\"Sentinel\",\"kind\":\"Free\"," 479 EXPECT_SUBSTRING("{\"type\":\"Sentinel\",\"kind\":\"Free\","
480 "\"valueAsString\":\"<free>\"", 480 "\"valueAsString\":\"<free>\"",
481 handler.msg()); 481 handler.msg());
482 } 482 }
483 483
484 484
485 static const char* alpha_callback( 485 static const char* alpha_callback(
486 const char* name, 486 const char* name,
487 const char** option_keys, 487 const char** option_keys,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 ServiceTestMessageHandler handler; 525 ServiceTestMessageHandler handler;
526 Dart_Port port_id = PortMap::CreatePort(&handler); 526 Dart_Port port_id = PortMap::CreatePort(&handler);
527 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); 527 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
528 EXPECT_VALID(port); 528 EXPECT_VALID(port);
529 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 529 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
530 530
531 531
532 Array& service_msg = Array::Handle(); 532 Array& service_msg = Array::Handle();
533 service_msg = Eval(lib, "[0, port, '\"', 'alpha', [], []]"); 533 service_msg = Eval(lib, "[0, port, '\"', 'alpha', [], []]");
534 Service::HandleRootMessage(service_msg); 534 Service::HandleRootMessage(service_msg);
535 handler.HandleNextMessage(); 535 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
536 EXPECT_STREQ("{\"jsonrpc\":\"2.0\", \"result\":alpha,\"id\":\"\\\"\"}", 536 EXPECT_STREQ("{\"jsonrpc\":\"2.0\", \"result\":alpha,\"id\":\"\\\"\"}",
537 handler.msg()); 537 handler.msg());
538 service_msg = Eval(lib, "[0, port, 1, 'beta', [], []]"); 538 service_msg = Eval(lib, "[0, port, 1, 'beta', [], []]");
539 Service::HandleRootMessage(service_msg); 539 Service::HandleRootMessage(service_msg);
540 handler.HandleNextMessage(); 540 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
541 EXPECT_STREQ("{\"jsonrpc\":\"2.0\", \"result\":beta,\"id\":1}", 541 EXPECT_STREQ("{\"jsonrpc\":\"2.0\", \"result\":beta,\"id\":1}",
542 handler.msg()); 542 handler.msg());
543 } 543 }
544 544
545 545
546 TEST_CASE(Service_EmbedderIsolateHandler) { 546 TEST_CASE(Service_EmbedderIsolateHandler) {
547 const char* kScript = 547 const char* kScript =
548 "var port;\n" // Set to our mock port by C++. 548 "var port;\n" // Set to our mock port by C++.
549 "\n" 549 "\n"
550 "var x = 7;\n" 550 "var x = 7;\n"
(...skipping 14 matching lines...) Expand all
565 // Build a mock message handler and wrap it in a dart port. 565 // Build a mock message handler and wrap it in a dart port.
566 ServiceTestMessageHandler handler; 566 ServiceTestMessageHandler handler;
567 Dart_Port port_id = PortMap::CreatePort(&handler); 567 Dart_Port port_id = PortMap::CreatePort(&handler);
568 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); 568 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
569 EXPECT_VALID(port); 569 EXPECT_VALID(port);
570 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 570 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
571 571
572 Array& service_msg = Array::Handle(); 572 Array& service_msg = Array::Handle();
573 service_msg = Eval(lib, "[0, port, '0', 'alpha', [], []]"); 573 service_msg = Eval(lib, "[0, port, '0', 'alpha', [], []]");
574 Service::HandleIsolateMessage(isolate, service_msg); 574 Service::HandleIsolateMessage(isolate, service_msg);
575 handler.HandleNextMessage(); 575 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
576 EXPECT_STREQ("{\"jsonrpc\":\"2.0\", \"result\":alpha,\"id\":\"0\"}", 576 EXPECT_STREQ("{\"jsonrpc\":\"2.0\", \"result\":alpha,\"id\":\"0\"}",
577 handler.msg()); 577 handler.msg());
578 service_msg = Eval(lib, "[0, port, '0', 'beta', [], []]"); 578 service_msg = Eval(lib, "[0, port, '0', 'beta', [], []]");
579 Service::HandleIsolateMessage(isolate, service_msg); 579 Service::HandleIsolateMessage(isolate, service_msg);
580 handler.HandleNextMessage(); 580 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
581 EXPECT_STREQ("{\"jsonrpc\":\"2.0\", \"result\":beta,\"id\":\"0\"}", 581 EXPECT_STREQ("{\"jsonrpc\":\"2.0\", \"result\":beta,\"id\":\"0\"}",
582 handler.msg()); 582 handler.msg());
583 } 583 }
584 584
585 // TODO(zra): Remove when tests are ready to enable. 585 // TODO(zra): Remove when tests are ready to enable.
586 #if !defined(TARGET_ARCH_ARM64) 586 #if !defined(TARGET_ARCH_ARM64)
587 587
588 TEST_CASE(Service_Profile) { 588 TEST_CASE(Service_Profile) {
589 const char* kScript = 589 const char* kScript =
590 "var port;\n" // Set to our mock port by C++. 590 "var port;\n" // Set to our mock port by C++.
(...skipping 13 matching lines...) Expand all
604 // Build a mock message handler and wrap it in a dart port. 604 // Build a mock message handler and wrap it in a dart port.
605 ServiceTestMessageHandler handler; 605 ServiceTestMessageHandler handler;
606 Dart_Port port_id = PortMap::CreatePort(&handler); 606 Dart_Port port_id = PortMap::CreatePort(&handler);
607 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id)); 607 Dart_Handle port = Api::NewHandle(isolate, SendPort::New(port_id));
608 EXPECT_VALID(port); 608 EXPECT_VALID(port);
609 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 609 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
610 610
611 Array& service_msg = Array::Handle(); 611 Array& service_msg = Array::Handle();
612 service_msg = Eval(lib, "[0, port, '0', '_getCpuProfile', [], []]"); 612 service_msg = Eval(lib, "[0, port, '0', '_getCpuProfile', [], []]");
613 Service::HandleIsolateMessage(isolate, service_msg); 613 Service::HandleIsolateMessage(isolate, service_msg);
614 handler.HandleNextMessage(); 614 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
615 // Expect error (tags required). 615 // Expect error (tags required).
616 EXPECT_SUBSTRING("\"error\"", handler.msg()); 616 EXPECT_SUBSTRING("\"error\"", handler.msg());
617 617
618 service_msg = 618 service_msg =
619 Eval(lib, "[0, port, '0', '_getCpuProfile', ['tags'], ['None']]"); 619 Eval(lib, "[0, port, '0', '_getCpuProfile', ['tags'], ['None']]");
620 Service::HandleIsolateMessage(isolate, service_msg); 620 Service::HandleIsolateMessage(isolate, service_msg);
621 handler.HandleNextMessage(); 621 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
622 // Expect profile 622 // Expect profile
623 EXPECT_SUBSTRING("\"type\":\"_CpuProfile\"", handler.msg()); 623 EXPECT_SUBSTRING("\"type\":\"_CpuProfile\"", handler.msg());
624 624
625 service_msg = 625 service_msg =
626 Eval(lib, "[0, port, '0', '_getCpuProfile', ['tags'], ['Bogus']]"); 626 Eval(lib, "[0, port, '0', '_getCpuProfile', ['tags'], ['Bogus']]");
627 Service::HandleIsolateMessage(isolate, service_msg); 627 Service::HandleIsolateMessage(isolate, service_msg);
628 handler.HandleNextMessage(); 628 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
629 // Expect error. 629 // Expect error.
630 EXPECT_SUBSTRING("\"error\"", handler.msg()); 630 EXPECT_SUBSTRING("\"error\"", handler.msg());
631 } 631 }
632 632
633 #endif // !defined(TARGET_ARCH_ARM64) 633 #endif // !defined(TARGET_ARCH_ARM64)
634 634
635 } // namespace dart 635 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/service_isolate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698