Coverage for /Syzygy/instrument/instrument_app_unittest.cc

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

Line-by-line coverage:

   1    :  // Copyright 2012 Google Inc.
   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/instrument/instrument_app.h"
  16    :  
  17    :  #include "base/stringprintf.h"
  18    :  #include "gmock/gmock.h"
  19    :  #include "gtest/gtest.h"
  20    :  #include "syzygy/block_graph/unittest_util.h"
  21    :  #include "syzygy/common/unittest_util.h"
  22    :  #include "syzygy/core/unittest_util.h"
  23    :  #include "syzygy/pe/pe_relinker.h"
  24    :  #include "syzygy/pe/pe_utils.h"
  25    :  #include "syzygy/pe/unittest_util.h"
  26    :  
  27    :  namespace instrument {
  28    :  
  29    :  namespace {
  30    :  
  31    :  using testing::StrictMock;
  32    :  using testing::Return;
  33    :  using testing::_;
  34    :  
  35    :  class MockRelinker : public pe::PERelinker {
  36    :   public:
  37  E :    MOCK_METHOD0(Init, bool());
  38  E :    MOCK_METHOD0(Relink, bool());
  39    :  };
  40    :  
  41    :  class TestInstrumentApp : public InstrumentApp {
  42    :   public:
  43    :    using InstrumentApp::input_dll_path_;
  44    :    using InstrumentApp::input_pdb_path_;
  45    :    using InstrumentApp::output_dll_path_;
  46    :    using InstrumentApp::output_pdb_path_;
  47    :    using InstrumentApp::client_dll_;
  48    :    using InstrumentApp::allow_overwrite_;
  49    :    using InstrumentApp::no_augment_pdb_;
  50    :    using InstrumentApp::debug_friendly_;
  51    :    using InstrumentApp::instrument_unsafe_references_;
  52    :    using InstrumentApp::module_entry_only_;
  53    :    using InstrumentApp::thunk_imports_;
  54    :    using InstrumentApp::mode_;
  55    :    using InstrumentApp::no_strip_strings_;
  56    :  
  57  E :    pe::PERelinker& GetRelinker() OVERRIDE {
  58  E :      return mock_relinker_;
  59  E :    }
  60    :  
  61    :    StrictMock<MockRelinker> mock_relinker_;
  62    :  };
  63    :  
  64    :  typedef common::Application<TestInstrumentApp> TestApp;
  65    :  
  66    :  class InstrumentAppTest : public testing::PELibUnitTest {
  67    :   public:
  68    :    typedef testing::PELibUnitTest Super;
  69    :  
  70    :    InstrumentAppTest()
  71    :        : cmd_line_(FilePath(L"instrument.exe")),
  72  E :          test_impl_(test_app_.implementation()) {
  73  E :    }
  74    :  
  75  E :    void SetUp() {
  76  E :      Super::SetUp();
  77    :  
  78    :      // Several of the tests generate progress and (deliberate) error messages
  79    :      // that would otherwise clutter the unittest output.
  80  E :      logging::SetMinLogLevel(logging::LOG_FATAL);
  81    :  
  82    :      // Setup the IO streams.
  83  E :      CreateTemporaryDir(&temp_dir_);
  84  E :      stdin_path_ = temp_dir_.Append(L"NUL");
  85  E :      stdout_path_ = temp_dir_.Append(L"stdout.txt");
  86  E :      stderr_path_ = temp_dir_.Append(L"stderr.txt");
  87  E :      InitStreams(stdin_path_, stdout_path_, stderr_path_);
  88    :  
  89    :      // Initialize the (potential) input and output path values.
  90  E :      abs_input_dll_path_ = testing::GetExeRelativePath(kDllName);
  91  E :      input_dll_path_ = testing::GetRelativePath(abs_input_dll_path_);
  92  E :      abs_input_pdb_path_ = testing::GetExeRelativePath(kDllPdbName);
  93  E :      input_pdb_path_ = testing::GetRelativePath(abs_input_pdb_path_);
  94  E :      output_dll_path_ = temp_dir_.Append(input_dll_path_.BaseName());
  95  E :      output_pdb_path_ = temp_dir_.Append(input_pdb_path_.BaseName());
  96    :  
  97    :      // Point the application at the test's command-line, IO streams and mock
  98    :      // machinery.
  99  E :      test_app_.set_command_line(&cmd_line_);
 100  E :      test_app_.set_in(in());
 101  E :      test_app_.set_out(out());
 102  E :      test_app_.set_err(err());
 103  E :    }
 104    :  
 105    :    // Stashes the current log-level before each test instance and restores it
 106    :    // after each test completes.
 107    :    testing::ScopedLogLevelSaver log_level_saver;
 108    :  
 109    :    // @name The application under test.
 110    :    // @{
 111    :    TestApp test_app_;
 112    :    TestApp::Implementation& test_impl_;
 113    :    FilePath temp_dir_;
 114    :    FilePath stdin_path_;
 115    :    FilePath stdout_path_;
 116    :    FilePath stderr_path_;
 117    :    // @}
 118    :  
 119    :    // @name Command-line and parameters.
 120    :    // @{
 121    :    CommandLine cmd_line_;
 122    :    FilePath input_dll_path_;
 123    :    FilePath input_pdb_path_;
 124    :    FilePath output_dll_path_;
 125    :    FilePath output_pdb_path_;
 126    :    // @}
 127    :  
 128    :    // @name Expected final values of input parameters.
 129    :    // @{
 130    :    FilePath abs_input_dll_path_;
 131    :    FilePath abs_input_pdb_path_;
 132    :    // @}
 133    :  };
 134    :  
 135    :  }  // namespace
 136    :  
 137  E :  TEST_F(InstrumentAppTest, GetHelp) {
 138  E :    cmd_line_.AppendSwitch("help");
 139  E :    ASSERT_FALSE(test_impl_.ParseCommandLine(&cmd_line_));
 140  E :  }
 141    :  
 142  E :  TEST_F(InstrumentAppTest, EmptyCommandLineFails) {
 143  E :    ASSERT_FALSE(test_impl_.ParseCommandLine(&cmd_line_));
 144  E :  }
 145    :  
 146  E :  TEST_F(InstrumentAppTest, ParseWithNoInputImageFails) {
 147  E :    cmd_line_.AppendSwitchPath("output-image", output_dll_path_);
 148    :  
 149  E :    ASSERT_FALSE(test_impl_.ParseCommandLine(&cmd_line_));
 150  E :  }
 151    :  
 152  E :  TEST_F(InstrumentAppTest, ParseWithNoOutputImageFails) {
 153  E :    cmd_line_.AppendSwitchPath("input-image", input_dll_path_);
 154    :  
 155  E :    ASSERT_FALSE(test_impl_.ParseCommandLine(&cmd_line_));
 156  E :  }
 157    :  
 158  E :  TEST_F(InstrumentAppTest, ParseMinimalAsan) {
 159  E :    cmd_line_.AppendSwitchASCII("mode", "ASAN");
 160  E :    cmd_line_.AppendSwitchPath("input-image", input_dll_path_);
 161  E :    cmd_line_.AppendSwitchPath("output-image", output_dll_path_);
 162    :  
 163  E :    EXPECT_TRUE(test_impl_.ParseCommandLine(&cmd_line_));
 164    :  
 165  E :    EXPECT_EQ(InstrumentApp::kInstrumentAsanMode, test_impl_.mode_);
 166  E :    EXPECT_EQ(abs_input_dll_path_, test_impl_.input_dll_path_);
 167  E :    EXPECT_EQ(output_dll_path_, test_impl_.output_dll_path_);
 168  E :    EXPECT_TRUE(test_impl_.client_dll_.empty());
 169  E :    EXPECT_FALSE(test_impl_.allow_overwrite_);
 170  E :    EXPECT_FALSE(test_impl_.no_augment_pdb_);
 171  E :    EXPECT_FALSE(test_impl_.no_strip_strings_);
 172  E :    EXPECT_FALSE(test_impl_.debug_friendly_);
 173  E :  }
 174    :  
 175  E :  TEST_F(InstrumentAppTest, ParseFullAsan) {
 176  E :    cmd_line_.AppendSwitchASCII("mode", "ASAN");
 177  E :    cmd_line_.AppendSwitchPath("input-image", input_dll_path_);
 178  E :    cmd_line_.AppendSwitchPath("output-image", output_dll_path_);
 179  E :    cmd_line_.AppendSwitchASCII("agent", "foo.dll");
 180  E :    cmd_line_.AppendSwitch("debug-friendly");
 181  E :    cmd_line_.AppendSwitchPath("input-pdb", input_pdb_path_);
 182  E :    cmd_line_.AppendSwitch("no-augment-pdb");
 183  E :    cmd_line_.AppendSwitch("no-strip-strings");
 184  E :    cmd_line_.AppendSwitchPath("output-pdb", output_pdb_path_);
 185  E :    cmd_line_.AppendSwitch("overwrite");
 186    :  
 187  E :    EXPECT_TRUE(test_impl_.ParseCommandLine(&cmd_line_));
 188    :  
 189  E :    EXPECT_EQ(InstrumentApp::kInstrumentAsanMode, test_impl_.mode_);
 190  E :    EXPECT_EQ(abs_input_dll_path_, test_impl_.input_dll_path_);
 191  E :    EXPECT_EQ(output_dll_path_, test_impl_.output_dll_path_);
 192  E :    EXPECT_EQ(abs_input_pdb_path_, test_impl_.input_pdb_path_);
 193  E :    EXPECT_EQ(output_pdb_path_, test_impl_.output_pdb_path_);
 194  E :    EXPECT_TRUE(test_impl_.client_dll_.empty());
 195  E :    EXPECT_TRUE(test_impl_.allow_overwrite_);
 196  E :    EXPECT_TRUE(test_impl_.no_augment_pdb_);
 197  E :    EXPECT_TRUE(test_impl_.no_strip_strings_);
 198  E :    EXPECT_TRUE(test_impl_.debug_friendly_);
 199  E :  }
 200    :  
 201  E :  TEST_F(InstrumentAppTest, ParseMinimalCallTrace) {
 202  E :    cmd_line_.AppendSwitchASCII("mode", "CALLTRACE");
 203  E :    cmd_line_.AppendSwitchPath("input-image", input_dll_path_);
 204  E :    cmd_line_.AppendSwitchPath("output-image", output_dll_path_);
 205    :  
 206  E :    EXPECT_TRUE(test_impl_.ParseCommandLine(&cmd_line_));
 207    :  
 208  E :    EXPECT_EQ(InstrumentApp::kInstrumentCallTraceMode, test_impl_.mode_);
 209  E :    EXPECT_EQ(abs_input_dll_path_, test_impl_.input_dll_path_);
 210  E :    EXPECT_EQ(output_dll_path_, test_impl_.output_dll_path_);
 211    :    EXPECT_EQ(std::string(InstrumentApp::kCallTraceClientDllRpc),
 212  E :              test_impl_.client_dll_);
 213  E :    EXPECT_FALSE(test_impl_.allow_overwrite_);
 214  E :    EXPECT_FALSE(test_impl_.no_augment_pdb_);
 215  E :    EXPECT_FALSE(test_impl_.no_strip_strings_);
 216  E :    EXPECT_FALSE(test_impl_.debug_friendly_);
 217  E :    EXPECT_FALSE(test_impl_.thunk_imports_);
 218  E :    EXPECT_TRUE(test_impl_.instrument_unsafe_references_);
 219  E :    EXPECT_FALSE(test_impl_.module_entry_only_);
 220  E :  }
 221    :  
 222  E :  TEST_F(InstrumentAppTest, ParseFullCallTrace) {
 223  E :    cmd_line_.AppendSwitchASCII("mode", "CALLTRACE");
 224  E :    cmd_line_.AppendSwitchPath("input-image", input_dll_path_);
 225  E :    cmd_line_.AppendSwitchPath("output-image", output_dll_path_);
 226    :  
 227  E :    cmd_line_.AppendSwitchASCII("agent", "foo.dll");
 228  E :    cmd_line_.AppendSwitch("debug-friendly");
 229  E :    cmd_line_.AppendSwitchPath("input-pdb", input_pdb_path_);
 230  E :    cmd_line_.AppendSwitch("no-augment-pdb");
 231  E :    cmd_line_.AppendSwitch("no-strip-strings");
 232  E :    cmd_line_.AppendSwitchPath("output-pdb", output_pdb_path_);
 233  E :    cmd_line_.AppendSwitch("overwrite");
 234  E :    cmd_line_.AppendSwitch("instrument-imports");
 235  E :    cmd_line_.AppendSwitch("module-entry-only");
 236  E :    cmd_line_.AppendSwitch("no-unsafe-refs");
 237    :  
 238  E :    EXPECT_TRUE(test_impl_.ParseCommandLine(&cmd_line_));
 239    :  
 240  E :    EXPECT_EQ(InstrumentApp::kInstrumentCallTraceMode, test_impl_.mode_);
 241  E :    EXPECT_EQ(abs_input_dll_path_, test_impl_.input_dll_path_);
 242  E :    EXPECT_EQ(output_dll_path_, test_impl_.output_dll_path_);
 243  E :    EXPECT_EQ(abs_input_pdb_path_, test_impl_.input_pdb_path_);
 244  E :    EXPECT_EQ(output_pdb_path_, test_impl_.output_pdb_path_);
 245  E :    EXPECT_EQ(std::string("foo.dll"), test_impl_.client_dll_);
 246  E :    EXPECT_TRUE(test_impl_.allow_overwrite_);
 247  E :    EXPECT_TRUE(test_impl_.no_augment_pdb_);
 248  E :    EXPECT_TRUE(test_impl_.no_strip_strings_);
 249  E :    EXPECT_TRUE(test_impl_.debug_friendly_);
 250  E :    EXPECT_TRUE(test_impl_.thunk_imports_);
 251  E :    EXPECT_FALSE(test_impl_.instrument_unsafe_references_);
 252  E :    EXPECT_TRUE(test_impl_.module_entry_only_);
 253  E :  }
 254    :  
 255  E :  TEST_F(InstrumentAppTest, ParseMinimalCoverage) {
 256  E :    cmd_line_.AppendSwitchASCII("mode", "COVERAGE");
 257  E :    cmd_line_.AppendSwitchPath("input-image", input_dll_path_);
 258  E :    cmd_line_.AppendSwitchPath("output-image", output_dll_path_);
 259    :  
 260  E :    EXPECT_TRUE(test_impl_.ParseCommandLine(&cmd_line_));
 261    :  
 262  E :    EXPECT_EQ(InstrumentApp::kInstrumentCoverageMode, test_impl_.mode_);
 263  E :    EXPECT_EQ(abs_input_dll_path_, test_impl_.input_dll_path_);
 264  E :    EXPECT_EQ(output_dll_path_, test_impl_.output_dll_path_);
 265    :    EXPECT_EQ(std::string(InstrumentApp::kCallTraceClientDllCoverage),
 266  E :              test_impl_.client_dll_);
 267  E :    EXPECT_FALSE(test_impl_.allow_overwrite_);
 268  E :    EXPECT_FALSE(test_impl_.no_augment_pdb_);
 269  E :    EXPECT_FALSE(test_impl_.no_strip_strings_);
 270  E :    EXPECT_FALSE(test_impl_.debug_friendly_);
 271  E :  }
 272    :  
 273  E :  TEST_F(InstrumentAppTest, ParseFullCoverage) {
 274  E :    cmd_line_.AppendSwitchASCII("mode", "COVERAGE");
 275  E :    cmd_line_.AppendSwitchPath("input-image", input_dll_path_);
 276  E :    cmd_line_.AppendSwitchPath("output-image", output_dll_path_);
 277  E :    cmd_line_.AppendSwitchASCII("agent", "foo.dll");
 278  E :    cmd_line_.AppendSwitch("debug-friendly");
 279  E :    cmd_line_.AppendSwitchPath("input-pdb", input_pdb_path_);
 280  E :    cmd_line_.AppendSwitch("no-augment-pdb");
 281  E :    cmd_line_.AppendSwitch("no-strip-strings");
 282  E :    cmd_line_.AppendSwitchPath("output-pdb", output_pdb_path_);
 283  E :    cmd_line_.AppendSwitch("overwrite");
 284    :  
 285  E :    EXPECT_TRUE(test_impl_.ParseCommandLine(&cmd_line_));
 286    :  
 287  E :    EXPECT_EQ(InstrumentApp::kInstrumentCoverageMode, test_impl_.mode_);
 288  E :    EXPECT_EQ(abs_input_dll_path_, test_impl_.input_dll_path_);
 289  E :    EXPECT_EQ(output_dll_path_, test_impl_.output_dll_path_);
 290  E :    EXPECT_EQ(abs_input_pdb_path_, test_impl_.input_pdb_path_);
 291  E :    EXPECT_EQ(output_pdb_path_, test_impl_.output_pdb_path_);
 292  E :    EXPECT_EQ(std::string("foo.dll"), test_impl_.client_dll_);
 293  E :    EXPECT_TRUE(test_impl_.allow_overwrite_);
 294  E :    EXPECT_TRUE(test_impl_.no_augment_pdb_);
 295  E :    EXPECT_TRUE(test_impl_.no_strip_strings_);
 296  E :    EXPECT_TRUE(test_impl_.debug_friendly_);
 297  E :  }
 298    :  
 299  E :  TEST_F(InstrumentAppTest, ParseMinimalProfiler) {
 300  E :    cmd_line_.AppendSwitchASCII("mode", "PROFILER");
 301  E :    cmd_line_.AppendSwitchPath("input-image", input_dll_path_);
 302  E :    cmd_line_.AppendSwitchPath("output-image", output_dll_path_);
 303    :  
 304  E :    EXPECT_TRUE(test_impl_.ParseCommandLine(&cmd_line_));
 305  E :    EXPECT_EQ(InstrumentApp::kInstrumentProfilerMode, test_impl_.mode_);
 306  E :    EXPECT_EQ(abs_input_dll_path_, test_impl_.input_dll_path_);
 307  E :    EXPECT_EQ(output_dll_path_, test_impl_.output_dll_path_);
 308    :  
 309    :    EXPECT_EQ(std::string(InstrumentApp::kCallTraceClientDllProfiler),
 310  E :              test_impl_.client_dll_);
 311    :  
 312  E :    EXPECT_FALSE(test_impl_.allow_overwrite_);
 313  E :    EXPECT_FALSE(test_impl_.no_augment_pdb_);
 314  E :    EXPECT_FALSE(test_impl_.no_strip_strings_);
 315  E :    EXPECT_FALSE(test_impl_.debug_friendly_);
 316  E :    EXPECT_FALSE(test_impl_.thunk_imports_);
 317  E :    EXPECT_FALSE(test_impl_.instrument_unsafe_references_);
 318  E :    EXPECT_FALSE(test_impl_.module_entry_only_);
 319  E :  }
 320    :  
 321  E :  TEST_F(InstrumentAppTest, ParseFullProfiler) {
 322  E :    cmd_line_.AppendSwitchASCII("mode", "PROFILER");
 323  E :    cmd_line_.AppendSwitchPath("input-image", input_dll_path_);
 324  E :    cmd_line_.AppendSwitchPath("output-image", output_dll_path_);
 325  E :    cmd_line_.AppendSwitchASCII("agent", "foo.dll");
 326  E :    cmd_line_.AppendSwitch("debug-friendly");
 327  E :    cmd_line_.AppendSwitchPath("input-pdb", input_pdb_path_);
 328  E :    cmd_line_.AppendSwitch("no-augment-pdb");
 329  E :    cmd_line_.AppendSwitch("no-strip-strings");
 330  E :    cmd_line_.AppendSwitchPath("output-pdb", output_pdb_path_);
 331  E :    cmd_line_.AppendSwitch("overwrite");
 332  E :    cmd_line_.AppendSwitch("instrument-imports");
 333    :  
 334  E :    EXPECT_TRUE(test_impl_.ParseCommandLine(&cmd_line_));
 335    :  
 336  E :    EXPECT_EQ(InstrumentApp::kInstrumentProfilerMode, test_impl_.mode_);
 337  E :    EXPECT_EQ(abs_input_dll_path_, test_impl_.input_dll_path_);
 338  E :    EXPECT_EQ(output_dll_path_, test_impl_.output_dll_path_);
 339  E :    EXPECT_EQ(abs_input_pdb_path_, test_impl_.input_pdb_path_);
 340  E :    EXPECT_EQ(output_pdb_path_, test_impl_.output_pdb_path_);
 341  E :    EXPECT_EQ(std::string("foo.dll"), test_impl_.client_dll_);
 342  E :    EXPECT_TRUE(test_impl_.allow_overwrite_);
 343  E :    EXPECT_TRUE(test_impl_.no_augment_pdb_);
 344  E :    EXPECT_TRUE(test_impl_.no_strip_strings_);
 345  E :    EXPECT_TRUE(test_impl_.debug_friendly_);
 346  E :    EXPECT_TRUE(test_impl_.thunk_imports_);
 347  E :  }
 348    :  
 349  E :  TEST_F(InstrumentAppTest, DeprecatedParseNoModeSpecifyDlls) {
 350  E :    cmd_line_.AppendSwitchPath("input-dll", input_dll_path_);
 351  E :    cmd_line_.AppendSwitchPath("output-dll", output_dll_path_);
 352    :  
 353  E :    EXPECT_TRUE(test_impl_.ParseCommandLine(&cmd_line_));
 354  E :    EXPECT_EQ(InstrumentApp::kInstrumentCallTraceMode, test_impl_.mode_);
 355  E :    EXPECT_EQ(abs_input_dll_path_, test_impl_.input_dll_path_);
 356  E :    EXPECT_EQ(output_dll_path_, test_impl_.output_dll_path_);
 357    :  
 358    :    EXPECT_EQ(std::string(InstrumentApp::kCallTraceClientDllRpc),
 359  E :              test_impl_.client_dll_);
 360    :  
 361  E :    EXPECT_FALSE(test_impl_.allow_overwrite_);
 362  E :    EXPECT_FALSE(test_impl_.no_augment_pdb_);
 363  E :    EXPECT_FALSE(test_impl_.no_strip_strings_);
 364  E :    EXPECT_FALSE(test_impl_.debug_friendly_);
 365  E :    EXPECT_FALSE(test_impl_.thunk_imports_);
 366  E :    EXPECT_TRUE(test_impl_.instrument_unsafe_references_);
 367  E :    EXPECT_FALSE(test_impl_.module_entry_only_);
 368  E :  }
 369    :  
 370  E :  TEST_F(InstrumentAppTest, DeprecatedParseCallTraceClientRpc) {
 371  E :    cmd_line_.AppendSwitchASCII("call-trace-client", "RPC");
 372  E :    cmd_line_.AppendSwitchPath("input-dll", input_dll_path_);
 373  E :    cmd_line_.AppendSwitchPath("output-dll", output_dll_path_);
 374    :  
 375  E :    EXPECT_TRUE(test_impl_.ParseCommandLine(&cmd_line_));
 376  E :    EXPECT_EQ(InstrumentApp::kInstrumentCallTraceMode, test_impl_.mode_);
 377  E :    EXPECT_EQ(abs_input_dll_path_, test_impl_.input_dll_path_);
 378  E :    EXPECT_EQ(output_dll_path_, test_impl_.output_dll_path_);
 379    :  
 380    :    EXPECT_EQ(std::string(InstrumentApp::kCallTraceClientDllRpc),
 381  E :              test_impl_.client_dll_);
 382    :  
 383  E :    EXPECT_FALSE(test_impl_.allow_overwrite_);
 384  E :    EXPECT_FALSE(test_impl_.no_augment_pdb_);
 385  E :    EXPECT_FALSE(test_impl_.no_strip_strings_);
 386  E :    EXPECT_FALSE(test_impl_.debug_friendly_);
 387  E :    EXPECT_FALSE(test_impl_.thunk_imports_);
 388  E :    EXPECT_TRUE(test_impl_.instrument_unsafe_references_);
 389  E :    EXPECT_FALSE(test_impl_.module_entry_only_);
 390  E :  }
 391    :  
 392  E :  TEST_F(InstrumentAppTest, DeprecatedParseCallTraceClientProfiler) {
 393  E :    cmd_line_.AppendSwitchASCII("call-trace-client", "PROFILER");
 394  E :    cmd_line_.AppendSwitchPath("input-dll", input_dll_path_);
 395  E :    cmd_line_.AppendSwitchPath("output-dll", output_dll_path_);
 396    :  
 397  E :    EXPECT_TRUE(test_impl_.ParseCommandLine(&cmd_line_));
 398  E :    EXPECT_EQ(InstrumentApp::kInstrumentProfilerMode, test_impl_.mode_);
 399  E :    EXPECT_EQ(abs_input_dll_path_, test_impl_.input_dll_path_);
 400  E :    EXPECT_EQ(output_dll_path_, test_impl_.output_dll_path_);
 401    :  
 402    :    EXPECT_EQ(std::string(InstrumentApp::kCallTraceClientDllProfiler),
 403  E :              test_impl_.client_dll_);
 404    :  
 405  E :    EXPECT_FALSE(test_impl_.allow_overwrite_);
 406  E :    EXPECT_FALSE(test_impl_.no_augment_pdb_);
 407  E :    EXPECT_FALSE(test_impl_.no_strip_strings_);
 408  E :    EXPECT_FALSE(test_impl_.debug_friendly_);
 409  E :    EXPECT_FALSE(test_impl_.thunk_imports_);
 410  E :    EXPECT_FALSE(test_impl_.instrument_unsafe_references_);
 411  E :    EXPECT_FALSE(test_impl_.module_entry_only_);
 412  E :  }
 413    :  
 414  E :  TEST_F(InstrumentAppTest, DeprecatedParseCallTraceClientOtherDll) {
 415  E :    cmd_line_.AppendSwitchASCII("call-trace-client", "foo.dll");
 416  E :    cmd_line_.AppendSwitchPath("input-dll", input_dll_path_);
 417  E :    cmd_line_.AppendSwitchPath("output-dll", output_dll_path_);
 418    :  
 419  E :    EXPECT_TRUE(test_impl_.ParseCommandLine(&cmd_line_));
 420  E :    EXPECT_EQ(InstrumentApp::kInstrumentCallTraceMode, test_impl_.mode_);
 421  E :    EXPECT_EQ(abs_input_dll_path_, test_impl_.input_dll_path_);
 422  E :    EXPECT_EQ(output_dll_path_, test_impl_.output_dll_path_);
 423    :  
 424    :    EXPECT_EQ(std::string("foo.dll"),
 425  E :              test_impl_.client_dll_);
 426    :  
 427  E :    EXPECT_FALSE(test_impl_.allow_overwrite_);
 428  E :    EXPECT_FALSE(test_impl_.no_augment_pdb_);
 429  E :    EXPECT_FALSE(test_impl_.no_strip_strings_);
 430  E :    EXPECT_FALSE(test_impl_.debug_friendly_);
 431  E :    EXPECT_FALSE(test_impl_.thunk_imports_);
 432  E :    EXPECT_TRUE(test_impl_.instrument_unsafe_references_);
 433  E :    EXPECT_FALSE(test_impl_.module_entry_only_);
 434  E :  }
 435    :  
 436  E :  TEST_F(InstrumentAppTest, InstrumentFailsInit) {
 437  E :    cmd_line_.AppendSwitchPath("input-image", input_dll_path_);
 438  E :    cmd_line_.AppendSwitchPath("output-image", output_dll_path_);
 439    :  
 440    :    EXPECT_CALL(test_impl_.mock_relinker_, Init())
 441  E :        .WillOnce(Return(false));
 442    :  
 443  E :    EXPECT_EQ(1, test_app_.Run());
 444  E :  }
 445    :  
 446  E :  TEST_F(InstrumentAppTest, InstrumentFailsRelink) {
 447  E :    cmd_line_.AppendSwitchPath("input-image", input_dll_path_);
 448  E :    cmd_line_.AppendSwitchPath("output-image", output_dll_path_);
 449    :  
 450    :    EXPECT_CALL(test_impl_.mock_relinker_, Init())
 451  E :        .WillOnce(Return(true));
 452    :  
 453    :    EXPECT_CALL(test_impl_.mock_relinker_, Relink())
 454  E :        .WillOnce(Return(false));
 455    :  
 456  E :    EXPECT_EQ(1, test_app_.Run());
 457  E :  }
 458    :  
 459  E :  TEST_F(InstrumentAppTest, Instrument) {
 460  E :    cmd_line_.AppendSwitchPath("input-image", input_dll_path_);
 461  E :    cmd_line_.AppendSwitchPath("output-image", output_dll_path_);
 462    :  
 463    :    EXPECT_CALL(test_impl_.mock_relinker_, Init())
 464  E :        .WillOnce(Return(true));
 465    :  
 466    :    EXPECT_CALL(test_impl_.mock_relinker_, Relink())
 467  E :        .WillOnce(Return(true));
 468    :  
 469  E :    ASSERT_EQ(0, test_app_.Run());
 470  E :  }
 471    :  
 472    :  }  // namespace pe

Coverage information generated Thu Sep 06 11:30:46 2012.