Coverage for /Syzygy/agent/asan/unittest_util.h

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%110.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    :  #ifndef SYZYGY_AGENT_ASAN_UNITTEST_UTIL_H_
  16    :  #define SYZYGY_AGENT_ASAN_UNITTEST_UTIL_H_
  17    :  
  18    :  #include "base/file_util.h"
  19    :  #include "base/string_piece.h"
  20    :  #include "base/files/scoped_temp_dir.h"
  21    :  #include "gtest/gtest.h"
  22    :  #include "syzygy/trace/logger/logger.h"
  23    :  #include "syzygy/trace/logger/logger_rpc_impl.h"
  24    :  
  25    :  namespace testing {
  26    :  
  27    :  // A unittest fixture that ensures that an ASAN logger instance is up and
  28    :  // running for the duration of the test. Output is captured to a file so that
  29    :  // its contents can be read after the test if necessary.
  30    :  class TestWithAsanLogger : public testing::Test {
  31    :   public:
  32    :    TestWithAsanLogger();
  33    :  
  34    :    // @name testing::Test overrides.
  35    :    // @{
  36    :    void SetUp() OVERRIDE;
  37    :    void TearDown() OVERRIDE;
  38    :    // @}
  39    :  
  40    :    // @name Accessors.
  41    :    // @{
  42  E :    const std::wstring& instance_id() const { return instance_id_; }
  43    :    const base::FilePath& log_file_path() const { return log_file_path_; }
  44    :    const base::FilePath& temp_dir() const { return temp_dir_.path(); }
  45    :    // @}
  46    :  
  47    :    bool LogContains(const base::StringPiece& message);
  48    :  
  49    :    // Delete the temporary file used for the logging and its directory.
  50    :    void DeleteTempFileAndDirectory();
  51    :  
  52    :   private:
  53    :    // The log service instance.
  54    :    trace::logger::Logger log_service_;
  55    :  
  56    :    // Manages the binding between the RPC stub functions and a log service
  57    :    // instance.
  58    :    trace::logger::RpcLoggerInstanceManager log_service_instance_;
  59    :  
  60    :    // The instance ID used by the running logger instance.
  61    :    std::wstring instance_id_;
  62    :  
  63    :    // The path to the log file where the the logger instance will write.
  64    :    base::FilePath log_file_path_;
  65    :  
  66    :    // The open file handle, if any to which the logger instance will write.
  67    :    file_util::ScopedFILE log_file_;
  68    :  
  69    :    // A temporary directory into which the log file will be written.
  70    :    base::ScopedTempDir temp_dir_;
  71    :  
  72    :    // The contents of the log. These are read by calling LogContains.
  73    :    bool log_contents_read_;
  74    :    std::string log_contents_;
  75    :  };
  76    :  
  77    :  }  // namespace testing
  78    :  
  79    :  #endif  // SYZYGY_AGENT_ASAN_UNITTEST_UTIL_H_

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