Coverage for /Syzygy/block_graph/transforms/fuzzing_transform_unittest.cc

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%15150.C++test

Line-by-line coverage:

   1    :  // Copyright 2013 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    :  // Unittests for FuzzingTransform.
  16    :  
  17    :  #include "syzygy/block_graph/transforms/fuzzing_transform.h"
  18    :  
  19    :  #include "gtest/gtest.h"
  20    :  #include "syzygy/block_graph/basic_block.h"
  21    :  #include "syzygy/block_graph/basic_block_assembler.h"
  22    :  #include "syzygy/block_graph/basic_block_decomposer.h"
  23    :  #include "syzygy/block_graph/basic_block_subgraph.h"
  24    :  #include "syzygy/block_graph/block_graph.h"
  25    :  #include "syzygy/block_graph/transform.h"
  26    :  
  27    :  #include "mnemonics.h"  // NOLINT
  28    :  
  29    :  namespace block_graph {
  30    :  namespace transforms {
  31    :  namespace {
  32    :  
  33    :  using block_graph::BasicBlock;
  34    :  using block_graph::BasicBlockAssembler;
  35    :  using block_graph::BasicCodeBlock;
  36    :  using block_graph::BasicBlockDecomposer;
  37    :  using block_graph::Instruction;
  38    :  using block_graph::Immediate;
  39    :  
  40    :  class TestLivenessFuzzingBasicBlockTransform :
  41    :      public LivenessFuzzingBasicBlockTransform {
  42    :   public:
  43    :    using LivenessFuzzingBasicBlockTransform::TransformBasicBlockSubGraph;
  44    :  };
  45    :  
  46    :  }  // namespace
  47    :  
  48  E :  TEST(LivenessFuzzingBasicBlockTransformTest, SingleBasicBlock) {
  49  E :    BlockGraph block;
  50  E :    BasicBlockSubGraph subgraph;
  51  E :    BasicCodeBlock* bb = subgraph.AddBasicCodeBlock("bb");
  52  E :    ASSERT_TRUE(bb != NULL);
  53    :  
  54    :    // Insert instructions into basic block.
  55  E :    BasicBlockAssembler assembly(bb->instructions().end(), &bb->instructions());
  56  E :    assembly.cmp(core::eax, Immediate(42, core::kSize32Bit));
  57  E :    assembly.mov(core::eax, Immediate(0, core::kSize32Bit));
  58    :  
  59    :    // Transforms the basic block.
  60  E :    TestLivenessFuzzingBasicBlockTransform tx;
  61  E :    size_t previous_size = bb->instructions().size();
  62  E :    ASSERT_TRUE(tx.TransformBasicBlockSubGraph(&block, &subgraph));
  63    :  
  64    :    // Expecting two new instructions.
  65  E :    size_t expected_size = previous_size + 2;
  66  E :    size_t current_size = bb->instructions().size();
  67  E :    EXPECT_EQ(expected_size, current_size);
  68  E :  }
  69    :  
  70    :  }  // namespace transforms
  71    :  }  // namespace block_graph

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