LCOV - code coverage report
Current view: top level - test/unittests - eh-frame-iterator-unittest.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 23 23 100.0 %
Date: 2019-04-17 Functions: 12 17 70.6 %

          Line data    Source code
       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             : namespace v8 {
       9             : namespace internal {
      10             : 
      11             : // Test enabled only on supported architectures.
      12             : #if defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_ARM) || \
      13             :     defined(V8_TARGET_ARCH_ARM64)
      14             : 
      15             : namespace {
      16             : 
      17          10 : class EhFrameIteratorTest : public testing::Test {};
      18             : 
      19             : }  // namespace
      20             : 
      21       15444 : TEST_F(EhFrameIteratorTest, Values) {
      22             :   // Assuming little endian.
      23             :   static const byte kEncoded[] = {0xDE, 0xC0, 0xAD, 0xDE, 0xEF, 0xBE, 0xFF};
      24             :   EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
      25           2 :   EXPECT_EQ(0xDEADC0DE, iterator.GetNextUInt32());
      26           2 :   EXPECT_EQ(0xBEEF, iterator.GetNextUInt16());
      27           2 :   EXPECT_EQ(0xFF, iterator.GetNextByte());
      28             :   EXPECT_TRUE(iterator.Done());
      29           1 : }
      30             : 
      31       15444 : TEST_F(EhFrameIteratorTest, Skip) {
      32             :   static const byte kEncoded[] = {0xDE, 0xAD, 0xC0, 0xDE};
      33             :   EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
      34             :   iterator.Skip(2);
      35           2 :   EXPECT_EQ(2, iterator.GetCurrentOffset());
      36           2 :   EXPECT_EQ(0xC0, iterator.GetNextByte());
      37             :   iterator.Skip(1);
      38             :   EXPECT_TRUE(iterator.Done());
      39           1 : }
      40             : 
      41       15444 : TEST_F(EhFrameIteratorTest, ULEB128Decoding) {
      42             :   static const byte kEncoded[] = {0xE5, 0x8E, 0x26};
      43             :   EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
      44           2 :   EXPECT_EQ(624485u, iterator.GetNextULeb128());
      45           1 :   EXPECT_TRUE(iterator.Done());
      46           1 : }
      47             : 
      48       15444 : TEST_F(EhFrameIteratorTest, SLEB128DecodingPositive) {
      49             :   static const byte kEncoded[] = {0xE5, 0x8E, 0x26};
      50             :   EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
      51           2 :   EXPECT_EQ(624485, iterator.GetNextSLeb128());
      52           1 :   EXPECT_TRUE(iterator.Done());
      53           1 : }
      54             : 
      55       15444 : TEST_F(EhFrameIteratorTest, SLEB128DecodingNegative) {
      56             :   static const byte kEncoded[] = {0x9B, 0xF1, 0x59};
      57             :   EhFrameIterator iterator(&kEncoded[0], &kEncoded[0] + sizeof(kEncoded));
      58           2 :   EXPECT_EQ(-624485, iterator.GetNextSLeb128());
      59           1 :   EXPECT_TRUE(iterator.Done());
      60           1 : }
      61             : 
      62             : #endif
      63             : 
      64             : }  // namespace internal
      65        9264 : }  // namespace v8

Generated by: LCOV version 1.10