Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1151)

Unified Diff: test/unittests/eh-frame-iterator-unittest.cc

Issue 2023503002: Reland Implement .eh_frame writer and disassembler. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@eh-frame-base
Patch Set: Rebase on master. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-eh-frame-hdr.cc ('k') | test/unittests/eh-frame-writer-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/eh-frame-iterator-unittest.cc
diff --git a/test/unittests/eh-frame-iterator-unittest.cc b/test/unittests/eh-frame-iterator-unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..27485db67eb8d6d3263e02d4a9d59a302876bdfc
--- /dev/null
+++ b/test/unittests/eh-frame-iterator-unittest.cc
@@ -0,0 +1,61 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/eh-frame.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+// Test enabled only on supported architectures.
+#if defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_ARM) || \
+ defined(V8_TARGET_ARCH_ARM64)
+
+using namespace v8::internal;
+
+namespace {
+
+class EhFrameIteratorTest : public testing::Test {};
+
+} // namespace
+
+TEST_F(EhFrameIteratorTest, Values) {
+ // Assuming little endian.
+ static const byte kEncoded[] = {0xde, 0xc0, 0xad, 0xde, 0xef, 0xbe, 0xff};
+ EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
+ EXPECT_EQ(0xdeadc0de, iterator.GetNextUInt32());
+ EXPECT_EQ(0xbeef, iterator.GetNextUInt16());
+ EXPECT_EQ(0xff, iterator.GetNextByte());
+ EXPECT_TRUE(iterator.Done());
+}
+
+TEST_F(EhFrameIteratorTest, Skip) {
+ static const byte kEncoded[] = {0xde, 0xad, 0xc0, 0xde};
+ EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
+ iterator.Skip(2);
+ EXPECT_EQ(2, iterator.GetCurrentOffset());
+ EXPECT_EQ(0xc0, iterator.GetNextByte());
+ iterator.Skip(1);
+ EXPECT_TRUE(iterator.Done());
+}
+
+TEST_F(EhFrameIteratorTest, ULEB128Decoding) {
+ static const byte kEncoded[] = {0xe5, 0x8e, 0x26};
+ EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
+ EXPECT_EQ(624485, iterator.GetNextULeb128());
+ EXPECT_TRUE(iterator.Done());
+}
+
+TEST_F(EhFrameIteratorTest, SLEB128DecodingPositive) {
+ static const byte kEncoded[] = {0xe5, 0x8e, 0x26};
+ EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
+ EXPECT_EQ(624485, iterator.GetNextSLeb128());
+ EXPECT_TRUE(iterator.Done());
+}
+
+TEST_F(EhFrameIteratorTest, SLEB128DecodingNegative) {
+ static const byte kEncoded[] = {0x9b, 0xf1, 0x59};
+ EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
+ EXPECT_EQ(-624485, iterator.GetNextSLeb128());
+ EXPECT_TRUE(iterator.Done());
+}
+
+#endif
« no previous file with comments | « test/cctest/test-eh-frame-hdr.cc ('k') | test/unittests/eh-frame-writer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698