Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: syzygy/integration_tests/instrument_integration_test.cc

Issue 2984303002: Split the testing class into two. (Closed)
Patch Set: Removed parametrization with Clang until the necessary fixes are done. Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | syzygy/pe/unittest_util.h » ('j') | syzygy/pe/unittest_util.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 Google Inc. All Rights Reserved. 1 // Copyright 2013 Google Inc. All Rights Reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with 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 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 ModuleInformationSet; 340 ModuleInformationSet;
341 341
342 using grinder::grinders::ProfileGrinder::PartData; 342 using grinder::grinders::ProfileGrinder::PartData;
343 using grinder::grinders::ProfileGrinder::PartDataMap; 343 using grinder::grinders::ProfileGrinder::PartDataMap;
344 using grinder::grinders::ProfileGrinder::PartKey; 344 using grinder::grinders::ProfileGrinder::PartKey;
345 345
346 using grinder::grinders::ProfileGrinder::modules_; 346 using grinder::grinders::ProfileGrinder::modules_;
347 using grinder::grinders::ProfileGrinder::parts_; 347 using grinder::grinders::ProfileGrinder::parts_;
348 }; 348 };
349 349
350 enum InstrumentationMode {
351 SYZYGY,
352 CLANG,
353 };
354
350 class LenientInstrumentAppIntegrationTest : public testing::PELibUnitTest { 355 class LenientInstrumentAppIntegrationTest : public testing::PELibUnitTest {
351 public: 356 public:
352 typedef testing::PELibUnitTest Super; 357 typedef testing::PELibUnitTest Super;
353 358
354 // A callback that gets hooked up to catch exceptions in the RTL. 359 // A callback that gets hooked up to catch exceptions in the RTL.
355 MOCK_METHOD1(OnExceptionCallback, void(EXCEPTION_POINTERS*)); 360 MOCK_METHOD1(OnExceptionCallback, void(EXCEPTION_POINTERS*));
356 361
357 LenientInstrumentAppIntegrationTest() 362 LenientInstrumentAppIntegrationTest()
358 : cmd_line_(base::FilePath(L"instrument.exe")), 363 : cmd_line_(base::FilePath(L"instrument.exe")),
359 test_impl_(test_app_.implementation()), 364 test_impl_(test_app_.implementation()),
(...skipping 12 matching lines...) Expand all
372 this->CreateTemporaryDir(&temp_dir_); 377 this->CreateTemporaryDir(&temp_dir_);
373 stdin_path_ = temp_dir_.Append(L"NUL"); 378 stdin_path_ = temp_dir_.Append(L"NUL");
374 stdout_path_ = temp_dir_.Append(L"stdout.txt"); 379 stdout_path_ = temp_dir_.Append(L"stdout.txt");
375 stderr_path_ = temp_dir_.Append(L"stderr.txt"); 380 stderr_path_ = temp_dir_.Append(L"stderr.txt");
376 InitStreams(stdin_path_, stdout_path_, stderr_path_); 381 InitStreams(stdin_path_, stdout_path_, stderr_path_);
377 382
378 // Initialize the (potential) input and output path values. 383 // Initialize the (potential) input and output path values.
379 base::FilePath abs_input_dll_path_ = 384 base::FilePath abs_input_dll_path_ =
380 testing::GetExeRelativePath(testing::kIntegrationTestsDllName); 385 testing::GetExeRelativePath(testing::kIntegrationTestsDllName);
381 input_dll_path_ = testing::GetRelativePath(abs_input_dll_path_); 386 input_dll_path_ = testing::GetRelativePath(abs_input_dll_path_);
382 output_dll_path_ = temp_dir_.Append(input_dll_path_.BaseName()); 387 test_dll_path_ = temp_dir_.Append(input_dll_path_.BaseName());
Sébastien Marchand 2017/08/01 19:27:36 Don't set this here, as it'll be invalid for the C
njanevsk 2017/08/03 01:23:21 Done.
383 388
384 // Initialize call_service output directory for produced trace files. 389 // Initialize call_service output directory for produced trace files.
385 traces_dir_ = temp_dir_.Append(L"traces"); 390 traces_dir_ = temp_dir_.Append(L"traces");
386 391
387 // Initialize call_service session id. 392 // Initialize call_service session id.
388 service_.SetEnvironment(); 393 service_.SetEnvironment();
389 394
390 ASSERT_NO_FATAL_FAILURE(ConfigureTestApp(&test_app_)); 395 ASSERT_NO_FATAL_FAILURE(ConfigureTestApp(&test_app_));
391 } 396 }
392 397
(...skipping 20 matching lines...) Expand all
413 void StopService() { 418 void StopService() {
414 service_.Stop(); 419 service_.Stop();
415 } 420 }
416 421
417 void UnloadDll() { 422 void UnloadDll() {
418 module_.Reset(NULL); 423 module_.Reset(NULL);
419 } 424 }
420 425
421 // Runs an instrumentation pass in the given mode and validates that the 426 // Runs an instrumentation pass in the given mode and validates that the
422 // resulting output DLL loads. 427 // resulting output DLL loads.
423 void EndToEndTest(const std::string& mode) { 428 void EndToEndTest(const std::string& mode,
424 cmd_line_.AppendSwitchPath("input-image", input_dll_path_); 429 InstrumentationMode instrumentation_mode) {
425 cmd_line_.AppendSwitchPath("output-image", output_dll_path_); 430 if (instrumentation_mode == SYZYGY) {
426 cmd_line_.AppendSwitchASCII("mode", mode); 431 cmd_line_.AppendSwitchPath("input-image", input_dll_path_);
432 cmd_line_.AppendSwitchPath("output-image", test_dll_path_);
433 cmd_line_.AppendSwitchASCII("mode", mode);
427 434
428 // Create the instrumented DLL. 435 // Create the instrumented DLL.
429 application::Application<instrument::InstrumentApp> app; 436 application::Application<instrument::InstrumentApp> app;
430 ASSERT_NO_FATAL_FAILURE(ConfigureTestApp(&app)); 437 ASSERT_NO_FATAL_FAILURE(ConfigureTestApp(&app));
431 ASSERT_EQ(0, app.Run()); 438 ASSERT_EQ(0, app.Run());
432 439 } else if (instrumentation_mode == CLANG) {
Sébastien Marchand 2017/08/01 19:27:36 You don't need this yet as it's not instantiated.
njanevsk 2017/08/03 01:23:21 Done.
440 test_dll_path_ =
441 testing::GetExeRelativePath(testing::kIntegrationTestsClangDllName);
442 printf("%s\n", test_dll_path_.AsUTF8Unsafe().c_str());
Sébastien Marchand 2017/08/01 19:27:36 Remove the debugging code.
njanevsk 2017/08/03 01:23:21 Done.
443 }
433 // Validate that the test dll loads post instrumentation. 444 // Validate that the test dll loads post instrumentation.
434 ASSERT_NO_FATAL_FAILURE(LoadTestDll(output_dll_path_, &module_)); 445 ASSERT_NO_FATAL_FAILURE(LoadTestDll(test_dll_path_, &module_));
435 } 446 }
436 447
437 // Invoke a test function inside test_dll by addressing it with a test id. 448 // Invoke a test function inside test_dll by addressing it with a test id.
438 // Returns the value resulting from the test function execution. 449 // Returns the value resulting from the test function execution.
439 unsigned int InvokeTestDllFunction(testing::EndToEndTestId test) { 450 unsigned int InvokeTestDllFunction(testing::EndToEndTestId test) {
440 // Load the exported 'function_name' function. 451 // Load the exported 'function_name' function.
441 typedef unsigned int (CALLBACK* TestDllFuncs)(unsigned int); 452 typedef unsigned int (CALLBACK* TestDllFuncs)(unsigned int);
442 TestDllFuncs func = reinterpret_cast<TestDllFuncs>( 453 TestDllFuncs func = reinterpret_cast<TestDllFuncs>(
443 ::GetProcAddress(module_, "EndToEndTest")); 454 ::GetProcAddress(module_, "EndToEndTest"));
444 DCHECK(func != NULL); 455 DCHECK(func != NULL);
445 456
446 // Invoke it, and returns its value. 457 // Invoke it, and returns its value.
447 return func(test); 458 return func(test);
448 } 459 }
449 460
450 int RunOutOfProcessFunction(const base::string16& harness_name, 461 int RunOutOfProcessFunction(const base::string16& harness_name,
451 testing::EndToEndTestId test, 462 testing::EndToEndTestId test,
452 bool expect_exception) { 463 bool expect_exception) {
453 base::FilePath harness = testing::GetExeRelativePath(harness_name.c_str()); 464 base::FilePath harness = testing::GetExeRelativePath(harness_name.c_str());
454 base::CommandLine cmd_line(harness); 465 base::CommandLine cmd_line(harness);
455 cmd_line.AppendSwitchASCII("test", base::StringPrintf("%d", test)); 466 cmd_line.AppendSwitchASCII("test", base::StringPrintf("%d", test));
456 cmd_line.AppendSwitchPath("dll", output_dll_path_); 467 cmd_line.AppendSwitchPath("dll", test_dll_path_);
457 if (expect_exception) 468 if (expect_exception)
458 cmd_line.AppendSwitch("expect-exception"); 469 cmd_line.AppendSwitch("expect-exception");
459 470
460 base::LaunchOptions options; 471 base::LaunchOptions options;
461 base::Process process = base::LaunchProcess(cmd_line, options); 472 base::Process process = base::LaunchProcess(cmd_line, options);
462 EXPECT_TRUE(process.IsValid()); 473 EXPECT_TRUE(process.IsValid());
463 474
464 int exit_code = 0; 475 int exit_code = 0;
465 EXPECT_TRUE(process.WaitForExit(&exit_code)); 476 EXPECT_TRUE(process.WaitForExit(&exit_code));
466 return exit_code; 477 return exit_code;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 // Memory acessors in the dynamic RTL must be redirected after first 579 // Memory acessors in the dynamic RTL must be redirected after first
569 // use of the function. If the dynamic RTL doesn't redirect the imports 580 // use of the function. If the dynamic RTL doesn't redirect the imports
570 // everything will still work, just terribly slowly. 581 // everything will still work, just terribly slowly.
571 ASSERT_NE(rtl_export_fn, imported_fn); 582 ASSERT_NE(rtl_export_fn, imported_fn);
572 } else { 583 } else {
573 ASSERT_EQ(rtl_export_fn, imported_fn); 584 ASSERT_EQ(rtl_export_fn, imported_fn);
574 } 585 }
575 } 586 }
576 } 587 }
577 588
578 void EndToEndCheckTestDll() { 589 void EndToEndCheckTestDll(InstrumentationMode instrumentation_mode) {
579 // Validate that behavior is unchanged after instrumentation. 590 if (instrumentation_mode == SYZYGY) {
Sébastien Marchand 2017/08/01 19:27:36 I don't sure that you need this check for now? You
njanevsk 2017/08/03 01:23:21 Done.
580 EXPECT_EQ(0xfff80200, InvokeTestDllFunction(testing::kArrayComputation1)); 591 // Validate that behavior is unchanged after instrumentation.
581 EXPECT_EQ(0x00000200, InvokeTestDllFunction(testing::kArrayComputation2)); 592 EXPECT_EQ(0xfff80200, InvokeTestDllFunction(testing::kArrayComputation1));
593 EXPECT_EQ(0x00000200, InvokeTestDllFunction(testing::kArrayComputation2));
594 }
582 } 595 }
583 596
584 bool AsanErrorCheck(testing::EndToEndTestId test, 597 bool AsanErrorCheck(testing::EndToEndTestId test,
585 BadAccessKind kind, 598 BadAccessKind kind,
586 AccessMode mode, 599 AccessMode mode,
587 size_t size, 600 size_t size,
588 size_t max_tries, 601 size_t max_tries,
589 bool unload) { 602 bool unload) {
590 // A small selection of tests can fail due to hash collisions. These are 603 // A small selection of tests can fail due to hash collisions. These are
591 // run repeatedly and expected to pass at least once. Every other test is 604 // run repeatedly and expected to pass at least once. Every other test is
(...skipping 18 matching lines...) Expand all
610 InvokeTestDllFunction(test); 623 InvokeTestDllFunction(test);
611 if (unload) 624 if (unload)
612 UnloadDll(); 625 UnloadDll();
613 626
614 // If this appears to have failed then retry it for all but the last 627 // If this appears to have failed then retry it for all but the last
615 // attempt. Some tests have a non-zero chance of failure, but their 628 // attempt. Some tests have a non-zero chance of failure, but their
616 // chances of failing repeatedly are infinitesimally small. 629 // chances of failing repeatedly are infinitesimally small.
617 if (asan_error_count == 0 && i + 1 < max_tries) { 630 if (asan_error_count == 0 && i + 1 < max_tries) {
618 // If the module was unloaded and the test is retrying, then reload it. 631 // If the module was unloaded and the test is retrying, then reload it.
619 if (unload) 632 if (unload)
620 EXPECT_NO_FATAL_FAILURE(LoadTestDll(output_dll_path_, &module_)); 633 EXPECT_NO_FATAL_FAILURE(LoadTestDll(test_dll_path_, &module_));
621 continue; 634 continue;
622 } 635 }
623 636
624 if (asan_error_count == 0 || 637 if (asan_error_count == 0 ||
625 last_asan_error.error_type != kind || 638 last_asan_error.error_type != kind ||
626 last_asan_error.access_mode != mode || 639 last_asan_error.access_mode != mode ||
627 last_asan_error.access_size != size) { 640 last_asan_error.access_size != size) {
628 return false; 641 return false;
629 } 642 }
630 break; 643 break;
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 886
874 void AsanLargeBlockHeapTests(bool expect_exception) { 887 void AsanLargeBlockHeapTests(bool expect_exception) {
875 OutOfProcessAsanErrorCheckAndValidateLog( 888 OutOfProcessAsanErrorCheckAndValidateLog(
876 testing::kAsanReadLargeAllocationTrailerBeforeFree, expect_exception, 889 testing::kAsanReadLargeAllocationTrailerBeforeFree, expect_exception,
877 kAsanAccessViolationLog, kAsanHeapBufferOverflow); 890 kAsanAccessViolationLog, kAsanHeapBufferOverflow);
878 OutOfProcessAsanErrorCheckAndValidateLog( 891 OutOfProcessAsanErrorCheckAndValidateLog(
879 testing::kAsanReadLargeAllocationBodyAfterFree, true, 892 testing::kAsanReadLargeAllocationBodyAfterFree, true,
880 kAsanAccessViolationLog, kAsanHeapUseAfterFree); 893 kAsanAccessViolationLog, kAsanHeapUseAfterFree);
881 } 894 }
882 895
883 void AsanZebraHeapTest(bool enabled);
Sébastien Marchand 2017/08/01 19:27:36 Don't remove this function.
njanevsk 2017/08/03 01:23:21 I haven't removed it. I moved it to the Parametriz
Sébastien Marchand 2017/08/03 18:12:59 Why just this one and not the other Asan*Test func
Sébastien Marchand 2017/08/03 20:44:31 Ha, I just realized that this depends on some thin
Sébastien Marchand 2017/08/03 20:46:03 (the body of the function or the tests, it just fe
884
885 void BBEntryInvokeTestDll() { 896 void BBEntryInvokeTestDll() {
886 EXPECT_EQ(42, InvokeTestDllFunction(testing::kBBEntryCallOnce)); 897 EXPECT_EQ(42, InvokeTestDllFunction(testing::kBBEntryCallOnce));
887 EXPECT_EQ(42, InvokeTestDllFunction(testing::kBBEntryCallTree)); 898 EXPECT_EQ(42, InvokeTestDllFunction(testing::kBBEntryCallTree));
888 EXPECT_EQ(42, InvokeTestDllFunction(testing::kBBEntryCallRecursive)); 899 EXPECT_EQ(42, InvokeTestDllFunction(testing::kBBEntryCallRecursive));
889 } 900 }
890 901
891 void ProfileInvokeTestDll() { 902 void ProfileInvokeTestDll() {
892 EXPECT_EQ(5, InvokeTestDllFunction(testing::kProfileCallExport)); 903 EXPECT_EQ(5, InvokeTestDllFunction(testing::kProfileCallExport));
893 // Save the RVA of one of the invoked functions for testing later. 904 // Save the RVA of one of the invoked functions for testing later.
894 get_my_rva_ = InvokeTestDllFunction(testing::kProfileGetMyRVA); 905 get_my_rva_ = InvokeTestDllFunction(testing::kProfileGetMyRVA);
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 TestingProfileGrinder::InvocationNodeMap::const_iterator node_it = 1183 TestingProfileGrinder::InvocationNodeMap::const_iterator node_it =
1173 data.nodes_.begin(); 1184 data.nodes_.begin();
1174 for (; node_it != data.nodes_.end(); ++node_it) { 1185 for (; node_it != data.nodes_.end(); ++node_it) {
1175 if (node_it->second.function.rva() == get_my_rva_) 1186 if (node_it->second.function.rva() == get_my_rva_)
1176 return; 1187 return;
1177 } 1188 }
1178 1189
1179 FAIL() << "Didn't find GetMyRVA function entry."; 1190 FAIL() << "Didn't find GetMyRVA function entry.";
1180 } 1191 }
1181 1192
1193 // Stashes the current log-level before each test instance and restores it
1194 // after each test completes.
1195 testing::ScopedLogLevelSaver log_level_saver;
1196
1197 // @name The application under test.
1198 // @{
1199 TestApp test_app_;
1200 TestApp::Implementation& test_impl_;
1201 base::FilePath temp_dir_;
1202 base::FilePath stdin_path_;
1203 base::FilePath stdout_path_;
1204 base::FilePath stderr_path_;
1205 // @}
1206
1207 // @name Command-line, parameters and outputs.
1208 // @{
1209 base::CommandLine cmd_line_;
1210 base::FilePath input_dll_path_;
1211 base::FilePath test_dll_path_;
1212 base::FilePath traces_dir_;
1213 // @}
1214
1215 // The test_dll module.
1216 testing::ScopedHMODULE module_;
1217
1218 // Our call trace service process instance.
1219 testing::CallTraceService service_;
1220
1221 // Decomposed image.
1222 pe::PEFile pe_image_;
1223 pe::ImageLayout image_layout_;
1224 block_graph::BlockGraph block_graph_;
1225 uint32_t get_my_rva_;
1226 };
1227
1228 class ParametrizedLenientInstrumentAppIntegrationTest
1229 : public LenientInstrumentAppIntegrationTest,
1230 public ::testing::WithParamInterface<InstrumentationMode> {
1231 public:
1232 void EndToEndTest(const std::string& mode) {
1233 LenientInstrumentAppIntegrationTest::EndToEndTest(mode, GetParam());
1234 }
1235 void AsanZebraHeapTest(bool enabled);
1236
1237 void EndToEndCheckTestDll() {
1238 LenientInstrumentAppIntegrationTest::EndToEndCheckTestDll(GetParam());
1239 }
1182 // Helper function to test the Asan symbolizer script. 1240 // Helper function to test the Asan symbolizer script.
1183 // 1241 //
1184 // It starts by running a test with the '--minidump_on_failure' flag turned 1242 // It starts by running a test with the '--minidump_on_failure' flag turned
1185 // on and then verify that the generated minidump can be symbolized correctly. 1243 // on and then verify that the generated minidump can be symbolized correctly.
1186 // 1244 //
1187 // @param test_id The test to run. 1245 // @param test_id The test to run.
1188 // @param kind The expected bad access kind. 1246 // @param kind The expected bad access kind.
1189 // @param mode The expected bad access mode. 1247 // @param mode The expected bad access mode.
1190 // @param size The expected bad access size. 1248 // @param size The expected bad access size.
1191 // @param expect_corrupt_heap Indicates if we expect the heap to be corrupt. 1249 // @param expect_corrupt_heap Indicates if we expect the heap to be corrupt.
1192 void AsanSymbolizerTest(testing::EndToEndTestId test_id, 1250 void AsanSymbolizerTest(testing::EndToEndTestId test_id,
Sébastien Marchand 2017/08/01 19:27:36 This could probably be moved to the parent class?
njanevsk 2017/08/03 01:23:21 Done.
1193 const char* kind, 1251 const char* kind,
1194 const char* mode, 1252 const char* mode,
1195 size_t size, 1253 size_t size,
1196 bool expect_corrupt_heap) { 1254 bool expect_corrupt_heap) {
1197 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1255 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
1198 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1256 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
1199 1257
1200 // Make sure that a minidump gets produced by the logger when a bug occurs. 1258 // Make sure that a minidump gets produced by the logger when a bug occurs.
1201 std::unique_ptr<base::Environment> env(base::Environment::Create()); 1259 std::unique_ptr<base::Environment> env(base::Environment::Create());
1202 ASSERT_NE(env.get(), nullptr); 1260 ASSERT_NE(env.get(), nullptr);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 EXPECT_TRUE(process.WaitForExit(&exit_code)); 1301 EXPECT_TRUE(process.WaitForExit(&exit_code));
1244 EXPECT_EQ(0u, exit_code); 1302 EXPECT_EQ(0u, exit_code);
1245 1303
1246 // Check if the minidump contains a valid protobuf. 1304 // Check if the minidump contains a valid protobuf.
1247 poirot::MinidumpProcessor poirot_processor( 1305 poirot::MinidumpProcessor poirot_processor(
1248 base::FilePath::FromUTF8Unsafe(minidump_path)); 1306 base::FilePath::FromUTF8Unsafe(minidump_path));
1249 EXPECT_TRUE(poirot_processor.ProcessDump()); 1307 EXPECT_TRUE(poirot_processor.ProcessDump());
1250 1308
1251 env->UnSetVar(::common::kSyzyAsanOptionsEnvVar); 1309 env->UnSetVar(::common::kSyzyAsanOptionsEnvVar);
1252 } 1310 }
1311 };
1253 1312
1254 // Stashes the current log-level before each test instance and restores it 1313 typedef testing::StrictMock<ParametrizedLenientInstrumentAppIntegrationTest>
1255 // after each test completes. 1314 ParametrizedInstrumentAppIntegrationTest;
1256 testing::ScopedLogLevelSaver log_level_saver;
1257 1315
1258 // @name The application under test.
1259 // @{
1260 TestApp test_app_;
1261 TestApp::Implementation& test_impl_;
1262 base::FilePath temp_dir_;
1263 base::FilePath stdin_path_;
1264 base::FilePath stdout_path_;
1265 base::FilePath stderr_path_;
1266 // @}
1267
1268 // @name Command-line, parameters and outputs.
1269 // @{
1270 base::CommandLine cmd_line_;
1271 base::FilePath input_dll_path_;
1272 base::FilePath output_dll_path_;
1273 base::FilePath traces_dir_;
1274 // @}
1275
1276 // The test_dll module.
1277 testing::ScopedHMODULE module_;
1278
1279 // Our call trace service process instance.
1280 testing::CallTraceService service_;
1281
1282 // Decomposed image.
1283 pe::PEFile pe_image_;
1284 pe::ImageLayout image_layout_;
1285 block_graph::BlockGraph block_graph_;
1286 uint32_t get_my_rva_;
1287 };
1288 typedef testing::StrictMock<LenientInstrumentAppIntegrationTest> 1316 typedef testing::StrictMock<LenientInstrumentAppIntegrationTest>
1289 InstrumentAppIntegrationTest; 1317 InstrumentAppIntegrationTest;
1290 1318
1291 typedef std::map<std::string, size_t> FunctionOffsetMap; 1319 typedef std::map<std::string, size_t> FunctionOffsetMap;
1292 1320
1293 // A utility transform for extracting call site offsets from blocks. 1321 // A utility transform for extracting call site offsets from blocks.
1294 // Used by GetCallOffsets and ZebraBlockHeap tests. 1322 // Used by GetCallOffsets and ZebraBlockHeap tests.
1295 class ExtractCallTransform 1323 class ExtractCallTransform
1296 : public block_graph::BasicBlockSubGraphTransformInterface { 1324 : public block_graph::BasicBlockSubGraphTransformInterface {
1297 public: 1325 public:
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 // Apply our dummy transform which simply extracts call addresses. 1391 // Apply our dummy transform which simply extracts call addresses.
1364 { 1392 {
1365 ExtractCallTransform bbtx(map); 1393 ExtractCallTransform bbtx(map);
1366 block_graph::transforms::ChainedBasicBlockTransforms tx; 1394 block_graph::transforms::ChainedBasicBlockTransforms tx;
1367 tx.AppendTransform(&bbtx); 1395 tx.AppendTransform(&bbtx);
1368 ASSERT_TRUE(block_graph::ApplyBlockGraphTransform( 1396 ASSERT_TRUE(block_graph::ApplyBlockGraphTransform(
1369 &tx, &policy, &bg, header)); 1397 &tx, &policy, &bg, header));
1370 } 1398 }
1371 } 1399 }
1372 1400
1373 void LenientInstrumentAppIntegrationTest::AsanZebraHeapTest(bool enabled) { 1401 void ParametrizedLenientInstrumentAppIntegrationTest::AsanZebraHeapTest(
1402 bool enabled) {
1374 // Find the offset of the call we want to instrument. 1403 // Find the offset of the call we want to instrument.
1375 static const char kTest1[] = 1404 static const char kTest1[] =
1376 "testing::AsanReadPageAllocationTrailerBeforeFree"; 1405 "testing::AsanReadPageAllocationTrailerBeforeFree";
1377 static const char kTest2[] = 1406 static const char kTest2[] =
1378 "testing::AsanWritePageAllocationBodyAfterFree"; 1407 "testing::AsanWritePageAllocationBodyAfterFree";
1379 FunctionOffsetMap map({{kTest1, -1}, {kTest2, -1}}); 1408 FunctionOffsetMap map({{kTest1, -1}, {kTest2, -1}});
1380 ASSERT_NO_FATAL_FAILURE(GetCallOffsets(input_dll_path_, &map)); 1409 ASSERT_NO_FATAL_FAILURE(GetCallOffsets(input_dll_path_, &map));
1381 1410
1382 // Create an allocation filter. 1411 // Create an allocation filter.
1383 base::FilePath filter_path = temp_dir_.AppendASCII("allocation_filter.json"); 1412 base::FilePath filter_path = temp_dir_.AppendASCII("allocation_filter.json");
(...skipping 16 matching lines...) Expand all
1400 OutOfProcessAsanErrorCheckAndValidateLog( 1429 OutOfProcessAsanErrorCheckAndValidateLog(
1401 testing::kAsanReadPageAllocationTrailerBeforeFreeAllocation, enabled, 1430 testing::kAsanReadPageAllocationTrailerBeforeFreeAllocation, enabled,
1402 kAsanAccessViolationLog, kAsanHeapBufferOverflow); 1431 kAsanAccessViolationLog, kAsanHeapBufferOverflow);
1403 OutOfProcessAsanErrorCheckAndValidateLog( 1432 OutOfProcessAsanErrorCheckAndValidateLog(
1404 testing::kAsanWritePageAllocationBodyAfterFree, enabled, 1433 testing::kAsanWritePageAllocationBodyAfterFree, enabled,
1405 kAsanAccessViolationLog, kAsanHeapUseAfterFree); 1434 kAsanAccessViolationLog, kAsanHeapUseAfterFree);
1406 } 1435 }
1407 1436
1408 } // namespace 1437 } // namespace
1409 1438
1410 TEST_F(InstrumentAppIntegrationTest, AsanEndToEnd) { 1439 TEST_P(ParametrizedInstrumentAppIntegrationTest, AsanEndToEnd) {
1411 // Disable the heap checking as this is implies touching all the shadow bytes 1440 // Disable the heap checking as this is implies touching all the shadow bytes
1412 // and this make those tests really slow. 1441 // and this make those tests really slow.
1413 cmd_line_.AppendSwitchASCII("asan-rtl-options", "--no_check_heap_on_failure"); 1442 cmd_line_.AppendSwitchASCII("asan-rtl-options", "--no_check_heap_on_failure");
1414 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1443 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
1415 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1444 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
1416 ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll()); 1445 ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll());
1417 ASSERT_NO_FATAL_FAILURE(CheckTestDllImportsRedirected()); 1446 ASSERT_NO_FATAL_FAILURE(CheckTestDllImportsRedirected());
1418 } 1447 }
1419 1448
1420 TEST_F(InstrumentAppIntegrationTest, AsanEndToEndNoLiveness) { 1449 TEST_P(ParametrizedInstrumentAppIntegrationTest, AsanEndToEndNoLiveness) {
1421 // Disable the heap checking as this is implies touching all the shadow bytes 1450 // Disable the heap checking as this is implies touching all the shadow bytes
1422 // and this make those tests really slow. 1451 // and this make those tests really slow.
1423 cmd_line_.AppendSwitchASCII("asan-rtl-options", "--no_check_heap_on_failure"); 1452 cmd_line_.AppendSwitchASCII("asan-rtl-options", "--no_check_heap_on_failure");
1424 cmd_line_.AppendSwitch("no-liveness-analysis"); 1453 cmd_line_.AppendSwitch("no-liveness-analysis");
1425 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1454 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
1426 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1455 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
1427 ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll()); 1456 ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll());
1428 } 1457 }
1429 1458
1430 TEST_F(InstrumentAppIntegrationTest, AsanEndToEndNoRedundancyAnalysis) { 1459 TEST_P(ParametrizedInstrumentAppIntegrationTest,
1460 AsanEndToEndNoRedundancyAnalysis) {
1431 // Disable the heap checking as this is implies touching all the shadow bytes 1461 // Disable the heap checking as this is implies touching all the shadow bytes
1432 // and this make those tests really slow. 1462 // and this make those tests really slow.
1433 cmd_line_.AppendSwitchASCII("asan-rtl-options", "--no_check_heap_on_failure"); 1463 cmd_line_.AppendSwitchASCII("asan-rtl-options", "--no_check_heap_on_failure");
1434 cmd_line_.AppendSwitch("no-redundancy-analysis"); 1464 cmd_line_.AppendSwitch("no-redundancy-analysis");
1435 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1465 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
1436 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1466 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
1437 ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll()); 1467 ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll());
1438 } 1468 }
1439 1469
1440 TEST_F(InstrumentAppIntegrationTest, AsanEndToEndNoFunctionInterceptors) { 1470 TEST_P(ParametrizedInstrumentAppIntegrationTest,
1471 AsanEndToEndNoFunctionInterceptors) {
1441 // Disable the heap checking as this is implies touching all the shadow bytes 1472 // Disable the heap checking as this is implies touching all the shadow bytes
1442 // and this make those tests really slow. 1473 // and this make those tests really slow.
1443 cmd_line_.AppendSwitchASCII("asan-rtl-options", "--no_check_heap_on_failure"); 1474 cmd_line_.AppendSwitchASCII("asan-rtl-options", "--no_check_heap_on_failure");
1444 cmd_line_.AppendSwitch("no-interceptors"); 1475 cmd_line_.AppendSwitch("no-interceptors");
1445 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1476 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
1446 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1477 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
1447 ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll()); 1478 ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll());
1448 } 1479 }
1449 1480
1450 TEST_F(InstrumentAppIntegrationTest, AsanEndToEndWithRtlOptions) { 1481 TEST_P(ParametrizedInstrumentAppIntegrationTest, AsanEndToEndWithRtlOptions) {
1451 cmd_line_.AppendSwitchASCII( 1482 cmd_line_.AppendSwitchASCII(
1452 "asan-rtl-options", 1483 "asan-rtl-options",
1453 "--quarantine_size=20000000 --quarantine_block_size=1000000 " 1484 "--quarantine_size=20000000 --quarantine_block_size=1000000 "
1454 "--no_check_heap_on_failure"); 1485 "--no_check_heap_on_failure");
1455 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1486 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
1456 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1487 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
1457 ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll()); 1488 ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll());
1458 1489
1459 // Get the active runtime and validate its parameters. 1490 // Get the active runtime and validate its parameters.
1460 agent::asan::AsanRuntime* runtime = GetActiveAsanRuntime(); 1491 agent::asan::AsanRuntime* runtime = GetActiveAsanRuntime();
1461 ASSERT_TRUE(runtime != NULL); 1492 ASSERT_TRUE(runtime != NULL);
1462 ASSERT_EQ(20000000u, runtime->params().quarantine_size); 1493 ASSERT_EQ(20000000u, runtime->params().quarantine_size);
1463 ASSERT_EQ(1000000u, runtime->params().quarantine_block_size); 1494 ASSERT_EQ(1000000u, runtime->params().quarantine_block_size);
1464 } 1495 }
1465 1496
1466 TEST_F(InstrumentAppIntegrationTest, 1497 TEST_P(ParametrizedInstrumentAppIntegrationTest,
1467 AsanEndToEndWithRtlOptionsOverrideWithEnvironment) { 1498 AsanEndToEndWithRtlOptionsOverrideWithEnvironment) {
1468 std::unique_ptr<base::Environment> env(base::Environment::Create()); 1499 std::unique_ptr<base::Environment> env(base::Environment::Create());
1469 ASSERT_NE(env.get(), nullptr); 1500 ASSERT_NE(env.get(), nullptr);
1470 env->SetVar(::common::kSyzyAsanOptionsEnvVar, 1501 env->SetVar(::common::kSyzyAsanOptionsEnvVar,
1471 "--quarantine_block_size=800000 --ignored_stack_ids=0x1 " 1502 "--quarantine_block_size=800000 --ignored_stack_ids=0x1 "
1472 "--no_check_heap_on_failure"); 1503 "--no_check_heap_on_failure");
1473 cmd_line_.AppendSwitchASCII( 1504 cmd_line_.AppendSwitchASCII(
1474 "asan-rtl-options", 1505 "asan-rtl-options",
1475 "--quarantine_size=20000000 --quarantine_block_size=1000000 " 1506 "--quarantine_size=20000000 --quarantine_block_size=1000000 "
1476 "--ignored_stack_ids=0x2"); 1507 "--ignored_stack_ids=0x2");
1477 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1508 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
1478 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1509 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
1479 ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll()); 1510 ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll());
1480 1511
1481 // Get the active runtime and validate its parameters. 1512 // Get the active runtime and validate its parameters.
1482 agent::asan::AsanRuntime* runtime = GetActiveAsanRuntime(); 1513 agent::asan::AsanRuntime* runtime = GetActiveAsanRuntime();
1483 ASSERT_TRUE(runtime != NULL); 1514 ASSERT_TRUE(runtime != NULL);
1484 ASSERT_EQ(20000000u, runtime->params().quarantine_size); 1515 ASSERT_EQ(20000000u, runtime->params().quarantine_size);
1485 ASSERT_EQ(800000u, runtime->params().quarantine_block_size); 1516 ASSERT_EQ(800000u, runtime->params().quarantine_block_size);
1486 ASSERT_THAT(runtime->params().ignored_stack_ids_set, 1517 ASSERT_THAT(runtime->params().ignored_stack_ids_set,
1487 testing::ElementsAre(0x1, 0x2)); 1518 testing::ElementsAre(0x1, 0x2));
1488 1519
1489 env->UnSetVar(::common::kSyzyAsanOptionsEnvVar); 1520 env->UnSetVar(::common::kSyzyAsanOptionsEnvVar);
1490 } 1521 }
1491 1522
1492 TEST_F(InstrumentAppIntegrationTest, FullOptimizedAsanEndToEnd) { 1523 TEST_P(ParametrizedInstrumentAppIntegrationTest, FullOptimizedAsanEndToEnd) {
1493 // Disable the heap checking as this implies touching all the shadow bytes 1524 // Disable the heap checking as this implies touching all the shadow bytes
1494 // and this make these tests really slow. 1525 // and this make these tests really slow.
1495 cmd_line_.AppendSwitchASCII("asan-rtl-options", "--no_check_heap_on_failure"); 1526 cmd_line_.AppendSwitchASCII("asan-rtl-options", "--no_check_heap_on_failure");
1496 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1527 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
1497 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1528 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
1498 ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll()); 1529 ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll());
1499 ASSERT_NO_FATAL_FAILURE(AsanErrorCheckInterceptedFunctions()); 1530 ASSERT_NO_FATAL_FAILURE(AsanErrorCheckInterceptedFunctions());
1500 } 1531 }
1501 1532
1502 TEST_F(InstrumentAppIntegrationTest, 1533 TEST_P(ParametrizedInstrumentAppIntegrationTest,
1503 AsanInvalidAccessWithCorruptAllocatedBlockHeader) { 1534 AsanInvalidAccessWithCorruptAllocatedBlockHeader) {
1504 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1535 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
1505 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1536 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
1506 OutOfProcessAsanErrorCheckAndValidateLog( 1537 OutOfProcessAsanErrorCheckAndValidateLog(
1507 testing::kAsanInvalidAccessWithCorruptAllocatedBlockHeader, true, 1538 testing::kAsanInvalidAccessWithCorruptAllocatedBlockHeader, true,
1508 kAsanCorruptHeap, NULL); 1539 kAsanCorruptHeap, NULL);
1509 } 1540 }
1510 1541
1511 TEST_F(InstrumentAppIntegrationTest, AsanOverflowCallsCrashForException) { 1542 TEST_P(ParametrizedInstrumentAppIntegrationTest,
1543 AsanOverflowCallsCrashForException) {
1512 // Asan-detected violations go through CrashForException if it is available. 1544 // Asan-detected violations go through CrashForException if it is available.
1513 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1545 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
1514 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1546 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
1515 int exit_code = 1547 int exit_code =
1516 RunOutOfProcessFunction(L"crash_for_exception_harness.exe", 1548 RunOutOfProcessFunction(L"crash_for_exception_harness.exe",
1517 testing::kAsanRead8BufferOverflow, true); 1549 testing::kAsanRead8BufferOverflow, true);
1518 EXPECT_EQ(kExeCrashForExceptionExitCode, exit_code); 1550 EXPECT_EQ(kExeCrashForExceptionExitCode, exit_code);
1519 } 1551 }
1520 1552
1521 TEST_F(InstrumentAppIntegrationTest, 1553 TEST_P(ParametrizedInstrumentAppIntegrationTest,
1522 AsanInvalidAccessWithCorruptAllocatedBlockTrailer) { 1554 AsanInvalidAccessWithCorruptAllocatedBlockTrailer) {
1523 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1555 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
1524 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1556 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
1525 OutOfProcessAsanErrorCheckAndValidateLog( 1557 OutOfProcessAsanErrorCheckAndValidateLog(
1526 testing::kAsanInvalidAccessWithCorruptAllocatedBlockTrailer, true, 1558 testing::kAsanInvalidAccessWithCorruptAllocatedBlockTrailer, true,
1527 kAsanCorruptHeap, NULL); 1559 kAsanCorruptHeap, NULL);
1528 } 1560 }
1529 1561
1530 TEST_F(InstrumentAppIntegrationTest, 1562 TEST_P(ParametrizedInstrumentAppIntegrationTest,
1531 AsanInvalidAccessWithCorruptFreedBlock) { 1563 AsanInvalidAccessWithCorruptFreedBlock) {
1532 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1564 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
1533 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1565 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
1534 OutOfProcessAsanErrorCheckAndValidateLog( 1566 OutOfProcessAsanErrorCheckAndValidateLog(
1535 testing::kAsanInvalidAccessWithCorruptFreedBlock, true, kAsanCorruptHeap, 1567 testing::kAsanInvalidAccessWithCorruptFreedBlock, true, kAsanCorruptHeap,
1536 NULL); 1568 NULL);
1537 } 1569 }
1538 1570
1539 TEST_F(InstrumentAppIntegrationTest, AsanCorruptBlockWithPageProtections) { 1571 TEST_P(ParametrizedInstrumentAppIntegrationTest,
1572 AsanCorruptBlockWithPageProtections) {
1540 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1573 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
1541 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1574 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
1542 OutOfProcessAsanErrorCheckAndValidateLog( 1575 OutOfProcessAsanErrorCheckAndValidateLog(
1543 testing::kAsanCorruptBlockWithPageProtections, true, 1576 testing::kAsanCorruptBlockWithPageProtections, true,
1544 kAsanHeapUseAfterFree, kAsanCorruptHeap); 1577 kAsanHeapUseAfterFree, kAsanCorruptHeap);
1545 } 1578 }
1546 1579
1547 TEST_F(InstrumentAppIntegrationTest, SampledAllocationsAsanEndToEnd) { 1580 TEST_P(ParametrizedInstrumentAppIntegrationTest,
1581 SampledAllocationsAsanEndToEnd) {
1548 cmd_line_.AppendSwitchASCII("asan-rtl-options", 1582 cmd_line_.AppendSwitchASCII("asan-rtl-options",
1549 "--allocation_guard_rate=0.5 " 1583 "--allocation_guard_rate=0.5 "
1550 "--no_check_heap_on_failure"); 1584 "--no_check_heap_on_failure");
1551 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1585 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
1552 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1586 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
1553 ASSERT_NO_FATAL_FAILURE(AsanErrorCheckSampledAllocations()); 1587 ASSERT_NO_FATAL_FAILURE(AsanErrorCheckSampledAllocations());
1554 } 1588 }
1555 1589
1556 TEST_F(InstrumentAppIntegrationTest, AsanLargeBlockHeapEnabledTest) { 1590 // The following two tests are timing out when instrumented and run with Clang.
Sébastien Marchand 2017/08/01 19:27:36 Remove this comment as you're not instantiating th
njanevsk 2017/08/03 01:23:21 Done.
1591 // TODO(njanevsk): Check why the tests are timing out.
1592 TEST_P(ParametrizedInstrumentAppIntegrationTest,
1593 AsanLargeBlockHeapEnabledTest) {
1557 cmd_line_.AppendSwitchASCII("asan-rtl-options", 1594 cmd_line_.AppendSwitchASCII("asan-rtl-options",
1558 "--no_check_heap_on_failure " 1595 "--no_check_heap_on_failure "
1559 "--quarantine_size=4000000 " 1596 "--quarantine_size=4000000 "
1560 "--quarantine_block_size=2000000"); 1597 "--quarantine_block_size=2000000");
1561 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1598 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
1562 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1599 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
1563 ASSERT_NO_FATAL_FAILURE(AsanLargeBlockHeapTests(true)); 1600 ASSERT_NO_FATAL_FAILURE(AsanLargeBlockHeapTests(true));
1564 } 1601 }
1565 1602
1566 TEST_F(InstrumentAppIntegrationTest, AsanLargeBlockHeapDisabledTest) { 1603 TEST_P(ParametrizedInstrumentAppIntegrationTest,
1604 AsanLargeBlockHeapDisabledTest) {
1567 cmd_line_.AppendSwitchASCII("asan-rtl-options", 1605 cmd_line_.AppendSwitchASCII("asan-rtl-options",
1568 "--no_check_heap_on_failure " 1606 "--no_check_heap_on_failure "
1569 "--disable_large_block_heap"); 1607 "--disable_large_block_heap");
1570 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1608 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
1571 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1609 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll());
1572 ASSERT_NO_FATAL_FAILURE(AsanLargeBlockHeapTests(false)); 1610 ASSERT_NO_FATAL_FAILURE(AsanLargeBlockHeapTests(false));
1573 } 1611 }
1574 1612
1575 TEST_F(InstrumentAppIntegrationTest, AsanZebraHeapDisabledTest) { 1613 TEST_P(ParametrizedInstrumentAppIntegrationTest, AsanZebraHeapDisabledTest) {
1576 AsanZebraHeapTest(false); 1614 AsanZebraHeapTest(false);
1577 } 1615 }
1578 1616
1579 TEST_F(InstrumentAppIntegrationTest, AsanZebraHeapEnabledTest) { 1617 TEST_P(ParametrizedInstrumentAppIntegrationTest, AsanZebraHeapEnabledTest) {
1580 AsanZebraHeapTest(true); 1618 AsanZebraHeapTest(true);
1581 } 1619 }
1582 1620
1583 TEST_F(InstrumentAppIntegrationTest, AsanSymbolizerTestAsanBufferOverflow) { 1621 TEST_P(ParametrizedInstrumentAppIntegrationTest,
1622 AsanSymbolizerTestAsanBufferOverflow) {
1584 AsanSymbolizerTest(testing::kAsanRead8BufferOverflow, 1623 AsanSymbolizerTest(testing::kAsanRead8BufferOverflow,
1585 STRINGIFY(HEAP_BUFFER_OVERFLOW), 1624 STRINGIFY(HEAP_BUFFER_OVERFLOW),
1586 STRINGIFY(ASAN_READ_ACCESS), 1625 STRINGIFY(ASAN_READ_ACCESS),
1587 1, 1626 1,
1588 false); 1627 false);
1589 } 1628 }
1590 1629
1591 TEST_F(InstrumentAppIntegrationTest, AsanSymbolizerTestAsanBufferUnderflow) { 1630 TEST_P(ParametrizedInstrumentAppIntegrationTest,
1631 AsanSymbolizerTestAsanBufferUnderflow) {
1592 AsanSymbolizerTest(testing::kAsanWrite32BufferUnderflow, 1632 AsanSymbolizerTest(testing::kAsanWrite32BufferUnderflow,
1593 STRINGIFY(HEAP_BUFFER_UNDERFLOW), 1633 STRINGIFY(HEAP_BUFFER_UNDERFLOW),
1594 STRINGIFY(ASAN_WRITE_ACCESS), 1634 STRINGIFY(ASAN_WRITE_ACCESS),
1595 4, 1635 4,
1596 false); 1636 false);
1597 } 1637 }
1598 1638
1599 TEST_F(InstrumentAppIntegrationTest, AsanSymbolizerTestAsanUseAfterFree) { 1639 TEST_P(ParametrizedInstrumentAppIntegrationTest,
1640 AsanSymbolizerTestAsanUseAfterFree) {
1600 AsanSymbolizerTest(testing::kAsanRead64UseAfterFree, 1641 AsanSymbolizerTest(testing::kAsanRead64UseAfterFree,
1601 STRINGIFY(USE_AFTER_FREE), 1642 STRINGIFY(USE_AFTER_FREE),
1602 STRINGIFY(ASAN_READ_ACCESS), 1643 STRINGIFY(ASAN_READ_ACCESS),
1603 8, 1644 8,
1604 false); 1645 false);
1605 } 1646 }
1606 1647
1607 TEST_F(InstrumentAppIntegrationTest, AsanSymbolizerTestAsanCorruptBlock) { 1648 TEST_P(ParametrizedInstrumentAppIntegrationTest,
1649 AsanSymbolizerTestAsanCorruptBlock) {
1608 AsanSymbolizerTest(testing::kAsanCorruptBlock, 1650 AsanSymbolizerTest(testing::kAsanCorruptBlock,
1609 STRINGIFY(CORRUPT_BLOCK), 1651 STRINGIFY(CORRUPT_BLOCK),
1610 STRINGIFY(ASAN_UNKNOWN_ACCESS), 1652 STRINGIFY(ASAN_UNKNOWN_ACCESS),
1611 0, 1653 0,
1612 false); 1654 false);
1613 } 1655 }
1614 1656
1615 TEST_F(InstrumentAppIntegrationTest, 1657 TEST_P(ParametrizedInstrumentAppIntegrationTest,
1616 AsanSymbolizerTestAsanCorruptBlockInQuarantine) { 1658 AsanSymbolizerTestAsanCorruptBlockInQuarantine) {
1617 AsanSymbolizerTest(testing::kAsanCorruptBlockInQuarantine, 1659 AsanSymbolizerTest(testing::kAsanCorruptBlockInQuarantine,
1618 STRINGIFY(CORRUPT_BLOCK), 1660 STRINGIFY(CORRUPT_BLOCK),
1619 STRINGIFY(ASAN_UNKNOWN_ACCESS), 1661 STRINGIFY(ASAN_UNKNOWN_ACCESS),
1620 0, 1662 0,
1621 true); 1663 true);
1622 } 1664 }
1623 1665
1624 // These tests require corrupt heap checking to be enabled. 1666 // These tests require corrupt heap checking to be enabled.
1625 TEST_F(InstrumentAppIntegrationTest, AsanNearNullptrAccess) { 1667 TEST_P(ParametrizedInstrumentAppIntegrationTest, AsanNearNullptrAccess) {
1626 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1668 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan"));
1627 1669
1628 OutOfProcessAsanErrorCheckAndValidateLog( 1670 OutOfProcessAsanErrorCheckAndValidateLog(
1629 testing::kAsanNearNullptrAccessHeapCorruptionInstrumented, true, 1671 testing::kAsanNearNullptrAccessHeapCorruptionInstrumented, true,
1630 kAsanHandlingException, kAsanNearNullptrAccessHeapCorruption); 1672 kAsanHandlingException, kAsanNearNullptrAccessHeapCorruption);
1631 OutOfProcessAsanErrorCheckAndValidateLog( 1673 OutOfProcessAsanErrorCheckAndValidateLog(
1632 testing::kAsanNearNullptrAccessHeapCorruptionUninstrumented, true, 1674 testing::kAsanNearNullptrAccessHeapCorruptionUninstrumented, true,
1633 kAsanHandlingException, kAsanNearNullptrAccessHeapCorruption); 1675 kAsanHandlingException, kAsanNearNullptrAccessHeapCorruption);
1634 OutOfProcessAsanErrorCheckAndValidateLog( 1676 OutOfProcessAsanErrorCheckAndValidateLog(
1635 testing::kAsanNearNullptrAccessNoHeapCorruptionInstrumented, true, 1677 testing::kAsanNearNullptrAccessNoHeapCorruptionInstrumented, true,
1636 kAsanHandlingException, kAsanNearNullptrAccessNoHeapCorruption); 1678 kAsanHandlingException, kAsanNearNullptrAccessNoHeapCorruption);
1637 OutOfProcessAsanErrorCheckAndValidateLog( 1679 OutOfProcessAsanErrorCheckAndValidateLog(
1638 testing::kAsanNearNullptrAccessNoHeapCorruptionUninstrumented, true, 1680 testing::kAsanNearNullptrAccessNoHeapCorruptionUninstrumented, true,
1639 kAsanHandlingException, kAsanNearNullptrAccessNoHeapCorruption); 1681 kAsanHandlingException, kAsanNearNullptrAccessNoHeapCorruption);
1640 OutOfProcessAsanErrorCheckAndValidateLog( 1682 OutOfProcessAsanErrorCheckAndValidateLog(
1641 testing::kAsanNullptrAccessNoHeapCorruptionUninstrumented, true, 1683 testing::kAsanNullptrAccessNoHeapCorruptionUninstrumented, true,
1642 kAsanHandlingException, kAsanNearNullptrAccessNoHeapCorruption); 1684 kAsanHandlingException, kAsanNearNullptrAccessNoHeapCorruption);
1643 } 1685 }
1644 1686
1687 // Instantiate the test cases only with SYZYGY until some problems are fixed.
1688 INSTANTIATE_TEST_CASE_P(InstantiationName,
1689 ParametrizedInstrumentAppIntegrationTest,
1690 testing::Values(SYZYGY));
1691
1645 TEST_F(InstrumentAppIntegrationTest, BBEntryEndToEnd) { 1692 TEST_F(InstrumentAppIntegrationTest, BBEntryEndToEnd) {
1646 ASSERT_NO_FATAL_FAILURE(StartService()); 1693 ASSERT_NO_FATAL_FAILURE(StartService());
1647 ASSERT_NO_FATAL_FAILURE(EndToEndTest("bbentry")); 1694 ASSERT_NO_FATAL_FAILURE(EndToEndTest("bbentry", SYZYGY));
Sébastien Marchand 2017/08/01 19:27:36 I'm not such a fan of having all these extra "SYZY
njanevsk 2017/08/03 01:23:21 Done.
1648 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1695 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll(SYZYGY));
1649 ASSERT_NO_FATAL_FAILURE(BBEntryInvokeTestDll()); 1696 ASSERT_NO_FATAL_FAILURE(BBEntryInvokeTestDll());
1650 ASSERT_NO_FATAL_FAILURE(StopService()); 1697 ASSERT_NO_FATAL_FAILURE(StopService());
1651 ASSERT_NO_FATAL_FAILURE(BBEntryCheckTestDll()); 1698 ASSERT_NO_FATAL_FAILURE(BBEntryCheckTestDll());
1652 } 1699 }
1653 1700
1654 TEST_F(InstrumentAppIntegrationTest, BranchEndToEnd) { 1701 TEST_F(InstrumentAppIntegrationTest, BranchEndToEnd) {
1655 ASSERT_NO_FATAL_FAILURE(StartService()); 1702 ASSERT_NO_FATAL_FAILURE(StartService());
1656 ASSERT_NO_FATAL_FAILURE(EndToEndTest("branch")); 1703 ASSERT_NO_FATAL_FAILURE(EndToEndTest("branch", SYZYGY));
1657 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1704 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll(SYZYGY));
1658 ASSERT_NO_FATAL_FAILURE(BBEntryInvokeTestDll()); 1705 ASSERT_NO_FATAL_FAILURE(BBEntryInvokeTestDll());
1659 ASSERT_NO_FATAL_FAILURE(UnloadDll()); 1706 ASSERT_NO_FATAL_FAILURE(UnloadDll());
1660 ASSERT_NO_FATAL_FAILURE(StopService()); 1707 ASSERT_NO_FATAL_FAILURE(StopService());
1661 ASSERT_NO_FATAL_FAILURE(BranchCheckTestDll()); 1708 ASSERT_NO_FATAL_FAILURE(BranchCheckTestDll());
1662 } 1709 }
1663 1710
1664 TEST_F(InstrumentAppIntegrationTest, BranchWithBufferingEndToEnd) { 1711 TEST_F(InstrumentAppIntegrationTest, BranchWithBufferingEndToEnd) {
1665 cmd_line_.AppendSwitch("buffering"); 1712 cmd_line_.AppendSwitch("buffering");
1666 ASSERT_NO_FATAL_FAILURE(StartService()); 1713 ASSERT_NO_FATAL_FAILURE(StartService());
1667 ASSERT_NO_FATAL_FAILURE(EndToEndTest("branch")); 1714 ASSERT_NO_FATAL_FAILURE(EndToEndTest("branch", SYZYGY));
1668 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1715 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll(SYZYGY));
1669 ASSERT_NO_FATAL_FAILURE(BBEntryInvokeTestDll()); 1716 ASSERT_NO_FATAL_FAILURE(BBEntryInvokeTestDll());
1670 ASSERT_NO_FATAL_FAILURE(UnloadDll()); 1717 ASSERT_NO_FATAL_FAILURE(UnloadDll());
1671 ASSERT_NO_FATAL_FAILURE(StopService()); 1718 ASSERT_NO_FATAL_FAILURE(StopService());
1672 ASSERT_NO_FATAL_FAILURE(BranchCheckTestDll()); 1719 ASSERT_NO_FATAL_FAILURE(BranchCheckTestDll());
1673 } 1720 }
1674 1721
1675 TEST_F(InstrumentAppIntegrationTest, BranchWithSlotEndToEnd) { 1722 TEST_F(InstrumentAppIntegrationTest, BranchWithSlotEndToEnd) {
1676 cmd_line_.AppendSwitchASCII("fs-slot", "1"); 1723 cmd_line_.AppendSwitchASCII("fs-slot", "1");
1677 ASSERT_NO_FATAL_FAILURE(StartService()); 1724 ASSERT_NO_FATAL_FAILURE(StartService());
1678 ASSERT_NO_FATAL_FAILURE(EndToEndTest("branch")); 1725 ASSERT_NO_FATAL_FAILURE(EndToEndTest("branch", SYZYGY));
1679 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1726 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll(SYZYGY));
1680 ASSERT_NO_FATAL_FAILURE(BBEntryInvokeTestDll()); 1727 ASSERT_NO_FATAL_FAILURE(BBEntryInvokeTestDll());
1681 ASSERT_NO_FATAL_FAILURE(UnloadDll()); 1728 ASSERT_NO_FATAL_FAILURE(UnloadDll());
1682 ASSERT_NO_FATAL_FAILURE(StopService()); 1729 ASSERT_NO_FATAL_FAILURE(StopService());
1683 ASSERT_NO_FATAL_FAILURE(BranchCheckTestDll()); 1730 ASSERT_NO_FATAL_FAILURE(BranchCheckTestDll());
1684 } 1731 }
1685 1732
1686 TEST_F(InstrumentAppIntegrationTest, BranchWithSlotAndBufferingEndToEnd) { 1733 TEST_F(InstrumentAppIntegrationTest, BranchWithSlotAndBufferingEndToEnd) {
1687 cmd_line_.AppendSwitch("buffering"); 1734 cmd_line_.AppendSwitch("buffering");
1688 cmd_line_.AppendSwitchASCII("fs-slot", "1"); 1735 cmd_line_.AppendSwitchASCII("fs-slot", "1");
1689 ASSERT_NO_FATAL_FAILURE(StartService()); 1736 ASSERT_NO_FATAL_FAILURE(StartService());
1690 ASSERT_NO_FATAL_FAILURE(EndToEndTest("branch")); 1737 ASSERT_NO_FATAL_FAILURE(EndToEndTest("branch", SYZYGY));
1691 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1738 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll(SYZYGY));
1692 ASSERT_NO_FATAL_FAILURE(BBEntryInvokeTestDll()); 1739 ASSERT_NO_FATAL_FAILURE(BBEntryInvokeTestDll());
1693 ASSERT_NO_FATAL_FAILURE(UnloadDll()); 1740 ASSERT_NO_FATAL_FAILURE(UnloadDll());
1694 ASSERT_NO_FATAL_FAILURE(StopService()); 1741 ASSERT_NO_FATAL_FAILURE(StopService());
1695 ASSERT_NO_FATAL_FAILURE(BranchCheckTestDll()); 1742 ASSERT_NO_FATAL_FAILURE(BranchCheckTestDll());
1696 } 1743 }
1697 1744
1698 TEST_F(InstrumentAppIntegrationTest, CallTraceEndToEnd) { 1745 TEST_F(InstrumentAppIntegrationTest, CallTraceEndToEnd) {
1699 ASSERT_NO_FATAL_FAILURE(EndToEndTest("calltrace")); 1746 ASSERT_NO_FATAL_FAILURE(EndToEndTest("calltrace", SYZYGY));
1700 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1747 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll(SYZYGY));
1701 } 1748 }
1702 1749
1703 TEST_F(InstrumentAppIntegrationTest, CoverageEndToEnd) { 1750 TEST_F(InstrumentAppIntegrationTest, CoverageEndToEnd) {
1704 base::win::ScopedCOMInitializer scoped_com_initializer; 1751 base::win::ScopedCOMInitializer scoped_com_initializer;
1705 ASSERT_NO_FATAL_FAILURE(StartService()); 1752 ASSERT_NO_FATAL_FAILURE(StartService());
1706 ASSERT_NO_FATAL_FAILURE(EndToEndTest("coverage")); 1753 ASSERT_NO_FATAL_FAILURE(EndToEndTest("coverage", SYZYGY));
1707 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1754 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll(SYZYGY));
1708 ASSERT_NO_FATAL_FAILURE(CoverageInvokeTestDll()); 1755 ASSERT_NO_FATAL_FAILURE(CoverageInvokeTestDll());
1709 ASSERT_NO_FATAL_FAILURE(StopService()); 1756 ASSERT_NO_FATAL_FAILURE(StopService());
1710 ASSERT_NO_FATAL_FAILURE(CoverageCheckTestDll()); 1757 ASSERT_NO_FATAL_FAILURE(CoverageCheckTestDll());
1711 } 1758 }
1712 1759
1713 TEST_F(InstrumentAppIntegrationTest, BBEntryCoverageEndToEnd) { 1760 TEST_F(InstrumentAppIntegrationTest, BBEntryCoverageEndToEnd) {
1714 // Coverage grinder must be able to process traces produced by bbentry 1761 // Coverage grinder must be able to process traces produced by bbentry
1715 // instrumentation. 1762 // instrumentation.
1716 base::win::ScopedCOMInitializer scoped_com_initializer; 1763 base::win::ScopedCOMInitializer scoped_com_initializer;
1717 ASSERT_NO_FATAL_FAILURE(StartService()); 1764 ASSERT_NO_FATAL_FAILURE(StartService());
1718 ASSERT_NO_FATAL_FAILURE(EndToEndTest("bbentry")); 1765 ASSERT_NO_FATAL_FAILURE(EndToEndTest("bbentry", SYZYGY));
1719 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); 1766 ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll(SYZYGY));
1720 ASSERT_NO_FATAL_FAILURE(CoverageInvokeTestDll()); 1767 ASSERT_NO_FATAL_FAILURE(CoverageInvokeTestDll());
1721 ASSERT_NO_FATAL_FAILURE(StopService()); 1768 ASSERT_NO_FATAL_FAILURE(StopService());
1722 ASSERT_NO_FATAL_FAILURE(CoverageCheckTestDll()); 1769 ASSERT_NO_FATAL_FAILURE(CoverageCheckTestDll());
1723 } 1770 }
1724 1771
1725 TEST_F(InstrumentAppIntegrationTest, ProfileEndToEnd) { 1772 TEST_F(InstrumentAppIntegrationTest, ProfileEndToEnd) {
1726 ASSERT_NO_FATAL_FAILURE(StartService()); 1773 ASSERT_NO_FATAL_FAILURE(StartService());
1727 ASSERT_NO_FATAL_FAILURE(EndToEndTest("profile")); 1774 ASSERT_NO_FATAL_FAILURE(EndToEndTest("profile", SYZYGY));
1728 ASSERT_NO_FATAL_FAILURE(ProfileInvokeTestDll()); 1775 ASSERT_NO_FATAL_FAILURE(ProfileInvokeTestDll());
1729 ASSERT_NO_FATAL_FAILURE(UnloadDll()); 1776 ASSERT_NO_FATAL_FAILURE(UnloadDll());
1730 ASSERT_NO_FATAL_FAILURE(StopService()); 1777 ASSERT_NO_FATAL_FAILURE(StopService());
1731 ASSERT_NO_FATAL_FAILURE(ProfileCheckTestDll(false)); 1778 ASSERT_NO_FATAL_FAILURE(ProfileCheckTestDll(false));
1732 } 1779 }
1733 1780
1734 TEST_F(InstrumentAppIntegrationTest, ProfileWithImportsEndToEnd) { 1781 TEST_F(InstrumentAppIntegrationTest, ProfileWithImportsEndToEnd) {
1735 cmd_line_.AppendSwitch("instrument-imports"); 1782 cmd_line_.AppendSwitch("instrument-imports");
1736 ASSERT_NO_FATAL_FAILURE(StartService()); 1783 ASSERT_NO_FATAL_FAILURE(StartService());
1737 ASSERT_NO_FATAL_FAILURE(EndToEndTest("profile")); 1784 ASSERT_NO_FATAL_FAILURE(EndToEndTest("profile", SYZYGY));
1738 ASSERT_NO_FATAL_FAILURE(ProfileInvokeTestDll()); 1785 ASSERT_NO_FATAL_FAILURE(ProfileInvokeTestDll());
1739 ASSERT_NO_FATAL_FAILURE(UnloadDll()); 1786 ASSERT_NO_FATAL_FAILURE(UnloadDll());
1740 ASSERT_NO_FATAL_FAILURE(StopService()); 1787 ASSERT_NO_FATAL_FAILURE(StopService());
1741 ASSERT_NO_FATAL_FAILURE(ProfileCheckTestDll(true)); 1788 ASSERT_NO_FATAL_FAILURE(ProfileCheckTestDll(true));
1742 } 1789 }
1743 1790
1744 TEST_F(InstrumentAppIntegrationTest, DeferredFreeTLS) { 1791 TEST_F(InstrumentAppIntegrationTest, DeferredFreeTLS) {
1745 ASSERT_NO_FATAL_FAILURE(StartService()); 1792 ASSERT_NO_FATAL_FAILURE(StartService());
1746 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); 1793 ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan", SYZYGY));
1747 ASSERT_EQ(0, InvokeTestDllFunction(testing::kAsanDeferredFreeTLS)); 1794 ASSERT_EQ(0, InvokeTestDllFunction(testing::kAsanDeferredFreeTLS));
1748 ASSERT_NO_FATAL_FAILURE(UnloadDll()); 1795 ASSERT_NO_FATAL_FAILURE(UnloadDll());
1749 ASSERT_NO_FATAL_FAILURE(StopService()); 1796 ASSERT_NO_FATAL_FAILURE(StopService());
1750 } 1797 }
1751 1798
1752 } // namespace integration_tests 1799 } // namespace integration_tests
OLDNEW
« no previous file with comments | « no previous file | syzygy/pe/unittest_util.h » ('j') | syzygy/pe/unittest_util.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698