summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2017-07-11 15:29:32 -0700
committerChristopher Ferris <cferris@google.com>2017-07-11 19:10:34 -0700
commitf6d5431273a6293703853fc3d4043ed2c5d5a3c9 (patch)
tree38b0e92916e097f917d5464954e1434e96acc6f9
parent5aee3ff22a42f9ff7a35e0181d19821b1510fee2 (diff)
downloadsystem_core-f6d5431273a6293703853fc3d4043ed2c5d5a3c9.tar.gz
system_core-f6d5431273a6293703853fc3d4043ed2c5d5a3c9.tar.bz2
system_core-f6d5431273a6293703853fc3d4043ed2c5d5a3c9.zip
A few cleanups.
- Cleanup the blueprint file a bit. - Fix the formatting in DwarfMemoryTest.cpp. - Fix the misnamed test MemoryBuffer.cpp to MemoryBufferTest.cpp. - Add a function to find the location of the test files so it's not necessary to run the test in the same directory as the test files. Bug: 23762183 Test: Builds and unit tests pass. Change-Id: I5666972bd01f14b8ee47c518f1840f8aeb7fd08b
-rw-r--r--libunwindstack/Android.bp50
-rw-r--r--libunwindstack/tests/DwarfMemoryTest.cpp48
-rw-r--r--libunwindstack/tests/ElfTestUtils.cpp11
-rw-r--r--libunwindstack/tests/MemoryBufferTest.cpp (renamed from libunwindstack/tests/MemoryBuffer.cpp)0
4 files changed, 53 insertions, 56 deletions
diff --git a/libunwindstack/Android.bp b/libunwindstack/Android.bp
index a5af0a06a..a6044c88b 100644
--- a/libunwindstack/Android.bp
+++ b/libunwindstack/Android.bp
@@ -39,19 +39,10 @@ cc_defaults {
enabled: false,
},
},
-
- multilib: {
- lib32: {
- suffix: "32",
- },
- lib64: {
- suffix: "64",
- },
- },
}
-cc_defaults {
- name: "libunwindstack_common",
+cc_library {
+ name: "libunwindstack",
defaults: ["libunwindstack_flags"],
srcs: [
@@ -89,16 +80,11 @@ cc_defaults {
],
}
-cc_library {
- name: "libunwindstack",
- defaults: ["libunwindstack_common"],
-}
-
//-------------------------------------------------------------------------
// Unit Tests
//-------------------------------------------------------------------------
-cc_defaults {
- name: "libunwindstack_test_common",
+cc_test {
+ name: "libunwindstack_test",
defaults: ["libunwindstack_flags"],
srcs: [
@@ -121,7 +107,7 @@ cc_defaults {
"tests/MapInfoCreateMemoryTest.cpp",
"tests/MapInfoGetElfTest.cpp",
"tests/MapsTest.cpp",
- "tests/MemoryBuffer.cpp",
+ "tests/MemoryBufferTest.cpp",
"tests/MemoryFake.cpp",
"tests/MemoryFileTest.cpp",
"tests/MemoryLocalTest.cpp",
@@ -142,6 +128,7 @@ cc_defaults {
"libbase",
"liblog",
"liblzma",
+ "libunwindstack",
],
static_libs: [
@@ -155,16 +142,6 @@ cc_defaults {
],
},
},
-}
-
-// These unit tests run against the shared library.
-cc_test {
- name: "libunwindstack_test",
- defaults: ["libunwindstack_test_common"],
-
- shared_libs: [
- "libunwindstack",
- ],
data: [
"tests/files/elf32.xz",
@@ -188,8 +165,6 @@ cc_defaults {
static_libs: [
"liblog",
],
-
- compile_multilib: "both",
}
cc_binary {
@@ -205,20 +180,9 @@ cc_binary {
// Once these files are generated, use the xz command to compress the data.
cc_binary_host {
name: "gen_gnudebugdata",
-
- cflags: [
- "-Wall",
- "-Werror",
- "-Wextra",
- ],
+ defaults: ["libunwindstack_flags"],
srcs: [
"tests/GenGnuDebugdata.cpp",
],
-
- target: {
- darwin: {
- enabled: false,
- },
- },
}
diff --git a/libunwindstack/tests/DwarfMemoryTest.cpp b/libunwindstack/tests/DwarfMemoryTest.cpp
index 4877f36a7..b7df8f770 100644
--- a/libunwindstack/tests/DwarfMemoryTest.cpp
+++ b/libunwindstack/tests/DwarfMemoryTest.cpp
@@ -237,9 +237,13 @@ void DwarfMemoryTest::ReadEncodedValue_omit() {
ASSERT_EQ(0U, value);
}
-TEST_F(DwarfMemoryTest, ReadEncodedValue_omit_uint32_t) { ReadEncodedValue_omit<uint32_t>(); }
+TEST_F(DwarfMemoryTest, ReadEncodedValue_omit_uint32_t) {
+ ReadEncodedValue_omit<uint32_t>();
+}
-TEST_F(DwarfMemoryTest, ReadEncodedValue_omit_uint64_t) { ReadEncodedValue_omit<uint64_t>(); }
+TEST_F(DwarfMemoryTest, ReadEncodedValue_omit_uint64_t) {
+ ReadEncodedValue_omit<uint64_t>();
+}
TEST_F(DwarfMemoryTest, ReadEncodedValue_absptr_uint32_t) {
uint64_t value = 100;
@@ -302,9 +306,13 @@ void DwarfMemoryTest::ReadEncodedValue_leb128() {
ASSERT_EQ(0xffffffffffffe100ULL, value);
}
-TEST_F(DwarfMemoryTest, ReadEncodedValue_leb128_uint32_t) { ReadEncodedValue_leb128<uint32_t>(); }
+TEST_F(DwarfMemoryTest, ReadEncodedValue_leb128_uint32_t) {
+ ReadEncodedValue_leb128<uint32_t>();
+}
-TEST_F(DwarfMemoryTest, ReadEncodedValue_leb128_uint64_t) { ReadEncodedValue_leb128<uint64_t>(); }
+TEST_F(DwarfMemoryTest, ReadEncodedValue_leb128_uint64_t) {
+ ReadEncodedValue_leb128<uint64_t>();
+}
template <typename AddressType>
void DwarfMemoryTest::ReadEncodedValue_data1() {
@@ -319,9 +327,13 @@ void DwarfMemoryTest::ReadEncodedValue_data1() {
ASSERT_EQ(0xffffffffffffffe0ULL, value);
}
-TEST_F(DwarfMemoryTest, ReadEncodedValue_data1_uint32_t) { ReadEncodedValue_data1<uint32_t>(); }
+TEST_F(DwarfMemoryTest, ReadEncodedValue_data1_uint32_t) {
+ ReadEncodedValue_data1<uint32_t>();
+}
-TEST_F(DwarfMemoryTest, ReadEncodedValue_data1_uint64_t) { ReadEncodedValue_data1<uint64_t>(); }
+TEST_F(DwarfMemoryTest, ReadEncodedValue_data1_uint64_t) {
+ ReadEncodedValue_data1<uint64_t>();
+}
template <typename AddressType>
void DwarfMemoryTest::ReadEncodedValue_data2() {
@@ -336,9 +348,13 @@ void DwarfMemoryTest::ReadEncodedValue_data2() {
ASSERT_EQ(0xffffffffffffe000ULL, value);
}
-TEST_F(DwarfMemoryTest, ReadEncodedValue_data2_uint32_t) { ReadEncodedValue_data2<uint32_t>(); }
+TEST_F(DwarfMemoryTest, ReadEncodedValue_data2_uint32_t) {
+ ReadEncodedValue_data2<uint32_t>();
+}
-TEST_F(DwarfMemoryTest, ReadEncodedValue_data2_uint64_t) { ReadEncodedValue_data2<uint64_t>(); }
+TEST_F(DwarfMemoryTest, ReadEncodedValue_data2_uint64_t) {
+ ReadEncodedValue_data2<uint64_t>();
+}
template <typename AddressType>
void DwarfMemoryTest::ReadEncodedValue_data4() {
@@ -353,9 +369,13 @@ void DwarfMemoryTest::ReadEncodedValue_data4() {
ASSERT_EQ(0xffffffffe0000000ULL, value);
}
-TEST_F(DwarfMemoryTest, ReadEncodedValue_data4_uint32_t) { ReadEncodedValue_data4<uint32_t>(); }
+TEST_F(DwarfMemoryTest, ReadEncodedValue_data4_uint32_t) {
+ ReadEncodedValue_data4<uint32_t>();
+}
-TEST_F(DwarfMemoryTest, ReadEncodedValue_data4_uint64_t) { ReadEncodedValue_data4<uint64_t>(); }
+TEST_F(DwarfMemoryTest, ReadEncodedValue_data4_uint64_t) {
+ ReadEncodedValue_data4<uint64_t>();
+}
template <typename AddressType>
void DwarfMemoryTest::ReadEncodedValue_data8() {
@@ -370,9 +390,13 @@ void DwarfMemoryTest::ReadEncodedValue_data8() {
ASSERT_EQ(0xe000000000000000ULL, value);
}
-TEST_F(DwarfMemoryTest, ReadEncodedValue_data8_uint32_t) { ReadEncodedValue_data8<uint32_t>(); }
+TEST_F(DwarfMemoryTest, ReadEncodedValue_data8_uint32_t) {
+ ReadEncodedValue_data8<uint32_t>();
+}
-TEST_F(DwarfMemoryTest, ReadEncodedValue_data8_uint64_t) { ReadEncodedValue_data8<uint64_t>(); }
+TEST_F(DwarfMemoryTest, ReadEncodedValue_data8_uint64_t) {
+ ReadEncodedValue_data8<uint64_t>();
+}
template <typename AddressType>
void DwarfMemoryTest::ReadEncodedValue_non_zero_adjust() {
diff --git a/libunwindstack/tests/ElfTestUtils.cpp b/libunwindstack/tests/ElfTestUtils.cpp
index 8755f163b..81064ddf1 100644
--- a/libunwindstack/tests/ElfTestUtils.cpp
+++ b/libunwindstack/tests/ElfTestUtils.cpp
@@ -45,6 +45,15 @@ void TestInitEhdr(Ehdr* ehdr, uint32_t elf_class, uint32_t machine_type) {
ehdr->e_ehsize = sizeof(Ehdr);
}
+static std::string GetTestFileDirectory() {
+ std::string exec(testing::internal::GetArgvs()[0]);
+ auto const value = exec.find_last_of('/');
+ if (value == std::string::npos) {
+ return "tests/files/";
+ }
+ return exec.substr(0, value + 1) + "tests/files/";
+}
+
template <typename Ehdr, typename Shdr>
void TestInitGnuDebugdata(uint32_t elf_class, uint32_t machine, bool init_gnu_debugdata,
TestCopyFuncType copy_func) {
@@ -91,7 +100,7 @@ void TestInitGnuDebugdata(uint32_t elf_class, uint32_t machine, bool init_gnu_de
offset = symtab_offset + 0x100;
if (init_gnu_debugdata) {
// Read in the compressed elf data and copy it in.
- name = "tests/files/";
+ name = GetTestFileDirectory();
if (elf_class == ELFCLASS32) {
name += "elf32.xz";
} else {
diff --git a/libunwindstack/tests/MemoryBuffer.cpp b/libunwindstack/tests/MemoryBufferTest.cpp
index af3d6b9ae..af3d6b9ae 100644
--- a/libunwindstack/tests/MemoryBuffer.cpp
+++ b/libunwindstack/tests/MemoryBufferTest.cpp