Commit 65d5a9e4 authored by binji's avatar binji Committed by Commit bot

[NaCl SDK] kernel_wrap_tests: Setup munmap mocks before calling ki_init

If munmap is called during ki_init() in a kernel_wrap_test, it will print a
message saying the call was unexpected. This will cause a deadlock since it is
trying to print a message inside the memory allocator.

BUG=378596
R=sbc@chromium.org
CQ_EXTRA_TRYBOTS=tryserver.chromium.linux:linux_nacl_sdk;tryserver.chromium.mac:mac_nacl_sdk;tryserver.chromium.win:win_nacl_sdk

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

Cr-Commit-Position: refs/heads/master@{#374745}
parent 654c8c4f
...@@ -150,9 +150,6 @@ class KernelWrapTest : public ::testing::Test { ...@@ -150,9 +150,6 @@ class KernelWrapTest : public ::testing::Test {
.WillOnce(Return(1)) .WillOnce(Return(1))
.WillOnce(Return(2)); .WillOnce(Return(2));
ASSERT_EQ(0, ki_push_state_for_testing());
ASSERT_EQ(0, ki_init(&mock));
// We allow write to be called any number of times, and it forwards to // We allow write to be called any number of times, and it forwards to
// _real_write. This prevents an infinite loop writing output if there is a // _real_write. This prevents an infinite loop writing output if there is a
// failure. // failure.
...@@ -167,6 +164,9 @@ class KernelWrapTest : public ::testing::Test { ...@@ -167,6 +164,9 @@ class KernelWrapTest : public ::testing::Test {
ON_CALL(mock, munmap(_, _)) ON_CALL(mock, munmap(_, _))
.WillByDefault(Return(0)); .WillByDefault(Return(0));
EXPECT_CALL(mock, munmap(_, _)).Times(AnyNumber()); EXPECT_CALL(mock, munmap(_, _)).Times(AnyNumber());
ASSERT_EQ(0, ki_push_state_for_testing());
ASSERT_EQ(0, ki_init(&mock));
} }
void TearDown() { void TearDown() {
......
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