1 : // Copyright 2012 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 : // A common test fixture which knows how to decompose the test dll.
16 :
17 : #ifndef SYZYGY_INSTRUMENT_TRANSFORMS_UNITTEST_UTIL_H_
18 : #define SYZYGY_INSTRUMENT_TRANSFORMS_UNITTEST_UTIL_H_
19 :
20 : #include "syzygy/block_graph/block_graph.h"
21 : #include "syzygy/core/unittest_util.h"
22 : #include "syzygy/pe/coff_transform_policy.h"
23 : #include "syzygy/pe/pe_file.h"
24 : #include "syzygy/pe/pe_transform_policy.h"
25 : #include "syzygy/pe/unittest_util.h"
26 :
27 m : namespace testing {
28 :
29 : // A common test fixture which knows how to decompose the "standard" test dll.
30 m : class TestDllTransformTest : public testing::PELibUnitTest {
31 m : public:
32 m : TestDllTransformTest();
33 :
34 : // Decomposes the test_dll.dll into block_graph_, sets header_block_ and
35 : // policy_. Typically, you would call inside an ASSERT_NO_FATAL_FAILURE
36 : // clause.
37 m : void DecomposeTestDll();
38 :
39 : // Decomposes the test_dll,obj into block_graph_, sets header_block_ and
40 : // policy_. Typically, you would call inside an ASSERT_NO_FATAL_FAILURE
41 : // clause.
42 m : void DecomposeTestDllObj();
43 :
44 : // The policy objects restricting how the transform is applied.
45 m : pe::PETransformPolicy pe_policy_;
46 m : pe::CoffTransformPolicy coff_policy_;
47 m : block_graph::TransformPolicyInterface *policy_;
48 :
49 : // The PEFile instance referring to test_dll.
50 m : pe::PEFile pe_file_;
51 :
52 : // The CoffFile instance referring to test_dll.obj.
53 m : pe::CoffFile coff_file_;
54 :
55 : // The block graph for test_dll.dll or test_dll.obj.
56 m : block_graph::BlockGraph block_graph_;
57 :
58 : // The header block for test_dll.dll or test_dll.obj.
59 m : block_graph::BlockGraph::Block* header_block_;
60 m : };
61 :
62 m : } // namespace testing
63 :
64 : #endif // SYZYGY_INSTRUMENT_TRANSFORMS_UNITTEST_UTIL_H_
|