Coverage for /Syzygy/refinery/analyzers/analyzer_factory_unittest.cc

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
0.0%0076.C++test

Line-by-line coverage:

   1    :  // Copyright 2015 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    :  #include "syzygy/refinery/analyzers/analyzer_factory.h"
  16    :  
  17    :  #include <string>
  18    :  
  19    :  #include "gtest/gtest.h"
  20    :  #include "syzygy/refinery/process_state/process_state.h"
  21    :  
  22  m :  namespace refinery {
  23    :  
  24  m :  namespace {
  25    :  
  26  m :  static const char kInvalidAnalyzerName[] = "FooBarAnalyzer";
  27    :  
  28  m :  static ProcessState::LayerEnum kAllLayers[] = {
  29    :  #define LAYER_CONSTANT_ENUM(name) ProcessState::name##Layer,
  30    :  
  31  m :      PROCESS_STATE_LAYERS(LAYER_CONSTANT_ENUM)
  32    :  
  33    :  #undef LAYER_CONSTANT_ENUM
  34  m :  };
  35    :  
  36  m :  class StaticAnalyzerFactoryTest : public testing::Test {
  37  m :   public:
  38  m :    void SetUp() override {
  39  m :      list_.GetAnalyzerNames(&analyzer_names_);
  40  m :      EXPECT_NE(0u, analyzer_names_.size());
  41  m :    }
  42    :  
  43  m :    const AnalyzerFactory::AnalyzerNames& analyzer_names() const {
  44  m :      return analyzer_names_;
  45  m :    }
  46  m :    const StaticAnalyzerFactory& list() const { return list_; }
  47    :  
  48  m :   private:
  49  m :    AnalyzerFactory::AnalyzerNames analyzer_names_;
  50  m :    StaticAnalyzerFactory list_;
  51  m :  };
  52    :  
  53  m :  }  // namespace
  54    :  
  55  m :  TEST_F(StaticAnalyzerFactoryTest,
  56  m :         CreateAnalyzersSucceedsForValidAnalyzerNames) {
  57  m :    for (const auto& name : analyzer_names()) {
  58  m :      std::unique_ptr<Analyzer> analyzer(list().CreateAnalyzer(name));
  59    :  
  60  m :      ASSERT_TRUE(analyzer.get());
  61  m :      ASSERT_EQ(name, analyzer->name());
  62  m :    }
  63  m :  }
  64    :  
  65  m :  TEST_F(StaticAnalyzerFactoryTest, CreateAnalyzerFailsForInvalidAnalyzerName) {
  66  m :    std::unique_ptr<Analyzer> analyzer(
  67  m :        list().CreateAnalyzer(kInvalidAnalyzerName));
  68  m :    ASSERT_FALSE(analyzer.get());
  69  m :  }
  70    :  
  71  m :  TEST_F(StaticAnalyzerFactoryTest, GetInputLayersSucceedsForValidAnalyzerNames) {
  72  m :    for (const auto& name : analyzer_names()) {
  73  m :      AnalyzerFactory::Layers layers;
  74  m :      ASSERT_TRUE(list().GetInputLayers(name, &layers));
  75  m :    }
  76  m :  }
  77    :  
  78  m :  TEST_F(StaticAnalyzerFactoryTest, GetInputLayersFailsForInvalidAnalyzerName) {
  79  m :    AnalyzerFactory::Layers layers;
  80  m :    ASSERT_FALSE(list().GetInputLayers(kInvalidAnalyzerName, &layers));
  81  m :  }
  82    :  
  83  m :  TEST_F(StaticAnalyzerFactoryTest,
  84  m :         GetOutputLayersSucceedsForValidAnalyzerNames) {
  85  m :    for (const auto& name : analyzer_names()) {
  86  m :      AnalyzerFactory::Layers layers;
  87  m :      ASSERT_TRUE(list().GetOutputLayers(name, &layers));
  88  m :    }
  89  m :  }
  90    :  
  91  m :  TEST_F(StaticAnalyzerFactoryTest,
  92  m :         GetGetAnalyzersInputtingHasAnalyzersForLayers) {
  93  m :    for (ProcessState::LayerEnum layer : kAllLayers) {
  94  m :      AnalyzerFactory::AnalyzerNames analyzer_names;
  95  m :      list().GetAnalyzersInputting(layer, &analyzer_names);
  96    :  
  97  m :      if (layer == ProcessState::HeapAllocationLayer ||
  98  m :          layer == ProcessState::HeapMetadataLayer) {
  99  m :        EXPECT_EQ(0u, analyzer_names.size()) << "Some analyzers input "
 100  m :                                             << ProcessState::LayerName(layer);
 101  m :      } else {
 102  m :        EXPECT_NE(0u, analyzer_names.size()) << "No analyzers input "
 103  m :                                             << ProcessState::LayerName(layer);
 104  m :      }
 105  m :    }
 106  m :  }
 107    :  
 108  m :  TEST_F(StaticAnalyzerFactoryTest,
 109  m :         GetGetAnalyzersOutputtingHasAnalyzersForLayers) {
 110  m :    for (ProcessState::LayerEnum layer : kAllLayers) {
 111  m :      AnalyzerFactory::AnalyzerNames analyzer_names;
 112  m :      list().GetAnalyzersOutputting(layer, &analyzer_names);
 113  m :      EXPECT_NE(0u, analyzer_names.size()) << "No analyzers output "
 114  m :                                           << ProcessState::LayerName(layer);
 115  m :    }
 116  m :  }
 117    :  
 118  m :  }  // namespace refinery

Coverage information generated Fri Jul 29 11:00:21 2016.