From ea8e7d10d7178004aa8368410618e6f08b90d2fa Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Wed, 17 Jul 2019 15:47:32 -0700 Subject: [PATCH] Move to isolated testing. Modify the MapInfoCreateMemoryTest to work in the isolated mode. Test: Ran unit tests on host/target. Change-Id: I84e01d96e852acd813e0f203b4a207cfaf8ca556 --- libunwindstack/Android.bp | 2 ++ libunwindstack/tests/IsolatedSettings.cpp | 26 +++++++++++++++++++ .../tests/MapInfoCreateMemoryTest.cpp | 16 ++++-------- 3 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 libunwindstack/tests/IsolatedSettings.cpp diff --git a/libunwindstack/Android.bp b/libunwindstack/Android.bp index a0a6b4fd5..dfe9747ff 100644 --- a/libunwindstack/Android.bp +++ b/libunwindstack/Android.bp @@ -162,6 +162,7 @@ cc_test_library { cc_test { name: "libunwindstack_test", defaults: ["libunwindstack_flags"], + isolated: true, srcs: [ "tests/ArmExidxDecodeTest.cpp", @@ -184,6 +185,7 @@ cc_test { "tests/ElfInterfaceTest.cpp", "tests/ElfTest.cpp", "tests/ElfTestUtils.cpp", + "tests/IsolatedSettings.cpp", "tests/JitDebugTest.cpp", "tests/LocalUnwinderTest.cpp", "tests/LogFake.cpp", diff --git a/libunwindstack/tests/IsolatedSettings.cpp b/libunwindstack/tests/IsolatedSettings.cpp new file mode 100644 index 000000000..dbd8bd608 --- /dev/null +++ b/libunwindstack/tests/IsolatedSettings.cpp @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +extern "C" bool GetInitialArgs(const char*** args, size_t* num_args) { + static const char* initial_args[2] = {"--slow_threshold_ms=90000", + "--deadline_threshold_ms=120000"}; + *args = initial_args; + *num_args = 2; + return true; +} diff --git a/libunwindstack/tests/MapInfoCreateMemoryTest.cpp b/libunwindstack/tests/MapInfoCreateMemoryTest.cpp index 5b4ca7c44..6c1cfa222 100644 --- a/libunwindstack/tests/MapInfoCreateMemoryTest.cpp +++ b/libunwindstack/tests/MapInfoCreateMemoryTest.cpp @@ -58,7 +58,7 @@ class MapInfoCreateMemoryTest : public ::testing::Test { ASSERT_TRUE(android::base::WriteFully(fd, buffer.data(), buffer.size())); } - static void SetUpTestSuite() { + void SetUp() override { std::vector buffer(12288, 0); memcpy(buffer.data(), ELFMAG, SELFMAG); buffer[EI_CLASS] = ELFCLASS32; @@ -72,9 +72,7 @@ class MapInfoCreateMemoryTest : public ::testing::Test { InitElf(elf32_at_map_.fd, 0x1000, 0x2000, ELFCLASS32); InitElf(elf64_at_map_.fd, 0x2000, 0x3000, ELFCLASS64); - } - void SetUp() override { memory_ = new MemoryFake; process_memory_.reset(memory_); } @@ -82,17 +80,13 @@ class MapInfoCreateMemoryTest : public ::testing::Test { MemoryFake* memory_; std::shared_ptr process_memory_; - static TemporaryFile elf_; + TemporaryFile elf_; - static TemporaryFile elf_at_1000_; + TemporaryFile elf_at_1000_; - static TemporaryFile elf32_at_map_; - static TemporaryFile elf64_at_map_; + TemporaryFile elf32_at_map_; + TemporaryFile elf64_at_map_; }; -TemporaryFile MapInfoCreateMemoryTest::elf_; -TemporaryFile MapInfoCreateMemoryTest::elf_at_1000_; -TemporaryFile MapInfoCreateMemoryTest::elf32_at_map_; -TemporaryFile MapInfoCreateMemoryTest::elf64_at_map_; TEST_F(MapInfoCreateMemoryTest, end_le_start) { MapInfo info(nullptr, 0x100, 0x100, 0, 0, elf_.path);