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

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: Refactor tests, small fixes, improved EhFrameIterator iface. 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
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..c5c6ded18ae9e497fcf9fc0bf6696cb1e492f4e3
--- /dev/null
+++ b/test/unittests/eh-frame-iterator-unittest.cc
@@ -0,0 +1,55 @@
+// 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 v8 {
+namespace internal {
+
+class EhFrameIteratorTest : public testing::Test {
+ protected:
+ static uint32_t DecodeULEB128(const byte* encoded, int* encoded_size) {
+ return EhFrameIterator::DecodeULEB128(encoded, encoded_size);
+ }
+
+ static int32_t DecodeSLEB128(const byte* encoded, int* encoded_size) {
+ return EhFrameIterator::DecodeSLEB128(encoded, encoded_size);
+ }
+};
+
+} // namespace internal
+} // namespace v8
+
+TEST_F(EhFrameIteratorTest, ULEB128Decoding) {
+ static const byte kEncoded[] = {0xe5, 0x8e, 0x26};
+ int size = 0;
+ uint32_t value = DecodeULEB128(kEncoded, &size);
+ EXPECT_EQ(static_cast<int>(sizeof(kEncoded)), size);
+ EXPECT_EQ(624485, value);
+}
+
+TEST_F(EhFrameIteratorTest, SLEB128DecodingPositive) {
+ static const byte kEncoded[] = {0xe5, 0x8e, 0x26};
+ int size = 0;
+ int32_t value = DecodeSLEB128(kEncoded, &size);
+ EXPECT_EQ(static_cast<int>(sizeof(kEncoded)), size);
+ EXPECT_EQ(624485, value);
+}
+
+TEST_F(EhFrameIteratorTest, SLEB128DecodingNegative) {
+ static const byte kEncoded[] = {0x9b, 0xf1, 0x59};
+ int size = 0;
+ int32_t value = DecodeSLEB128(kEncoded, &size);
+ EXPECT_EQ(static_cast<int>(sizeof(kEncoded)), size);
+ EXPECT_EQ(-624485, value);
+}
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698