summaryrefslogtreecommitdiff
path: root/libunwindstack/tests/ElfTest.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2017-07-19 15:50:22 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-07-19 15:50:22 +0000
commit9f7c071743effb977ba19f4efeece55da09eb707 (patch)
tree70c4716dbbb062911e37eee1e8382c3c4ed2bb59 /libunwindstack/tests/ElfTest.cpp
parent57db1511bdc8f1317997edc1850650f60055ad0c (diff)
parent2f80aa506fd17d84f00371f42b9bb274162cab6d (diff)
Merge "Add signal handling to the register object." am: 33913ebfb5 am: b945cc6de0
am: 2f80aa506f Change-Id: I0df6230ffb131aa0537802e00192ce9154963d02
Diffstat (limited to 'libunwindstack/tests/ElfTest.cpp')
-rw-r--r--libunwindstack/tests/ElfTest.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/libunwindstack/tests/ElfTest.cpp b/libunwindstack/tests/ElfTest.cpp
index 72ceb85ee4..ed1be3b334 100644
--- a/libunwindstack/tests/ElfTest.cpp
+++ b/libunwindstack/tests/ElfTest.cpp
@@ -26,6 +26,7 @@
#include <unwindstack/MapInfo.h>
#include "ElfTestUtils.h"
+#include "LogFake.h"
#include "MemoryFake.h"
#if !defined(PT_ARM_EXIDX)
@@ -131,6 +132,32 @@ TEST_F(ElfTest, elf_invalid) {
ASSERT_FALSE(elf.Step(0, nullptr, nullptr));
}
+TEST_F(ElfTest, elf32_invalid_machine) {
+ Elf elf(memory_);
+
+ InitElf32(EM_PPC);
+
+ ResetLogs();
+ ASSERT_FALSE(elf.Init());
+
+ ASSERT_EQ("", GetFakeLogBuf());
+ ASSERT_EQ("4 unwind 32 bit elf that is neither arm nor x86: e_machine = 20\n\n",
+ GetFakeLogPrint());
+}
+
+TEST_F(ElfTest, elf64_invalid_machine) {
+ Elf elf(memory_);
+
+ InitElf64(EM_PPC64);
+
+ ResetLogs();
+ ASSERT_FALSE(elf.Init());
+
+ ASSERT_EQ("", GetFakeLogBuf());
+ ASSERT_EQ("4 unwind 64 bit elf that is neither aarch64 nor x86_64: e_machine = 21\n\n",
+ GetFakeLogPrint());
+}
+
TEST_F(ElfTest, elf_arm) {
Elf elf(memory_);