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

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: 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
15
16 class EhFrameIteratorTest : public testing::Test {};
17
18 } // namespace
19
20 TEST_F(EhFrameIteratorTest, Values) {
21 // Assuming little endian.
22 static const byte kEncoded[] = {0xde, 0xc0, 0xad, 0xde, 0xef, 0xbe, 0xff};
23 EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
24 EXPECT_EQ(0xdeadc0de, iterator.GetNextUInt32());
25 EXPECT_EQ(0xbeef, iterator.GetNextUInt16());
26 EXPECT_EQ(0xff, iterator.GetNextByte());
27 EXPECT_TRUE(iterator.Done());
28 }
29
30 TEST_F(EhFrameIteratorTest, Skip) {
31 static const byte kEncoded[] = {0xde, 0xad, 0xc0, 0xde};
32 EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
33 iterator.Skip(2);
34 EXPECT_EQ(2, iterator.GetCurrentOffset());
35 EXPECT_EQ(0xc0, iterator.GetNextByte());
36 iterator.Skip(1);
37 EXPECT_TRUE(iterator.Done());
38 }
39
40 TEST_F(EhFrameIteratorTest, ULEB128Decoding) {
41 static const byte kEncoded[] = {0xe5, 0x8e, 0x26};
42 EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
43 EXPECT_EQ(624485, iterator.GetNextULeb128());
44 EXPECT_TRUE(iterator.Done());
45 }
46
47 TEST_F(EhFrameIteratorTest, SLEB128DecodingPositive) {
48 static const byte kEncoded[] = {0xe5, 0x8e, 0x26};
49 EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
50 EXPECT_EQ(624485, iterator.GetNextSLeb128());
51 EXPECT_TRUE(iterator.Done());
52 }
53
54 TEST_F(EhFrameIteratorTest, SLEB128DecodingNegative) {
55 static const byte kEncoded[] = {0x9b, 0xf1, 0x59};
56 EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
57 EXPECT_EQ(-624485, iterator.GetNextSLeb128());
58 EXPECT_TRUE(iterator.Done());
59 }
60
61 #endif
OLDNEW
« 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