Commit 32a6fc7d authored by sammc's avatar sammc Committed by Commit bot

Fix some leaks and failures under valgrind in JS extensions unit tests.

This change:
- Adds running the GC until the v8 heap size reaches steady state during
  ModuleSystemTest::TearDown. This is necessary to ensure that
  gin::Wrappable objects are freed, as finalizers for JS objects aren't
  run during isolate shut down.
- Removes a racy check that failed under valgrind.

BUG=389016,406487

Review URL: https://codereview.chromium.org/502893002

Cr-Commit-Position: refs/heads/master@{#294779}
parent fba512c9
......@@ -409,12 +409,6 @@ class SerialApiTest : public ApiTestBase {
&SerialApiTest::CreateSerialService, base::Unretained(this)));
}
virtual void TearDown() OVERRIDE {
if (io_handler_.get())
EXPECT_TRUE(io_handler_->HasOneRef());
ApiTestBase::TearDown();
}
scoped_refptr<TestIoHandlerBase> io_handler_;
private:
......
......@@ -211,18 +211,33 @@ v8::Handle<v8::Object> ModuleSystemTestEnvironment::CreateGlobal(
ModuleSystemTest::ModuleSystemTest()
: isolate_(v8::Isolate::GetCurrent()),
env_(CreateEnvironment()),
should_assertions_be_made_(true) {
}
ModuleSystemTest::~ModuleSystemTest() {
}
void ModuleSystemTest::SetUp() {
env_ = CreateEnvironment();
}
void ModuleSystemTest::TearDown() {
// All tests must assert at least once unless otherwise specified.
EXPECT_EQ(should_assertions_be_made_,
env_->assert_natives()->assertion_made());
EXPECT_FALSE(env_->assert_natives()->failed());
env_.reset();
v8::HeapStatistics stats;
isolate_->GetHeapStatistics(&stats);
size_t old_heap_size = 0;
// Run the GC until the heap size reaches a steady state to ensure that
// all the garbage is collected.
while (stats.used_heap_size() != old_heap_size) {
old_heap_size = stats.used_heap_size();
isolate_->RequestGarbageCollectionForTesting(
v8::Isolate::kFullGarbageCollection);
isolate_->GetHeapStatistics(&stats);
}
}
scoped_ptr<ModuleSystemTestEnvironment> ModuleSystemTest::CreateEnvironment() {
......
......@@ -81,6 +81,7 @@ class ModuleSystemTest : public testing::Test {
ModuleSystemTest();
virtual ~ModuleSystemTest();
virtual void SetUp() OVERRIDE;
virtual void TearDown() OVERRIDE;
protected:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment