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

Side by Side Diff: runtime/vm/unit_test.h

Issue 2640573003: Resolution for issue #5092: Unit test handle checks consider dangling handles to be valid. (Closed)
Patch Set: Created 3 years, 11 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
« runtime/vm/thread_registry.cc ('K') | « runtime/vm/thread_registry.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 #ifndef RUNTIME_VM_UNIT_TEST_H_ 5 #ifndef RUNTIME_VM_UNIT_TEST_H_
6 #define RUNTIME_VM_UNIT_TEST_H_ 6 #define RUNTIME_VM_UNIT_TEST_H_
7 7
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 9
10 #include "platform/globals.h" 10 #include "platform/globals.h"
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 do { \ 540 do { \
541 Dart_Handle tmp_handle = (handle); \ 541 Dart_Handle tmp_handle = (handle); \
542 if (Dart_IsError(tmp_handle)) { \ 542 if (Dart_IsError(tmp_handle)) { \
543 dart::Expect(__FILE__, __LINE__) \ 543 dart::Expect(__FILE__, __LINE__) \
544 .Fail( \ 544 .Fail( \
545 "expected '%s' to be a valid handle but found an error " \ 545 "expected '%s' to be a valid handle but found an error " \
546 "handle:\n" \ 546 "handle:\n" \
547 " '%s'\n", \ 547 " '%s'\n", \
548 #handle, Dart_GetError(tmp_handle)); \ 548 #handle, Dart_GetError(tmp_handle)); \
549 } \ 549 } \
550 if (!Dart_IsValid(tmp_handle)) { \
bkonyi 2017/01/18 00:47:01 I'm not sure if we'd rather create a new macro or
siva 2017/01/18 23:27:06 The check for the handle being valid should happen
bkonyi 2017/01/19 01:05:13 Done.
551 dart::Expect(__FILE__, __LINE__) \
552 .Fail( \
553 "expected '%s' to be a valid handle but '%s' has already been " \
554 "freed\n", \
555 #handle, #handle); \
556 } \
550 } while (0) 557 } while (0)
551 558
552 #define EXPECT_ERROR(handle, substring) \ 559 #define EXPECT_ERROR(handle, substring) \
553 do { \ 560 do { \
554 Dart_Handle tmp_handle = (handle); \ 561 Dart_Handle tmp_handle = (handle); \
siva 2017/01/18 23:27:06 This should also have a call to Dart_IsValid(...)
555 if (Dart_IsError(tmp_handle)) { \ 562 if (Dart_IsError(tmp_handle)) { \
556 dart::Expect(__FILE__, __LINE__) \ 563 dart::Expect(__FILE__, __LINE__) \
557 .IsSubstring((substring), Dart_GetError(tmp_handle)); \ 564 .IsSubstring((substring), Dart_GetError(tmp_handle)); \
558 } else { \ 565 } else { \
559 dart::Expect(__FILE__, __LINE__) \ 566 dart::Expect(__FILE__, __LINE__) \
560 .Fail( \ 567 .Fail( \
561 "expected '%s' to be an error handle but found a valid " \ 568 "expected '%s' to be an error handle but found a valid " \
562 "handle.\n", \ 569 "handle.\n", \
563 #handle); \ 570 #handle); \
564 } \ 571 } \
565 } while (0) 572 } while (0)
566 573
574 #define EXPECT_INVALID(handle) \
575 do { \
bkonyi 2017/01/18 00:44:47 Should this check for error handles as well, shoul
siva 2017/01/18 23:27:06 Why do we need this macro, couldn't the unit tests
bkonyi 2017/01/19 01:05:13 You're right. Removed.
576 Dart_Handle tmp_handle = (handle); \
577 if (Dart_IsValid(tmp_handle)) { \
578 dart::Expect(__FILE__, __LINE__) \
579 .Fail( \
580 "expected '%s' to be an invalid handle but '%s' has not been " \
581 "freed\n", \
582 #handle, #handle); \
583 } \
584 } while (0)
585
567 #define EXPECT_TRUE(handle) \ 586 #define EXPECT_TRUE(handle) \
568 do { \ 587 do { \
569 Dart_Handle tmp_handle = (handle); \ 588 Dart_Handle tmp_handle = (handle); \
570 if (Dart_IsBoolean(tmp_handle)) { \ 589 if (Dart_IsBoolean(tmp_handle)) { \
571 bool value; \ 590 bool value; \
572 Dart_BooleanValue(tmp_handle, &value); \ 591 Dart_BooleanValue(tmp_handle, &value); \
573 if (!value) { \ 592 if (!value) { \
574 dart::Expect(__FILE__, __LINE__) \ 593 dart::Expect(__FILE__, __LINE__) \
575 .Fail("expected True, but was '%s'\n", #handle); \ 594 .Fail("expected True, but was '%s'\n", #handle); \
576 } \ 595 } \
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 ~SetFlagScope() { *flag_ = original_value_; } 627 ~SetFlagScope() { *flag_ = original_value_; }
609 628
610 private: 629 private:
611 T* flag_; 630 T* flag_;
612 T original_value_; 631 T original_value_;
613 }; 632 };
614 633
615 } // namespace dart 634 } // namespace dart
616 635
617 #endif // RUNTIME_VM_UNIT_TEST_H_ 636 #endif // RUNTIME_VM_UNIT_TEST_H_
OLDNEW
« runtime/vm/thread_registry.cc ('K') | « runtime/vm/thread_registry.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698