Chromium Code Reviews| Index: test/unittests/eh-frame-hdr-unittest.cc |
| diff --git a/test/unittests/eh-frame-hdr-unittest.cc b/test/unittests/eh-frame-hdr-unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..29698f5d728a6d84e2c44ce010f16d43af6f8187 |
| --- /dev/null |
| +++ b/test/unittests/eh-frame-hdr-unittest.cc |
| @@ -0,0 +1,70 @@ |
| +// 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" |
| + |
| +namespace { |
| + |
| +class EhFrameHdrLayout : public testing::Test { |
|
rmcilroy
2016/07/05 10:56:13
I don't think you need this fixture - just create
Stefano Sanfilippo
2016/07/05 16:02:14
Done.
|
| + public: |
| + EhFrameHdrLayout() |
| + : eh_frame_hdr_(10, 30, 10), |
| + dummy_eh_frame_hdr_(v8::internal::EhFrameHdr::CreateEmptyHeader()) {} |
| + |
| + protected: |
| + v8::internal::EhFrameHdr eh_frame_hdr_; |
| + v8::internal::EhFrameHdr dummy_eh_frame_hdr_; |
| +}; |
| + |
| +} // namespace |
| + |
| +TEST_F(EhFrameHdrLayout, Real) { |
| + // |
| + // Plugging some numbers in the DSO layout shown in eh-frame.cc: |
| + // |
| + // | ... | |
| + // +---------------+ <-- (E) -------- |
| + // | | ^ |
| + // | Instructions | 10 bytes | .text |
| + // | | v |
| + // +---------------+ <--------------- |
| + // |///////////////| |
| + // |////Padding////| 6 bytes |
| + // |///////////////| |
| + // +---------------+ <---(D)--------- |
| + // | | ^ |
| + // | CIE | N bytes* | |
| + // | | | |
| + // +---------------+ <-- (C) | .eh_frame |
| + // | | | |
| + // | FDE | 30 - N bytes | |
| + // | | v |
| + // +---------------+ <-- (B) -------- |
| + // | version | ^ |
| + // +---------------+ 4 bytes | |
| + // | encoding | | |
| + // | specifiers | | |
| + // +---------------+ <---(A) | .eh_frame_hdr |
| + // | offset to | | |
| + // | .eh_frame | | |
| + // +---------------+ | |
| + // | ... | ... |
| + // |
| + // (*) the size of the CIE is platform dependent, 10 for this test. |
| + // |
| + EXPECT_EQ(1, eh_frame_hdr_.lut_entries_number()); |
| + EXPECT_EQ(-(4 + 30), eh_frame_hdr_.offset_to_eh_frame()); // A -> D |
| + EXPECT_EQ(-(30 + 6 + 10), eh_frame_hdr_.offset_to_procedure()); // B -> E |
| + EXPECT_EQ(-(30 - 10), eh_frame_hdr_.offset_to_fde()); // B -> C |
| +} |
| + |
| +TEST_F(EhFrameHdrLayout, Empty) { |
| + // An emtpy header has an empty LUT |
| + EXPECT_EQ(0, dummy_eh_frame_hdr_.lut_entries_number()); |
| + // These values should be irrelevant, but check that they have been zeroed. |
| + EXPECT_EQ(0, dummy_eh_frame_hdr_.offset_to_eh_frame()); |
| + EXPECT_EQ(0, dummy_eh_frame_hdr_.offset_to_procedure()); |
| + EXPECT_EQ(0, dummy_eh_frame_hdr_.offset_to_fde()); |
| +} |