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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/eh-frame.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 // Test enabled only on supported architectures.
9 #if defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_ARM) || \
10 defined(V8_TARGET_ARCH_ARM64)
11
12 using namespace v8::internal;
13
14 namespace v8 {
15 namespace internal {
16
17 class EhFrameIteratorTest : public testing::Test {
18 protected:
19 static uint32_t DecodeULEB128(const byte* encoded, int* encoded_size) {
20 return EhFrameIterator::DecodeULEB128(encoded, encoded_size);
21 }
22
23 static int32_t DecodeSLEB128(const byte* encoded, int* encoded_size) {
24 return EhFrameIterator::DecodeSLEB128(encoded, encoded_size);
25 }
26 };
27
28 } // namespace internal
29 } // namespace v8
30
31 TEST_F(EhFrameIteratorTest, ULEB128Decoding) {
32 static const byte kEncoded[] = {0xe5, 0x8e, 0x26};
33 int size = 0;
34 uint32_t value = DecodeULEB128(kEncoded, &size);
35 EXPECT_EQ(static_cast<int>(sizeof(kEncoded)), size);
36 EXPECT_EQ(624485, value);
37 }
38
39 TEST_F(EhFrameIteratorTest, SLEB128DecodingPositive) {
40 static const byte kEncoded[] = {0xe5, 0x8e, 0x26};
41 int size = 0;
42 int32_t value = DecodeSLEB128(kEncoded, &size);
43 EXPECT_EQ(static_cast<int>(sizeof(kEncoded)), size);
44 EXPECT_EQ(624485, value);
45 }
46
47 TEST_F(EhFrameIteratorTest, SLEB128DecodingNegative) {
48 static const byte kEncoded[] = {0x9b, 0xf1, 0x59};
49 int size = 0;
50 int32_t value = DecodeSLEB128(kEncoded, &size);
51 EXPECT_EQ(static_cast<int>(sizeof(kEncoded)), size);
52 EXPECT_EQ(-624485, value);
53 }
54
55 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698