Coverage for /Syzygy/integration_tests/instrument_integration_test.cc

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
99.4%4614640.C++source

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    :  #include "base/environment.h"
  16    :  #include "base/string_util.h"
  17    :  #include "base/stringprintf.h"
  18    :  #include "base/files/file_path.h"
  19    :  #include "gtest/gtest.h"
  20    :  #include "syzygy/agent/asan/asan_rtl_impl.h"
  21    :  #include "syzygy/agent/asan/asan_runtime.h"
  22    :  #include "syzygy/common/indexed_frequency_data.h"
  23    :  #include "syzygy/common/unittest_util.h"
  24    :  #include "syzygy/core/unittest_util.h"
  25    :  #include "syzygy/grinder/basic_block_util.h"
  26    :  #include "syzygy/grinder/grinder.h"
  27    :  #include "syzygy/grinder/grinders/coverage_grinder.h"
  28    :  #include "syzygy/grinder/grinders/indexed_frequency_data_grinder.h"
  29    :  #include "syzygy/grinder/grinders/profile_grinder.h"
  30    :  #include "syzygy/instrument/instrument_app.h"
  31    :  #include "syzygy/integration_tests/integration_tests_dll.h"
  32    :  #include "syzygy/pe/decomposer.h"
  33    :  #include "syzygy/pe/unittest_util.h"
  34    :  #include "syzygy/trace/common/unittest_util.h"
  35    :  
  36    :  namespace integration_tests {
  37    :  
  38    :  namespace {
  39    :  
  40    :  using grinder::basic_block_util::IndexedFrequencyInformation;
  41    :  using grinder::basic_block_util::IndexedFrequencyMap;
  42    :  using grinder::basic_block_util::ModuleIndexedFrequencyMap;
  43    :  using instrument::InstrumentApp;
  44    :  using trace::parser::Parser;
  45    :  typedef block_graph::BlockGraph::Block Block;
  46    :  typedef block_graph::BlockGraph::BlockMap BlockMap;
  47    :  typedef common::Application<InstrumentApp> TestApp;
  48    :  typedef grinder::CoverageData::LineExecutionCountMap LineExecutionCountMap;
  49    :  typedef grinder::CoverageData::SourceFileCoverageData SourceFileCoverageData;
  50    :  typedef grinder::CoverageData::SourceFileCoverageDataMap
  51    :      SourceFileCoverageDataMap;
  52    :  
  53    :  enum AccessMode {
  54    :    ASAN_READ_ACCESS = agent::asan::HeapProxy::ASAN_READ_ACCESS,
  55    :    ASAN_WRITE_ACCESS = agent::asan::HeapProxy::ASAN_WRITE_ACCESS,
  56    :    ASAN_UNKNOWN_ACCESS = agent::asan::HeapProxy::ASAN_UNKNOWN_ACCESS,
  57    :  };
  58    :  
  59    :  enum BadAccessKind {
  60    :    UNKNOWN_BAD_ACCESS = agent::asan::HeapProxy::UNKNOWN_BAD_ACCESS,
  61    :    USE_AFTER_FREE = agent::asan::HeapProxy::USE_AFTER_FREE,
  62    :    HEAP_BUFFER_OVERFLOW = agent::asan::HeapProxy::HEAP_BUFFER_OVERFLOW,
  63    :    HEAP_BUFFER_UNDERFLOW = agent::asan::HeapProxy::HEAP_BUFFER_UNDERFLOW,
  64    :  };
  65    :  
  66    :  // Contains the number of ASAN errors reported with our callback.
  67    :  int asan_error_count;
  68    :  // Contains the last ASAN error reported.
  69    :  agent::asan::AsanErrorInfo last_asan_error;
  70    :  
  71  E :  void AsanSafeCallback(agent::asan::AsanErrorInfo* info) {
  72  E :    asan_error_count++;
  73  E :    last_asan_error = *info;
  74  E :  }
  75    :  
  76  E :  void ResetAsanErrors() {
  77  E :    asan_error_count = 0;
  78  E :  }
  79    :  
  80  E :  void SetAsanCallBack() {
  81    :    typedef void (WINAPI *AsanSetCallBack)(AsanErrorCallBack);
  82    :  
  83  E :    HMODULE asan_module = GetModuleHandle(L"syzyasan_rtl.dll");
  84  E :    DCHECK(asan_module != NULL);
  85    :    AsanSetCallBack set_callback = reinterpret_cast<AsanSetCallBack>(
  86  E :        ::GetProcAddress(asan_module, "asan_SetCallBack"));
  87  E :    DCHECK(set_callback != NULL);
  88    :  
  89  E :    set_callback(AsanSafeCallback);
  90  E :  };
  91    :  
  92    :  class TestingProfileGrinder : public grinder::grinders::ProfileGrinder {
  93    :   public:
  94    :    // Expose for testing.
  95    :    typedef grinder::grinders::ProfileGrinder::InvocationNodeMap
  96    :        InvocationNodeMap;
  97    :    typedef grinder::grinders::ProfileGrinder::ModuleInformationSet
  98    :        ModuleInformationSet;
  99    :  
 100    :    using grinder::grinders::ProfileGrinder::PartData;
 101    :    using grinder::grinders::ProfileGrinder::PartDataMap;
 102    :    using grinder::grinders::ProfileGrinder::PartKey;
 103    :  
 104    :    using grinder::grinders::ProfileGrinder::modules_;
 105    :    using grinder::grinders::ProfileGrinder::parts_;
 106    :  };
 107    :  
 108    :  class InstrumentAppIntegrationTest : public testing::PELibUnitTest {
 109    :   public:
 110    :    typedef testing::PELibUnitTest Super;
 111    :  
 112    :    InstrumentAppIntegrationTest()
 113    :        : cmd_line_(base::FilePath(L"instrument.exe")),
 114    :          test_impl_(test_app_.implementation()),
 115    :          image_layout_(&block_graph_),
 116  E :          get_my_rva_(NULL) {
 117  E :    }
 118    :  
 119  E :    void SetUp() {
 120  E :      Super::SetUp();
 121    :  
 122    :      // Several of the tests generate progress and (deliberate) error messages
 123    :      // that would otherwise clutter the unittest output.
 124  E :      logging::SetMinLogLevel(logging::LOG_FATAL);
 125    :  
 126    :      // Setup the IO streams.
 127  E :      CreateTemporaryDir(&temp_dir_);
 128  E :      stdin_path_ = temp_dir_.Append(L"NUL");
 129  E :      stdout_path_ = temp_dir_.Append(L"stdout.txt");
 130  E :      stderr_path_ = temp_dir_.Append(L"stderr.txt");
 131  E :      InitStreams(stdin_path_, stdout_path_, stderr_path_);
 132    :  
 133    :      // Initialize the (potential) input and output path values.
 134    :      base::FilePath abs_input_dll_path_ =
 135  E :          testing::GetExeRelativePath(L"integration_tests_dll.dll");
 136  E :      input_dll_path_ = testing::GetRelativePath(abs_input_dll_path_);
 137  E :      output_dll_path_ = temp_dir_.Append(input_dll_path_.BaseName());
 138    :  
 139    :      // Initialize call_service output directory for produced trace files.
 140  E :      traces_dir_ = temp_dir_.Append(L"traces");
 141    :  
 142    :      // Initialize call_service session id.
 143  E :      service_.SetEnvironment();
 144    :  
 145  E :      ASSERT_NO_FATAL_FAILURE(ConfigureTestApp(&test_app_));
 146  E :    }
 147    :  
 148  E :    void TearDown() {
 149    :      // We need to release the module handle before Super::TearDown, otherwise
 150    :      // the library file cannot be deleted.
 151  E :      module_.Release();
 152    :  
 153  E :      Super::TearDown();
 154  E :    }
 155    :  
 156    :    // Points the application at the fixture's command-line and IO streams.
 157    :    template<typename TestAppType>
 158  E :    void ConfigureTestApp(TestAppType* test_app) {
 159  E :      test_app->set_command_line(&cmd_line_);
 160  E :      test_app->set_in(in());
 161  E :      test_app->set_out(out());
 162  E :      test_app->set_err(err());
 163  E :    }
 164    :  
 165  E :    void StartService() {
 166  E :      service_.Start(traces_dir_);
 167  E :    }
 168    :  
 169  E :    void StopService() {
 170  E :      service_.Stop();
 171  E :    }
 172    :  
 173  E :    void UnloadDll() {
 174  E :      module_.Reset(NULL);
 175  E :    }
 176    :  
 177    :    // Runs an instrumentation pass in the given mode and validates that the
 178    :    // resulting output DLL loads.
 179  E :    void EndToEndTest(const std::string& mode) {
 180  E :      cmd_line_.AppendSwitchPath("input-image", input_dll_path_);
 181  E :      cmd_line_.AppendSwitchPath("output-image", output_dll_path_);
 182  E :      cmd_line_.AppendSwitchASCII("mode", mode);
 183    :  
 184    :      // Create the instrumented DLL.
 185  E :      common::Application<instrument::InstrumentApp> app;
 186  E :      ASSERT_NO_FATAL_FAILURE(ConfigureTestApp(&app));
 187  E :      ASSERT_EQ(0, app.Run());
 188    :  
 189    :      // Validate that the test dll loads post instrumentation.
 190  E :      ASSERT_NO_FATAL_FAILURE(LoadTestDll(output_dll_path_, &module_));
 191  E :    }
 192    :  
 193    :    // Invoke a test function inside test_dll by addressing it with a test id.
 194    :    // Returns the value resulting of test function execution.
 195  E :    unsigned int InvokeTestDllFunction(testing::EndToEndTestId test) {
 196    :      // Load the exported 'function_name' function.
 197    :      typedef unsigned int (CALLBACK* TestDllFuncs)(unsigned int);
 198    :      TestDllFuncs func = reinterpret_cast<TestDllFuncs>(
 199  E :          ::GetProcAddress(module_, "EndToEndTest"));
 200  E :      DCHECK(func != NULL);
 201    :  
 202    :      // Invoke it, and returns its value.
 203  E :      return func(test);
 204  E :    }
 205    :  
 206  E :    void EndToEndCheckTestDll() {
 207    :      // Validate that behavior is unchanged after instrumentation.
 208  E :      EXPECT_EQ(0xfff80200,
 209    :                InvokeTestDllFunction(testing::kArrayComputation1TestId));
 210  E :      EXPECT_EQ(0x00000200,
 211    :                InvokeTestDllFunction(testing::kArrayComputation2TestId));
 212  E :    }
 213    :  
 214    :    void AsanErrorCheck(testing::EndToEndTestId test, BadAccessKind kind,
 215  E :        AccessMode mode, size_t size) {
 216    :  
 217  E :      ResetAsanErrors();
 218  E :      InvokeTestDllFunction(test);
 219  E :      EXPECT_LT(0, asan_error_count);
 220  E :      EXPECT_EQ(kind, last_asan_error.error_type);
 221  E :      EXPECT_EQ(mode, last_asan_error.access_mode);
 222  E :      EXPECT_EQ(size, last_asan_error.access_size);
 223  E :    }
 224    :  
 225  E :    void AsanErrorCheckTestDll() {
 226  E :      ASSERT_NO_FATAL_FAILURE(SetAsanCallBack());
 227    :  
 228    :      AsanErrorCheck(testing::kAsanRead8BufferOverflowTestId,
 229  E :          HEAP_BUFFER_OVERFLOW, ASAN_READ_ACCESS, 1);
 230    :      AsanErrorCheck(testing::kAsanRead16BufferOverflowTestId,
 231  E :          HEAP_BUFFER_OVERFLOW, ASAN_READ_ACCESS, 2);
 232    :      AsanErrorCheck(testing::kAsanRead32BufferOverflowTestId,
 233  E :          HEAP_BUFFER_OVERFLOW, ASAN_READ_ACCESS, 4);
 234    :      AsanErrorCheck(testing::kAsanRead64BufferOverflowTestId,
 235  E :          HEAP_BUFFER_OVERFLOW, ASAN_READ_ACCESS, 8);
 236    :  
 237    :      AsanErrorCheck(testing::kAsanRead8BufferUnderflowTestId,
 238  E :          HEAP_BUFFER_UNDERFLOW, ASAN_READ_ACCESS, 1);
 239    :      AsanErrorCheck(testing::kAsanRead16BufferUnderflowTestId,
 240  E :          HEAP_BUFFER_UNDERFLOW, ASAN_READ_ACCESS, 2);
 241    :      AsanErrorCheck(testing::kAsanRead32BufferUnderflowTestId,
 242  E :          HEAP_BUFFER_UNDERFLOW, ASAN_READ_ACCESS, 4);
 243    :      AsanErrorCheck(testing::kAsanRead64BufferUnderflowTestId,
 244  E :          HEAP_BUFFER_UNDERFLOW, ASAN_READ_ACCESS, 8);
 245    :  
 246    :      AsanErrorCheck(testing::kAsanWrite8BufferOverflowTestId,
 247  E :          HEAP_BUFFER_OVERFLOW, ASAN_WRITE_ACCESS, 1);
 248    :      AsanErrorCheck(testing::kAsanWrite16BufferOverflowTestId,
 249  E :          HEAP_BUFFER_OVERFLOW, ASAN_WRITE_ACCESS, 2);
 250    :      AsanErrorCheck(testing::kAsanWrite32BufferOverflowTestId,
 251  E :          HEAP_BUFFER_OVERFLOW, ASAN_WRITE_ACCESS, 4);
 252    :      AsanErrorCheck(testing::kAsanWrite64BufferOverflowTestId,
 253  E :          HEAP_BUFFER_OVERFLOW, ASAN_WRITE_ACCESS, 8);
 254    :  
 255    :      AsanErrorCheck(testing::kAsanWrite8BufferUnderflowTestId,
 256  E :          HEAP_BUFFER_UNDERFLOW, ASAN_WRITE_ACCESS, 1);
 257    :      AsanErrorCheck(testing::kAsanWrite16BufferUnderflowTestId,
 258  E :          HEAP_BUFFER_UNDERFLOW, ASAN_WRITE_ACCESS, 2);
 259    :      AsanErrorCheck(testing::kAsanWrite32BufferUnderflowTestId,
 260  E :          HEAP_BUFFER_UNDERFLOW, ASAN_WRITE_ACCESS, 4);
 261    :      AsanErrorCheck(testing::kAsanWrite64BufferUnderflowTestId,
 262  E :          HEAP_BUFFER_UNDERFLOW, ASAN_WRITE_ACCESS, 8);
 263    :  
 264    :      AsanErrorCheck(testing::kAsanRead8UseAfterFreeTestId, USE_AFTER_FREE,
 265  E :          ASAN_READ_ACCESS, 1);
 266    :      AsanErrorCheck(testing::kAsanRead16UseAfterFreeTestId, USE_AFTER_FREE,
 267  E :          ASAN_READ_ACCESS, 2);
 268    :      AsanErrorCheck(testing::kAsanRead32UseAfterFreeTestId, USE_AFTER_FREE,
 269  E :          ASAN_READ_ACCESS, 4);
 270    :      AsanErrorCheck(testing::kAsanRead64UseAfterFreeTestId, USE_AFTER_FREE,
 271  E :          ASAN_READ_ACCESS, 8);
 272    :  
 273    :      AsanErrorCheck(testing::kAsanWrite8UseAfterFreeTestId, USE_AFTER_FREE,
 274  E :          ASAN_WRITE_ACCESS, 1);
 275    :      AsanErrorCheck(testing::kAsanWrite16UseAfterFreeTestId, USE_AFTER_FREE,
 276  E :          ASAN_WRITE_ACCESS, 2);
 277    :      AsanErrorCheck(testing::kAsanWrite32UseAfterFreeTestId, USE_AFTER_FREE,
 278  E :          ASAN_WRITE_ACCESS, 4);
 279    :      AsanErrorCheck(testing::kAsanWrite64UseAfterFreeTestId, USE_AFTER_FREE,
 280  E :          ASAN_WRITE_ACCESS, 8);
 281  E :    }
 282    :  
 283  E :    void AsanErrorCheckInterceptedFunctions() {
 284    :      AsanErrorCheck(testing::kAsanMemsetOverflow, HEAP_BUFFER_OVERFLOW,
 285  E :          ASAN_WRITE_ACCESS, 1);
 286    :      AsanErrorCheck(testing::kAsanMemsetUnderflow, HEAP_BUFFER_UNDERFLOW,
 287  E :          ASAN_WRITE_ACCESS, 1);
 288    :      AsanErrorCheck(testing::kAsanMemsetUseAfterFree, USE_AFTER_FREE,
 289  E :          ASAN_WRITE_ACCESS, 1);
 290    :      AsanErrorCheck(testing::kAsanMemchrOverflow, HEAP_BUFFER_OVERFLOW,
 291  E :          ASAN_READ_ACCESS, 1);
 292    :      AsanErrorCheck(testing::kAsanMemchrUnderflow, HEAP_BUFFER_UNDERFLOW,
 293  E :          ASAN_READ_ACCESS, 1);
 294    :      AsanErrorCheck(testing::kAsanMemchrUseAfterFree, USE_AFTER_FREE,
 295  E :          ASAN_READ_ACCESS, 1);
 296    :      AsanErrorCheck(testing::kAsanMemmoveReadOverflow, HEAP_BUFFER_OVERFLOW,
 297  E :          ASAN_READ_ACCESS, 1);
 298    :      AsanErrorCheck(testing::kAsanMemmoveReadUnderflow, HEAP_BUFFER_UNDERFLOW,
 299  E :          ASAN_READ_ACCESS, 1);
 300    :      AsanErrorCheck(testing::kAsanMemmoveUseAfterFree, USE_AFTER_FREE,
 301  E :          ASAN_WRITE_ACCESS, 1);
 302    :      AsanErrorCheck(testing::kAsanMemmoveWriteOverflow, HEAP_BUFFER_OVERFLOW,
 303  E :          ASAN_WRITE_ACCESS, 1);
 304    :      AsanErrorCheck(testing::kAsanMemmoveWriteUnderflow, HEAP_BUFFER_UNDERFLOW,
 305  E :          ASAN_WRITE_ACCESS, 1);
 306    :      AsanErrorCheck(testing::kAsanMemcpyReadOverflow, HEAP_BUFFER_OVERFLOW,
 307  E :          ASAN_READ_ACCESS, 1);
 308    :      AsanErrorCheck(testing::kAsanMemcpyReadUnderflow, HEAP_BUFFER_UNDERFLOW,
 309  E :          ASAN_READ_ACCESS, 1);
 310    :      AsanErrorCheck(testing::kAsanMemcpyUseAfterFree, USE_AFTER_FREE,
 311  E :          ASAN_READ_ACCESS, 1);
 312    :      AsanErrorCheck(testing::kAsanMemcpyWriteOverflow, HEAP_BUFFER_OVERFLOW,
 313  E :          ASAN_WRITE_ACCESS, 1);
 314    :      AsanErrorCheck(testing::kAsanMemcpyWriteUnderflow, HEAP_BUFFER_UNDERFLOW,
 315  E :          ASAN_WRITE_ACCESS, 1);
 316    :  
 317    :      AsanErrorCheck(testing::kAsanStrcspnKeysOverflow, HEAP_BUFFER_OVERFLOW,
 318  E :          ASAN_READ_ACCESS, 1);
 319    :      AsanErrorCheck(testing::kAsanStrcspnKeysUnderflow, HEAP_BUFFER_UNDERFLOW,
 320  E :          ASAN_READ_ACCESS, 1);
 321    :      AsanErrorCheck(testing::kAsanStrcspnKeysUseAfterFree, USE_AFTER_FREE,
 322  E :          ASAN_READ_ACCESS, 1);
 323    :      AsanErrorCheck(testing::kAsanStrcspnSrcOverflow, HEAP_BUFFER_OVERFLOW,
 324  E :          ASAN_READ_ACCESS, 1);
 325    :      AsanErrorCheck(testing::kAsanStrcspnSrcUnderflow, HEAP_BUFFER_UNDERFLOW,
 326  E :          ASAN_READ_ACCESS, 1);
 327    :      AsanErrorCheck(testing::kAsanStrcspnSrcUseAfterFree, USE_AFTER_FREE,
 328  E :          ASAN_READ_ACCESS, 1);
 329    :      AsanErrorCheck(testing::kAsanStrlenOverflow, HEAP_BUFFER_OVERFLOW,
 330  E :          ASAN_READ_ACCESS, 1);
 331    :      AsanErrorCheck(testing::kAsanStrlenUnderflow, HEAP_BUFFER_UNDERFLOW,
 332  E :          ASAN_READ_ACCESS, 1);
 333    :      AsanErrorCheck(testing::kAsanStrlenUseAfterFree, USE_AFTER_FREE,
 334  E :          ASAN_READ_ACCESS, 1);
 335    :      AsanErrorCheck(testing::kAsanStrrchrOverflow, HEAP_BUFFER_OVERFLOW,
 336  E :          ASAN_READ_ACCESS, 1);
 337    :      AsanErrorCheck(testing::kAsanStrrchrUnderflow, HEAP_BUFFER_UNDERFLOW,
 338  E :          ASAN_READ_ACCESS, 1);
 339    :      AsanErrorCheck(testing::kAsanStrrchrUseAfterFree, USE_AFTER_FREE,
 340  E :          ASAN_READ_ACCESS, 1);
 341    :      AsanErrorCheck(testing::kAsanStrcmpSrc1Overflow, HEAP_BUFFER_OVERFLOW,
 342  E :          ASAN_READ_ACCESS, 1);
 343    :      AsanErrorCheck(testing::kAsanStrcmpSrc1Underflow, HEAP_BUFFER_UNDERFLOW,
 344  E :          ASAN_READ_ACCESS, 1);
 345    :      AsanErrorCheck(testing::kAsanStrcmpSrc1UseAfterFree, USE_AFTER_FREE,
 346  E :          ASAN_READ_ACCESS, 1);
 347    :      AsanErrorCheck(testing::kAsanStrcmpSrc2Overflow, HEAP_BUFFER_OVERFLOW,
 348  E :          ASAN_READ_ACCESS, 1);
 349    :      AsanErrorCheck(testing::kAsanStrcmpSrc2Underflow, HEAP_BUFFER_UNDERFLOW,
 350  E :          ASAN_READ_ACCESS, 1);
 351    :      AsanErrorCheck(testing::kAsanStrcmpSrc2UseAfterFree, USE_AFTER_FREE,
 352  E :          ASAN_READ_ACCESS, 1);
 353    :      AsanErrorCheck(testing::kAsanStrpbrkKeysOverflow, HEAP_BUFFER_OVERFLOW,
 354  E :          ASAN_READ_ACCESS, 1);
 355    :      AsanErrorCheck(testing::kAsanStrpbrkKeysUnderflow, HEAP_BUFFER_UNDERFLOW,
 356  E :          ASAN_READ_ACCESS, 1);
 357    :      AsanErrorCheck(testing::kAsanStrpbrkKeysUseAfterFree, USE_AFTER_FREE,
 358  E :          ASAN_READ_ACCESS, 1);
 359    :      AsanErrorCheck(testing::kAsanStrpbrkSrcOverflow, HEAP_BUFFER_OVERFLOW,
 360  E :          ASAN_READ_ACCESS, 1);
 361    :      AsanErrorCheck(testing::kAsanStrpbrkSrcUnderflow, HEAP_BUFFER_UNDERFLOW,
 362  E :          ASAN_READ_ACCESS, 1);
 363    :      AsanErrorCheck(testing::kAsanStrpbrkSrcUseAfterFree, USE_AFTER_FREE,
 364  E :          ASAN_READ_ACCESS, 1);
 365    :      AsanErrorCheck(testing::kAsanStrstrSrc1Overflow, HEAP_BUFFER_OVERFLOW,
 366  E :          ASAN_READ_ACCESS, 1);
 367    :      AsanErrorCheck(testing::kAsanStrstrSrc1Underflow, HEAP_BUFFER_UNDERFLOW,
 368  E :          ASAN_READ_ACCESS, 1);
 369    :      AsanErrorCheck(testing::kAsanStrstrSrc1UseAfterFree, USE_AFTER_FREE,
 370  E :          ASAN_READ_ACCESS, 1);
 371    :      AsanErrorCheck(testing::kAsanStrstrSrc2Overflow, HEAP_BUFFER_OVERFLOW,
 372  E :          ASAN_READ_ACCESS, 1);
 373    :      AsanErrorCheck(testing::kAsanStrstrSrc2Underflow, HEAP_BUFFER_UNDERFLOW,
 374  E :          ASAN_READ_ACCESS, 1);
 375    :      AsanErrorCheck(testing::kAsanStrstrSrc2UseAfterFree, USE_AFTER_FREE,
 376  E :          ASAN_READ_ACCESS, 1);
 377    :      AsanErrorCheck(testing::kAsanStrspnKeysOverflow, HEAP_BUFFER_OVERFLOW,
 378  E :          ASAN_READ_ACCESS, 1);
 379    :      AsanErrorCheck(testing::kAsanStrspnKeysUnderflow, HEAP_BUFFER_UNDERFLOW,
 380  E :          ASAN_READ_ACCESS, 1);
 381    :      AsanErrorCheck(testing::kAsanStrspnKeysUseAfterFree, USE_AFTER_FREE,
 382  E :          ASAN_READ_ACCESS, 1);
 383    :      AsanErrorCheck(testing::kAsanStrspnSrcOverflow, HEAP_BUFFER_OVERFLOW,
 384  E :          ASAN_READ_ACCESS, 1);
 385    :      AsanErrorCheck(testing::kAsanStrspnSrcUnderflow, HEAP_BUFFER_UNDERFLOW,
 386  E :          ASAN_READ_ACCESS, 1);
 387    :      AsanErrorCheck(testing::kAsanStrspnSrcUseAfterFree, USE_AFTER_FREE,
 388  E :          ASAN_READ_ACCESS, 1);
 389    :      AsanErrorCheck(testing::kAsanStrncpySrcOverflow, HEAP_BUFFER_OVERFLOW,
 390  E :          ASAN_READ_ACCESS, 1);
 391    :      AsanErrorCheck(testing::kAsanStrncpySrcUnderflow, HEAP_BUFFER_UNDERFLOW,
 392  E :          ASAN_READ_ACCESS, 1);
 393    :      AsanErrorCheck(testing::kAsanStrncpySrcUseAfterFree, USE_AFTER_FREE,
 394  E :          ASAN_READ_ACCESS, 1);
 395    :      AsanErrorCheck(testing::kAsanStrncpyDstOverflow, HEAP_BUFFER_OVERFLOW,
 396  E :          ASAN_WRITE_ACCESS, 1);
 397    :      AsanErrorCheck(testing::kAsanStrncpyDstUnderflow, HEAP_BUFFER_UNDERFLOW,
 398  E :          ASAN_WRITE_ACCESS, 1);
 399    :      AsanErrorCheck(testing::kAsanStrncpyDstUseAfterFree, USE_AFTER_FREE,
 400  E :          ASAN_WRITE_ACCESS, 1);
 401    :      AsanErrorCheck(testing::kAsanStrncatSuffixOverflow, HEAP_BUFFER_OVERFLOW,
 402  E :          ASAN_READ_ACCESS, 1);
 403    :      AsanErrorCheck(testing::kAsanStrncatSuffixUnderflow, HEAP_BUFFER_UNDERFLOW,
 404  E :          ASAN_READ_ACCESS, 1);
 405    :      AsanErrorCheck(testing::kAsanStrncatSuffixUseAfterFree, USE_AFTER_FREE,
 406  E :          ASAN_READ_ACCESS, 1);
 407    :      AsanErrorCheck(testing::kAsanStrncatDstOverflow, HEAP_BUFFER_OVERFLOW,
 408  E :          ASAN_WRITE_ACCESS, 1);
 409    :      AsanErrorCheck(testing::kAsanStrncatDstUnderflow, HEAP_BUFFER_UNDERFLOW,
 410  E :          ASAN_WRITE_ACCESS, 1);
 411    :      AsanErrorCheck(testing::kAsanStrncatDstUseAfterFree, USE_AFTER_FREE,
 412  E :          ASAN_WRITE_ACCESS, 1);
 413    :  
 414    :      AsanErrorCheck(testing::kAsanReadFileOverflow, HEAP_BUFFER_OVERFLOW,
 415  E :          ASAN_WRITE_ACCESS, 1);
 416    :      AsanErrorCheck(testing::kAsanReadFileUseAfterFree, USE_AFTER_FREE,
 417  E :          ASAN_WRITE_ACCESS, 1);
 418    :      AsanErrorCheck(testing::kAsanWriteFileOverflow, HEAP_BUFFER_OVERFLOW,
 419  E :          ASAN_READ_ACCESS, 1);
 420    :      AsanErrorCheck(testing::kAsanWriteFileUseAfterFree, USE_AFTER_FREE,
 421  E :          ASAN_READ_ACCESS, 1);
 422  E :    }
 423    :  
 424  E :    void BBEntryInvokeTestDll() {
 425  E :      EXPECT_EQ(42, InvokeTestDllFunction(testing::kBBEntryCallOnce));
 426  E :      EXPECT_EQ(42, InvokeTestDllFunction(testing::kBBEntryCallTree));
 427  E :      EXPECT_EQ(42, InvokeTestDllFunction(testing::kBBEntryCallRecursive));
 428  E :    }
 429    :  
 430  E :    void ProfileInvokeTestDll() {
 431  E :      EXPECT_EQ(5, InvokeTestDllFunction(testing::kProfileCallExport));
 432    :      // Save the RVA of one of the invoked functions for testing later.
 433  E :      get_my_rva_ = InvokeTestDllFunction(testing::kProfileGetMyRVA);
 434    :  
 435    :      // The profiler will record the address of the first instruction of the
 436    :      // original function, which is six bytes past the start of the function
 437    :      // as seen by itself post-instrumentation.
 438  E :      get_my_rva_ += 6;
 439  E :    }
 440    :  
 441    :    uint32 ProfileInvokeGetRVA() {
 442    :      return InvokeTestDllFunction(testing::kProfileGetMyRVA);
 443    :    }
 444    :  
 445  E :    void QueueTraces(Parser* parser) {
 446  E :      DCHECK(parser != NULL);
 447    :  
 448    :      // Queue up the trace file(s) we engendered.
 449    :      file_util::FileEnumerator enumerator(traces_dir_,
 450    :                                           false,
 451  E :                                           file_util::FileEnumerator::FILES);
 452  E :      while (true) {
 453  E :        base::FilePath trace_file = enumerator.Next();
 454  E :        if (trace_file.empty())
 455  E :          break;
 456  E :        ASSERT_TRUE(parser->OpenTraceFile(trace_file));
 457  E :      }
 458  E :    }
 459    :  
 460  E :    const Block* FindBlockWithName(std::string name) {
 461  E :      const BlockMap& blocks = block_graph_.blocks();
 462  E :      BlockMap::const_iterator block_iter = blocks.begin();
 463  E :      for (; block_iter != blocks.end(); ++block_iter) {
 464  E :        const Block& block = block_iter->second;
 465  E :        if (block.type() != block_graph::BlockGraph::CODE_BLOCK)
 466  E :          continue;
 467  E :        if (block.name().compare(name) == 0)
 468  E :          return &block;
 469  E :      }
 470  i :      return NULL;
 471  E :    }
 472    :  
 473    :    int GetBlockFrequency(const IndexedFrequencyMap& frequencies,
 474  E :                          const Block* block) {
 475  E :      DCHECK(block != NULL);
 476    :      IndexedFrequencyMap::const_iterator entry =
 477  E :          frequencies.find(std::make_pair(block->addr(), 0));
 478  E :      if (entry == frequencies.end())
 479  i :        return 0;
 480  E :      return entry->second;
 481  E :    }
 482    :  
 483    :    void ExpectFunctionFrequency(const IndexedFrequencyMap& frequencies,
 484    :                                 const char* function_name,
 485  E :                                 int expected_frequency) {
 486  E :      DCHECK(function_name != NULL);
 487  E :      const Block* block = FindBlockWithName(function_name);
 488  E :      ASSERT_TRUE(block != NULL);
 489  E :      int exec_frequency = GetBlockFrequency(frequencies, block);
 490  E :      EXPECT_EQ(expected_frequency, exec_frequency);
 491  E :    }
 492    :  
 493  E :    void DecomposeImage() {
 494    :      // Decompose the DLL.
 495  E :      pe_image_.Init(input_dll_path_);
 496  E :      pe::Decomposer decomposer(pe_image_);
 497  E :      ASSERT_TRUE(decomposer.Decompose(&image_layout_));
 498  E :    }
 499    :  
 500  E :    void BBEntryCheckTestDll() {
 501  E :      Parser parser;
 502  E :      grinder::grinders::IndexedFrequencyDataGrinder grinder;
 503    :  
 504    :      // Initialize trace parser.
 505  E :      ASSERT_TRUE(parser.Init(&grinder));
 506  E :      grinder.SetParser(&parser);
 507    :  
 508    :      // Add generated traces to the parser.
 509  E :      QueueTraces(&parser);
 510    :  
 511    :      // Parse all traces.
 512  E :      ASSERT_TRUE(parser.Consume());
 513  E :      ASSERT_FALSE(parser.error_occurred());
 514  E :      ASSERT_TRUE(grinder.Grind());
 515    :  
 516    :      // Retrieve basic block count information.
 517    :      const ModuleIndexedFrequencyMap& module_entry_count =
 518  E :          grinder.frequency_data_map();
 519  E :      ASSERT_EQ(1u, module_entry_count.size());
 520    :  
 521    :      ModuleIndexedFrequencyMap::const_iterator entry_iter =
 522  E :          module_entry_count.begin();
 523  E :      const IndexedFrequencyInformation& info = entry_iter->second;
 524  E :      const IndexedFrequencyMap& entry_count = info.frequency_map;
 525    :  
 526    :      // Decompose the output image.
 527  E :      ASSERT_NO_FATAL_FAILURE(DecomposeImage());
 528    :  
 529    :      // Validate function entry counts.
 530  E :      ASSERT_NO_FATAL_FAILURE(
 531    :          ExpectFunctionFrequency(entry_count, "BBEntryCallOnce", 1));
 532  E :      ASSERT_NO_FATAL_FAILURE(
 533    :          ExpectFunctionFrequency(entry_count, "BBEntryCallTree", 1));
 534  E :      ASSERT_NO_FATAL_FAILURE(
 535    :          ExpectFunctionFrequency(entry_count, "BBEntryFunction1", 4));
 536  E :      ASSERT_NO_FATAL_FAILURE(
 537    :          ExpectFunctionFrequency(entry_count, "BBEntryFunction2", 2));
 538  E :      ASSERT_NO_FATAL_FAILURE(
 539    :          ExpectFunctionFrequency(entry_count, "BBEntryFunction3", 1));
 540  E :      ASSERT_NO_FATAL_FAILURE(
 541    :          ExpectFunctionFrequency(entry_count, "BBEntryCallRecursive", 1));
 542  E :      ASSERT_NO_FATAL_FAILURE(
 543    :          ExpectFunctionFrequency(entry_count, "BBEntryFunctionRecursive", 42));
 544  E :    }
 545    :  
 546  E :    void BranchCheckTestDll() {
 547  E :      Parser parser;
 548  E :      grinder::grinders::IndexedFrequencyDataGrinder grinder;
 549    :  
 550    :      // Initialize trace parser.
 551  E :      ASSERT_TRUE(parser.Init(&grinder));
 552  E :      grinder.SetParser(&parser);
 553    :  
 554    :      // Add generated traces to the parser.
 555  E :      QueueTraces(&parser);
 556    :  
 557    :      // Parse all traces.
 558  E :      ASSERT_TRUE(parser.Consume());
 559  E :      ASSERT_FALSE(parser.error_occurred());
 560  E :      ASSERT_TRUE(grinder.Grind());
 561    :  
 562    :      // Retrieve basic block count information.
 563    :      const grinder::basic_block_util::ModuleIndexedFrequencyMap& module_map =
 564  E :          grinder.frequency_data_map();
 565  E :      ASSERT_EQ(1u, module_map.size());
 566    :  
 567  E :      ModuleIndexedFrequencyMap::const_iterator entry_iter = module_map.begin();
 568  E :      const IndexedFrequencyInformation& information = entry_iter->second;
 569  E :      const IndexedFrequencyMap& frequency_map = information.frequency_map;
 570    :  
 571    :      // Decompose the output image.
 572  E :      ASSERT_NO_FATAL_FAILURE(DecomposeImage());
 573    :  
 574    :      // Validate function entry counts.
 575  E :      ASSERT_NO_FATAL_FAILURE(
 576    :          ExpectFunctionFrequency(frequency_map, "BBEntryCallOnce", 1));
 577  E :      ASSERT_NO_FATAL_FAILURE(
 578    :          ExpectFunctionFrequency(frequency_map, "BBEntryCallTree", 1));
 579  E :      ASSERT_NO_FATAL_FAILURE(
 580    :          ExpectFunctionFrequency(frequency_map, "BBEntryFunction1", 4));
 581  E :      ASSERT_NO_FATAL_FAILURE(
 582    :          ExpectFunctionFrequency(frequency_map, "BBEntryFunction2", 2));
 583  E :      ASSERT_NO_FATAL_FAILURE(
 584    :          ExpectFunctionFrequency(frequency_map, "BBEntryFunction3", 1));
 585  E :      ASSERT_NO_FATAL_FAILURE(
 586    :          ExpectFunctionFrequency(frequency_map, "BBEntryCallRecursive", 1));
 587  E :      ASSERT_NO_FATAL_FAILURE(
 588    :          ExpectFunctionFrequency(frequency_map, "BBEntryFunctionRecursive", 42));
 589  E :    }
 590    :  
 591  E :    bool GetLineInfoExecution(const SourceFileCoverageData* data, size_t line) {
 592  E :      DCHECK(data != NULL);
 593    :  
 594  E :      const LineExecutionCountMap& lines = data->line_execution_count_map;
 595  E :      LineExecutionCountMap::const_iterator look = lines.find(line);
 596  E :      if (look != lines.end()) {
 597  E :        if (look->second != 0)
 598  E :          return true;
 599    :      }
 600    :  
 601  E :      return false;
 602  E :    }
 603    :  
 604  E :    void CoverageInvokeTestDll() {
 605  E :      EXPECT_EQ(182, InvokeTestDllFunction(testing::kCoverage1));
 606  E :      EXPECT_EQ(182, InvokeTestDllFunction(testing::kCoverage2));
 607  E :      EXPECT_EQ(2, InvokeTestDllFunction(testing::kCoverage3));
 608  E :    }
 609    :  
 610  E :    void CoverageCheckTestDll() {
 611  E :      Parser parser;
 612  E :      grinder::grinders::CoverageGrinder grinder;
 613    :  
 614    :      // Initialize trace parser.
 615  E :      ASSERT_TRUE(parser.Init(&grinder));
 616  E :      grinder.SetParser(&parser);
 617    :  
 618    :      // Add generated traces to the parser.
 619  E :      QueueTraces(&parser);
 620    :  
 621    :      // Parse all traces.
 622  E :      ASSERT_TRUE(parser.Consume());
 623  E :      ASSERT_FALSE(parser.error_occurred());
 624  E :      ASSERT_TRUE(grinder.Grind());
 625    :  
 626    :      // Retrieve coverage information.
 627  E :      const grinder::CoverageData& coverage_data = grinder.coverage_data();
 628    :      const SourceFileCoverageDataMap& files =
 629  E :          coverage_data.source_file_coverage_data_map();
 630    :  
 631    :      // Find file "coverage_tests.cc".
 632  E :      SourceFileCoverageDataMap::const_iterator file = files.begin();
 633  E :      const SourceFileCoverageData* data = NULL;
 634  E :      for (; file != files.end(); ++file) {
 635  E :        if (EndsWith(file->first, "coverage_tests.cc", true)) {
 636  E :          data = &file->second;
 637  E :          break;
 638    :        }
 639  E :      }
 640  E :      ASSERT_TRUE(data != NULL);
 641    :  
 642    :      // Validate function entry counts.
 643    :      // Function: coverage_func1.
 644  E :      EXPECT_TRUE(GetLineInfoExecution(data, 28));
 645  E :      EXPECT_TRUE(GetLineInfoExecution(data, 29));
 646    :  
 647    :      // Function: coverage_func2.
 648  E :      EXPECT_TRUE(GetLineInfoExecution(data, 35));
 649  E :      EXPECT_TRUE(GetLineInfoExecution(data, 36));
 650  E :      EXPECT_TRUE(GetLineInfoExecution(data, 37));
 651  E :      EXPECT_FALSE(GetLineInfoExecution(data, 40));
 652  E :      EXPECT_TRUE(GetLineInfoExecution(data, 42));
 653    :  
 654    :      // Function: coverage_func3.
 655  E :      EXPECT_TRUE(GetLineInfoExecution(data, 47));
 656  E :      EXPECT_FALSE(GetLineInfoExecution(data, 49));
 657  E :      EXPECT_FALSE(GetLineInfoExecution(data, 50));
 658  E :      EXPECT_TRUE(GetLineInfoExecution(data, 52));
 659  E :      EXPECT_TRUE(GetLineInfoExecution(data, 54));
 660  E :    }
 661    :  
 662    :    static bool ContainsString(const std::vector<std::wstring>& vec,
 663  E :                               const wchar_t* str) {
 664  E :      return std::find(vec.begin(), vec.end(), str) != vec.end();
 665  E :    }
 666    :  
 667  E :    void ProfileCheckTestDll(bool thunk_imports) {
 668  E :      Parser parser;
 669  E :      TestingProfileGrinder grinder;
 670    :  
 671    :      // Have the grinder aggregate all data to a single part.
 672  E :      grinder.set_thread_parts(false);
 673    :  
 674    :      // Initialize trace parser.
 675  E :      ASSERT_TRUE(parser.Init(&grinder));
 676  E :      grinder.SetParser(&parser);
 677    :  
 678    :      // Add generated traces to the parser.
 679  E :      QueueTraces(&parser);
 680    :  
 681    :      // Parse all traces.
 682  E :      ASSERT_TRUE(parser.Consume());
 683  E :      ASSERT_FALSE(parser.error_occurred());
 684  E :      ASSERT_TRUE(grinder.Grind());
 685    :  
 686    :      const TestingProfileGrinder::ModuleInformationSet& modules =
 687  E :          grinder.modules_;
 688  E :      TestingProfileGrinder::ModuleInformationSet::const_iterator mod_it;
 689  E :      std::vector<std::wstring> module_names;
 690  E :      for (mod_it = modules.begin(); mod_it != modules.end(); ++mod_it) {
 691  E :        base::FilePath image_name(mod_it->image_file_name);
 692  E :        module_names.push_back(image_name.BaseName().value());
 693  E :      }
 694    :  
 695  E :      EXPECT_TRUE(ContainsString(module_names, L"integration_tests_dll.dll"));
 696    :      // If imports are thunked, we expect to find a module entry for the export
 697    :      // DLL - otherwise it shouldn't be in there at all.
 698  E :      if (thunk_imports) {
 699  E :        EXPECT_TRUE(ContainsString(module_names, L"export_dll.dll"));
 700  E :      } else {
 701  E :        EXPECT_FALSE(ContainsString(module_names, L"export_dll.dll"));
 702    :      }
 703    :  
 704    :      // Make sure at least one function we know of was hit.
 705  E :      ASSERT_EQ(1U, grinder.parts_.size());
 706    :      const TestingProfileGrinder::PartData& data =
 707  E :          grinder.parts_.begin()->second;
 708    :  
 709    :      TestingProfileGrinder::InvocationNodeMap::const_iterator node_it =
 710  E :          data.nodes_.begin();
 711  E :      for (; node_it != data.nodes_.end(); ++node_it) {
 712  E :        if (node_it->second.function.rva() == get_my_rva_)
 713  E :          return;
 714  E :      }
 715    :  
 716  i :      FAIL() << "Didn't find GetMyRVA function entry.";
 717  E :    }
 718    :  
 719    :    // Stashes the current log-level before each test instance and restores it
 720    :    // after each test completes.
 721    :    testing::ScopedLogLevelSaver log_level_saver;
 722    :  
 723    :    // @name The application under test.
 724    :    // @{
 725    :    TestApp test_app_;
 726    :    TestApp::Implementation& test_impl_;
 727    :    base::FilePath temp_dir_;
 728    :    base::FilePath stdin_path_;
 729    :    base::FilePath stdout_path_;
 730    :    base::FilePath stderr_path_;
 731    :    // @}
 732    :  
 733    :    // @name Command-line, parameters and outputs.
 734    :    // @{
 735    :    CommandLine cmd_line_;
 736    :    base::FilePath input_dll_path_;
 737    :    base::FilePath output_dll_path_;
 738    :    base::FilePath traces_dir_;
 739    :    // @}
 740    :  
 741    :    // The test_dll module.
 742    :    testing::ScopedHMODULE module_;
 743    :  
 744    :    // Our call trace service process instance.
 745    :    testing::CallTraceService service_;
 746    :  
 747    :    // Decomposed image.
 748    :    pe::PEFile pe_image_;
 749    :    pe::ImageLayout image_layout_;
 750    :    block_graph::BlockGraph block_graph_;
 751    :    uint32 get_my_rva_;
 752    :  };
 753    :  
 754    :  }  // namespace
 755    :  
 756  E :  TEST_F(InstrumentAppIntegrationTest, AsanEndToEnd) {
 757  E :    ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
 758  E :    ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
 759  E :    ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll());
 760  E :  }
 761    :  
 762  E :  TEST_F(InstrumentAppIntegrationTest, AsanEndToEndNoLiveness) {
 763  E :    cmd_line_.AppendSwitch("no-liveness-analysis");
 764  E :    ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
 765  E :    ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
 766  E :    ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll());
 767  E :  }
 768    :  
 769  E :  TEST_F(InstrumentAppIntegrationTest, AsanEndToEndNoRedundancyAnalysis) {
 770  E :    cmd_line_.AppendSwitch("no-redundancy-analysis");
 771  E :    ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
 772  E :    ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
 773  E :    ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll());
 774  E :  }
 775    :  
 776  E :  TEST_F(InstrumentAppIntegrationTest, AsanEndToEndNoFunctionInterceptors) {
 777  E :    cmd_line_.AppendSwitch("no-interceptors");
 778  E :    ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
 779  E :    ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
 780  E :    ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll());
 781  E :  }
 782    :  
 783  E :  TEST_F(InstrumentAppIntegrationTest, FullOptimizedAsanEndToEnd) {
 784  E :    ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
 785  E :    ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
 786  E :    ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll());
 787  E :    ASSERT_NO_FATAL_FAILURE(AsanErrorCheckInterceptedFunctions());
 788  E :  }
 789    :  
 790  E :  TEST_F(InstrumentAppIntegrationTest, BBEntryEndToEnd) {
 791  E :    ASSERT_NO_FATAL_FAILURE(StartService());
 792  E :    ASSERT_NO_FATAL_FAILURE(EndToEndTest("bbentry"));
 793  E :    ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
 794  E :    ASSERT_NO_FATAL_FAILURE(BBEntryInvokeTestDll());
 795  E :    ASSERT_NO_FATAL_FAILURE(StopService());
 796  E :    ASSERT_NO_FATAL_FAILURE(BBEntryCheckTestDll());
 797  E :  }
 798    :  
 799  E :  TEST_F(InstrumentAppIntegrationTest, BranchEndToEnd) {
 800  E :    ASSERT_NO_FATAL_FAILURE(StartService());
 801  E :    ASSERT_NO_FATAL_FAILURE(EndToEndTest("branch"));
 802  E :    ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
 803  E :    ASSERT_NO_FATAL_FAILURE(BBEntryInvokeTestDll());
 804  E :    ASSERT_NO_FATAL_FAILURE(UnloadDll());
 805  E :    ASSERT_NO_FATAL_FAILURE(StopService());
 806  E :    ASSERT_NO_FATAL_FAILURE(BranchCheckTestDll());
 807  E :  }
 808    :  
 809  E :  TEST_F(InstrumentAppIntegrationTest, BranchWithBufferingEndToEnd) {
 810  E :    cmd_line_.AppendSwitch("buffering");
 811  E :    ASSERT_NO_FATAL_FAILURE(StartService());
 812  E :    ASSERT_NO_FATAL_FAILURE(EndToEndTest("branch"));
 813  E :    ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
 814  E :    ASSERT_NO_FATAL_FAILURE(BBEntryInvokeTestDll());
 815  E :    ASSERT_NO_FATAL_FAILURE(UnloadDll());
 816  E :    ASSERT_NO_FATAL_FAILURE(StopService());
 817  E :    ASSERT_NO_FATAL_FAILURE(BranchCheckTestDll());
 818  E :  }
 819    :  
 820  E :  TEST_F(InstrumentAppIntegrationTest, BranchWithSlotEndToEnd) {
 821  E :    cmd_line_.AppendSwitchASCII("fs-slot", "1");
 822  E :    ASSERT_NO_FATAL_FAILURE(StartService());
 823  E :    ASSERT_NO_FATAL_FAILURE(EndToEndTest("branch"));
 824  E :    ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
 825  E :    ASSERT_NO_FATAL_FAILURE(BBEntryInvokeTestDll());
 826  E :    ASSERT_NO_FATAL_FAILURE(UnloadDll());
 827  E :    ASSERT_NO_FATAL_FAILURE(StopService());
 828  E :    ASSERT_NO_FATAL_FAILURE(BranchCheckTestDll());
 829  E :  }
 830    :  
 831  E :  TEST_F(InstrumentAppIntegrationTest, BranchWithSlotAndBufferingEndToEnd) {
 832  E :    cmd_line_.AppendSwitch("buffering");
 833  E :    cmd_line_.AppendSwitchASCII("fs-slot", "1");
 834  E :    ASSERT_NO_FATAL_FAILURE(StartService());
 835  E :    ASSERT_NO_FATAL_FAILURE(EndToEndTest("branch"));
 836  E :    ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
 837  E :    ASSERT_NO_FATAL_FAILURE(BBEntryInvokeTestDll());
 838  E :    ASSERT_NO_FATAL_FAILURE(UnloadDll());
 839  E :    ASSERT_NO_FATAL_FAILURE(StopService());
 840  E :    ASSERT_NO_FATAL_FAILURE(BranchCheckTestDll());
 841  E :  }
 842    :  
 843  E :  TEST_F(InstrumentAppIntegrationTest, CallTraceEndToEnd) {
 844  E :    ASSERT_NO_FATAL_FAILURE(EndToEndTest("calltrace"));
 845  E :    ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
 846  E :  }
 847    :  
 848  E :  TEST_F(InstrumentAppIntegrationTest, CoverageEndToEnd) {
 849  E :    ASSERT_NO_FATAL_FAILURE(StartService());
 850  E :    ASSERT_NO_FATAL_FAILURE(EndToEndTest("coverage"));
 851  E :    ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
 852  E :    ASSERT_NO_FATAL_FAILURE(CoverageInvokeTestDll());
 853  E :    ASSERT_NO_FATAL_FAILURE(StopService());
 854  E :    ASSERT_NO_FATAL_FAILURE(CoverageCheckTestDll());
 855  E :  }
 856    :  
 857  E :  TEST_F(InstrumentAppIntegrationTest, BBEntryCoverageEndToEnd) {
 858    :    // Coverage grinder must be able to process traces produced by bbentry
 859    :    // instrumentation.
 860  E :    ASSERT_NO_FATAL_FAILURE(StartService());
 861  E :    ASSERT_NO_FATAL_FAILURE(EndToEndTest("bbentry"));
 862  E :    ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
 863  E :    ASSERT_NO_FATAL_FAILURE(CoverageInvokeTestDll());
 864  E :    ASSERT_NO_FATAL_FAILURE(StopService());
 865  E :    ASSERT_NO_FATAL_FAILURE(CoverageCheckTestDll());
 866  E :  }
 867    :  
 868  E :  TEST_F(InstrumentAppIntegrationTest, ProfileEndToEnd) {
 869  E :    ASSERT_NO_FATAL_FAILURE(StartService());
 870  E :    ASSERT_NO_FATAL_FAILURE(EndToEndTest("profile"));
 871  E :    ASSERT_NO_FATAL_FAILURE(ProfileInvokeTestDll());
 872  E :    ASSERT_NO_FATAL_FAILURE(UnloadDll());
 873  E :    ASSERT_NO_FATAL_FAILURE(StopService());
 874  E :    ASSERT_NO_FATAL_FAILURE(ProfileCheckTestDll(false));
 875  E :  }
 876    :  
 877  E :  TEST_F(InstrumentAppIntegrationTest, ProfileWithImportsEndToEnd) {
 878  E :    cmd_line_.AppendSwitch("instrument-imports");
 879  E :    ASSERT_NO_FATAL_FAILURE(StartService());
 880  E :    ASSERT_NO_FATAL_FAILURE(EndToEndTest("profile"));
 881  E :    ASSERT_NO_FATAL_FAILURE(ProfileInvokeTestDll());
 882  E :    ASSERT_NO_FATAL_FAILURE(UnloadDll());
 883  E :    ASSERT_NO_FATAL_FAILURE(StopService());
 884  E :    ASSERT_NO_FATAL_FAILURE(ProfileCheckTestDll(true));
 885  E :  }
 886    :  
 887    :  }  // namespace integration_tests

Coverage information generated Wed Dec 11 11:34:16 2013.