Coverage for /Syzygy/block_graph/basic_block_test_util.h

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
0.0%0048.C++source

Line-by-line coverage:

   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    :  #ifndef SYZYGY_BLOCK_GRAPH_BASIC_BLOCK_TEST_UTIL_H_
  16    :  #define SYZYGY_BLOCK_GRAPH_BASIC_BLOCK_TEST_UTIL_H_
  17    :  
  18    :  #include "gtest/gtest.h"
  19    :  #include "syzygy/block_graph/basic_block_decomposer.h"
  20    :  #include "syzygy/block_graph/basic_block_subgraph.h"
  21    :  
  22  m :  extern "C" {
  23    :  
  24    :  // Functions and labels exposed from our .asm test stub.
  25  m :  extern int assembly_func();
  26  m :  extern int unreachable_label();
  27  m :  extern int interrupt_label();
  28  m :  extern int assembly_func_end();
  29    :  
  30  m :  extern int case_0();
  31  m :  extern int case_1();
  32  m :  extern int case_default();
  33  m :  extern int jump_table();
  34  m :  extern int case_table();
  35    :  
  36    :  // Functions invoked or referred by the .asm test stub. These are defined in
  37    :  // basic_block_test_util.cc.
  38  m :  extern int func1();
  39  m :  extern int func2();
  40    :  
  41  m :  }  // extern "C"
  42    :  
  43  m :  namespace testing {
  44    :  
  45    :  // A utility class for generating test data built around the function in
  46    :  // basic_block_assembly_func.asm. When assembly_func_ is decomposed as a basic
  47    :  // block subgraph the layout is as follows:
  48    :  //
  49    :  // BB0: offset 0, code, assembly_func, 4 instructions, 0 successors
  50    :  // BB1: offset 23, code/padding (unreachable code)
  51    :  // BB2: offset 24, code, case_0, 2 instructions, 1 successor
  52    :  // BB3: offset 31, code, sub eax to jnz, 1 instruction, 2 successors
  53    :  // BB4: offset 36, code, ret, 1 instruction, 0 successors
  54    :  // BB5: offset 37, code, case_1, 1 instruction, 1 successor
  55    :  // BB6: offset 42, code, case_default, 2 instructions, 0 successors
  56    :  // BB7: offset 49, code/padding, interrupt_label, 3 instruction, 0 successors
  57    :  // BB8: offset 50, data, jump_table, 12 bytes
  58    :  // BB9: offset 62, data, case_table, 256 bytes
  59  m :  class BasicBlockTest : public ::testing::Test {
  60  m :   public:
  61  m :    typedef core::RelativeAddress RelativeAddress;
  62  m :    typedef block_graph::BlockGraph BlockGraph;
  63  m :    typedef block_graph::BasicBlockDecomposer BasicBlockDecomposer;
  64  m :    typedef block_graph::BasicBlockSubGraph BasicBlockSubGraph;
  65  m :    typedef BasicBlockSubGraph::BasicBlock BasicBlock;
  66  m :    typedef BasicBlockSubGraph::BlockDescription BlockDescription;
  67  m :    typedef BlockGraph::Block Block;
  68  m :    typedef BlockGraph::Reference Reference;
  69  m :    typedef BlockGraph::Section Section;
  70    :  
  71    :    // The number and type of basic blocks.
  72  m :    static const size_t kNumCodeBasicBlocks = 8;
  73  m :    static const size_t kNumDataBasicBlocks = 2;
  74  m :    static const size_t kNumCodePaddingBasicBlocks = 2;
  75  m :    static const size_t kNumDataPaddingBasicBlocks = 0;
  76  m :    static const size_t kNumBasicBlocks =
  77  m :        kNumCodeBasicBlocks + kNumDataBasicBlocks;
  78    :  
  79  m :    BasicBlockTest();
  80    :  
  81    :    // Initializes block_graph, assembly_func, func1, func2 and data. Meant to be
  82    :    // wrapped in ASSERT_NO_FATAL_FAILURE.
  83  m :    void InitBlockGraph();
  84    :  
  85    :    // Initializes subgraph, bbs and bds. Meant to be wrapped in
  86    :    // ASSERT_NO_FATAL_FAILURE.
  87    :    // @pre InitBlockGraph must have been called successfully.
  88  m :    void InitBasicBlockSubGraph();
  89    :  
  90    :    // Initializes block_graph_, text_section_, func1_, and func2_. Leaves
  91    :    // data_section_, assembly_func_ and data_ NULL. func2_ contains a function
  92    :    // with a debug-end label past the end of the block, and internally it calls
  93    :    // func1_.
  94  m :    void InitBasicBlockSubGraphWithLabelPastEnd();
  95    :  
  96    :    // Initialized by InitBlockGraph.
  97    :    // @{
  98    :    // Start address of the assembly function.
  99  m :    RelativeAddress start_addr_;
 100    :  
 101  m :    BlockGraph block_graph_;
 102  m :    Section* text_section_;
 103  m :    Section* data_section_;
 104  m :    Block* assembly_func_;
 105  m :    Block* func1_;
 106  m :    Block* func2_;
 107  m :    Block* data_;
 108    :    // @}
 109    :  
 110    :    // Initialized by InitBasicBlockSubGraph and
 111    :    // InitBasicBlockSubGraphWithLabelPastEnd.
 112    :    // @{
 113  m :    BasicBlockSubGraph subgraph_;
 114  m :    std::vector<BasicBlock*> bbs_;
 115  m :    std::vector<BlockDescription*> bds_;
 116    :    // @}
 117  m :  };
 118    :  
 119  m :  }  // namespace testing
 120    :  
 121    :  #endif  // SYZYGY_BLOCK_GRAPH_BASIC_BLOCK_TEST_UTIL_H_

Coverage information generated Thu Jul 04 09:34:53 2013.