1 : // Copyright 2011 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 :
15 : #ifndef SYZYGY_REORDER_ORDER_GENERATOR_TEST_H_
16 : #define SYZYGY_REORDER_ORDER_GENERATOR_TEST_H_
17 :
18 : #include "gtest/gtest.h"
19 : #include "syzygy/pe/unittest_util.h"
20 : #include "syzygy/reorder/reorderer.h"
21 :
22 m : namespace testing {
23 :
24 m : class OrderGeneratorTest : public PELibUnitTest {
25 m : protected:
26 m : typedef reorder::Reorderer::Order Order;
27 m : typedef Order::BlockSpec BlockSpec;
28 m : typedef Order::BlockSpecVector BlockSpecVector;
29 m : typedef Order::SectionSpec SectionSpec;
30 m : typedef Order::SectionSpecVector SectionSpecVector;
31 :
32 m : OrderGeneratorTest();
33 :
34 m : void SetUp();
35 :
36 m : reorder::Reorderer::UniqueTime GetSystemTime();
37 :
38 m : void ExpectMatchingMetadata(const IMAGE_SECTION_HEADER* section,
39 m : const SectionSpec& section_specs);
40 :
41 m : void ExpectNoDuplicateBlocks();
42 :
43 m : void ExpectSameOrder(const IMAGE_SECTION_HEADER* section,
44 m : const BlockSpecVector& block_specs);
45 :
46 m : void ExpectDifferentOrder(const IMAGE_SECTION_HEADER* section,
47 m : const BlockSpecVector& block_specs);
48 :
49 m : void GetBlockListForSection(const IMAGE_SECTION_HEADER* section,
50 m : BlockSpecVector* block_specs);
51 :
52 m : pe::PEFile input_dll_;
53 m : block_graph::BlockGraph block_graph_;
54 m : pe::ImageLayout image_layout_;
55 m : Order order_;
56 m : };
57 :
58 : // Comparison functions for Orders and their parts.
59 m : bool BlockSpecsAreEqual(const reorder::Reorderer::Order::BlockSpec& lhs,
60 m : const reorder::Reorderer::Order::BlockSpec& rhs);
61 m : bool SectionSpecsAreEqual(const reorder::Reorderer::Order::SectionSpec& lhs,
62 m : const reorder::Reorderer::Order::SectionSpec& rhs);
63 m : bool OrdersAreEqual(const reorder::Reorderer::Order& lhs,
64 m : const reorder::Reorderer::Order& rhs);
65 :
66 m : } // namespace testing
67 :
68 : #endif // SYZYGY_REORDER_ORDER_GENERATOR_TEST_H_
|