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

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

Issue 1645423002: Return an error in many service RPCs if the isolate is not runnable (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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/service.md ('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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 " return d;\n" 160 " return d;\n"
161 " }\n" 161 " }\n"
162 "}\n" 162 "}\n"
163 "main() {\n" 163 "main() {\n"
164 " var z = new A();\n" 164 " var z = new A();\n"
165 " var x = z.c();\n" 165 " var x = z.c();\n"
166 " x();\n" 166 " x();\n"
167 "}"; 167 "}";
168 168
169 Isolate* isolate = thread->isolate(); 169 Isolate* isolate = thread->isolate();
170 isolate->set_is_runnable(true);
170 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 171 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
171 EXPECT_VALID(lib); 172 EXPECT_VALID(lib);
172 Library& vmlib = Library::Handle(); 173 Library& vmlib = Library::Handle();
173 vmlib ^= Api::UnwrapHandle(lib); 174 vmlib ^= Api::UnwrapHandle(lib);
174 EXPECT(!vmlib.IsNull()); 175 EXPECT(!vmlib.IsNull());
175 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); 176 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
176 EXPECT_VALID(result); 177 EXPECT_VALID(result);
177 const Class& class_a = Class::Handle(GetClass(vmlib, "A")); 178 const Class& class_a = Class::Handle(GetClass(vmlib, "A"));
178 EXPECT(!class_a.IsNull()); 179 EXPECT(!class_a.IsNull());
179 const Function& function_c = Function::Handle(GetFunction(class_a, "c")); 180 const Function& function_c = Function::Handle(GetFunction(class_a, "c"));
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 267
267 268
268 TEST_CASE(Service_TokenStream) { 269 TEST_CASE(Service_TokenStream) {
269 const char* kScript = 270 const char* kScript =
270 "var port;\n" // Set to our mock port by C++. 271 "var port;\n" // Set to our mock port by C++.
271 "\n" 272 "\n"
272 "main() {\n" 273 "main() {\n"
273 "}"; 274 "}";
274 275
275 Isolate* isolate = thread->isolate(); 276 Isolate* isolate = thread->isolate();
276 277 isolate->set_is_runnable(true);
277 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 278 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
278 EXPECT_VALID(lib); 279 EXPECT_VALID(lib);
279 Library& vmlib = Library::Handle(); 280 Library& vmlib = Library::Handle();
280 vmlib ^= Api::UnwrapHandle(lib); 281 vmlib ^= Api::UnwrapHandle(lib);
281 EXPECT(!vmlib.IsNull()); 282 EXPECT(!vmlib.IsNull());
282 283
283 const String& script_name = String::Handle(String::New("test-lib")); 284 const String& script_name = String::Handle(String::New("test-lib"));
284 EXPECT(!script_name.IsNull()); 285 EXPECT(!script_name.IsNull());
285 const Script& script = Script::Handle(vmlib.LookupScript(script_name)); 286 const Script& script = Script::Handle(vmlib.LookupScript(script_name));
286 EXPECT(!script.IsNull()); 287 EXPECT(!script.IsNull());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 " return d;\n" 326 " return d;\n"
326 " }\n" 327 " }\n"
327 "}\n" 328 "}\n"
328 "main() {\n" 329 "main() {\n"
329 " var z = new A();\n" 330 " var z = new A();\n"
330 " var x = z.c();\n" 331 " var x = z.c();\n"
331 " x();\n" 332 " x();\n"
332 "}"; 333 "}";
333 334
334 Isolate* isolate = thread->isolate(); 335 Isolate* isolate = thread->isolate();
336 isolate->set_is_runnable(true);
335 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 337 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
336 EXPECT_VALID(lib); 338 EXPECT_VALID(lib);
337 Library& vmlib = Library::Handle(); 339 Library& vmlib = Library::Handle();
338 vmlib ^= Api::UnwrapHandle(lib); 340 vmlib ^= Api::UnwrapHandle(lib);
339 EXPECT(!vmlib.IsNull()); 341 EXPECT(!vmlib.IsNull());
340 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); 342 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
341 EXPECT_VALID(result); 343 EXPECT_VALID(result);
342 const Class& class_a = Class::Handle(GetClass(vmlib, "A")); 344 const Class& class_a = Class::Handle(GetClass(vmlib, "A"));
343 EXPECT(!class_a.IsNull()); 345 EXPECT(!class_a.IsNull());
344 const Function& function_c = Function::Handle(GetFunction(class_a, "c")); 346 const Function& function_c = Function::Handle(GetFunction(class_a, "c"));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 " return d;\n" 388 " return d;\n"
387 " }\n" 389 " }\n"
388 "}\n" 390 "}\n"
389 "main() {\n" 391 "main() {\n"
390 " var z = new A();\n" 392 " var z = new A();\n"
391 " var x = z.c();\n" 393 " var x = z.c();\n"
392 " x();\n" 394 " x();\n"
393 "}"; 395 "}";
394 396
395 Isolate* isolate = thread->isolate(); 397 Isolate* isolate = thread->isolate();
398 isolate->set_is_runnable(true);
396 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 399 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
397 EXPECT_VALID(lib); 400 EXPECT_VALID(lib);
398 Library& vmlib = Library::Handle(); 401 Library& vmlib = Library::Handle();
399 vmlib ^= Api::UnwrapHandle(lib); 402 vmlib ^= Api::UnwrapHandle(lib);
400 EXPECT(!vmlib.IsNull()); 403 EXPECT(!vmlib.IsNull());
401 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); 404 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
402 EXPECT_VALID(result); 405 EXPECT_VALID(result);
403 const Class& class_a = Class::Handle(GetClass(vmlib, "A")); 406 const Class& class_a = Class::Handle(GetClass(vmlib, "A"));
404 EXPECT(!class_a.IsNull()); 407 EXPECT(!class_a.IsNull());
405 const Function& function_c = Function::Handle(GetFunction(class_a, "c")); 408 const Function& function_c = Function::Handle(GetFunction(class_a, "c"));
(...skipping 30 matching lines...) Expand all
436 439
437 440
438 TEST_CASE(Service_Address) { 441 TEST_CASE(Service_Address) {
439 const char* kScript = 442 const char* kScript =
440 "var port;\n" // Set to our mock port by C++. 443 "var port;\n" // Set to our mock port by C++.
441 "\n" 444 "\n"
442 "main() {\n" 445 "main() {\n"
443 "}"; 446 "}";
444 447
445 Isolate* isolate = thread->isolate(); 448 Isolate* isolate = thread->isolate();
449 isolate->set_is_runnable(true);
446 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 450 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
447 EXPECT_VALID(lib); 451 EXPECT_VALID(lib);
448 452
449 // Build a mock message handler and wrap it in a dart port. 453 // Build a mock message handler and wrap it in a dart port.
450 ServiceTestMessageHandler handler; 454 ServiceTestMessageHandler handler;
451 Dart_Port port_id = PortMap::CreatePort(&handler); 455 Dart_Port port_id = PortMap::CreatePort(&handler);
452 Dart_Handle port = Api::NewHandle(thread, SendPort::New(port_id)); 456 Dart_Handle port = Api::NewHandle(thread, SendPort::New(port_id));
453 EXPECT_VALID(port); 457 EXPECT_VALID(port);
454 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port)); 458 EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
455 459
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 const char* kScript = 600 const char* kScript =
597 "var port;\n" // Set to our mock port by C++. 601 "var port;\n" // Set to our mock port by C++.
598 "\n" 602 "\n"
599 "var x = 7;\n" 603 "var x = 7;\n"
600 "main() {\n" 604 "main() {\n"
601 " x = x * x;\n" 605 " x = x * x;\n"
602 " x = x / 13;\n" 606 " x = x / 13;\n"
603 "}"; 607 "}";
604 608
605 Isolate* isolate = thread->isolate(); 609 Isolate* isolate = thread->isolate();
610 isolate->set_is_runnable(true);
606 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 611 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
607 EXPECT_VALID(lib); 612 EXPECT_VALID(lib);
608 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); 613 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
609 EXPECT_VALID(result); 614 EXPECT_VALID(result);
610 615
611 // Build a mock message handler and wrap it in a dart port. 616 // Build a mock message handler and wrap it in a dart port.
612 ServiceTestMessageHandler handler; 617 ServiceTestMessageHandler handler;
613 Dart_Port port_id = PortMap::CreatePort(&handler); 618 Dart_Port port_id = PortMap::CreatePort(&handler);
614 Dart_Handle port = Api::NewHandle(thread, SendPort::New(port_id)); 619 Dart_Handle port = Api::NewHandle(thread, SendPort::New(port_id));
615 EXPECT_VALID(port); 620 EXPECT_VALID(port);
(...skipping 17 matching lines...) Expand all
633 Eval(lib, "[0, port, '0', '_getCpuProfile', ['tags'], ['Bogus']]"); 638 Eval(lib, "[0, port, '0', '_getCpuProfile', ['tags'], ['Bogus']]");
634 Service::HandleIsolateMessage(isolate, service_msg); 639 Service::HandleIsolateMessage(isolate, service_msg);
635 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage()); 640 EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
636 // Expect error. 641 // Expect error.
637 EXPECT_SUBSTRING("\"error\"", handler.msg()); 642 EXPECT_SUBSTRING("\"error\"", handler.msg());
638 } 643 }
639 644
640 #endif // !defined(TARGET_ARCH_ARM64) 645 #endif // !defined(TARGET_ARCH_ARM64)
641 646
642 } // namespace dart 647 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/service/service.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698