Chromium Code Reviews| Index: syzygy/integration_tests/instrument_integration_test.cc |
| diff --git a/syzygy/integration_tests/instrument_integration_test.cc b/syzygy/integration_tests/instrument_integration_test.cc |
| index c53f0e1160712a626b3c0fba14c9659358ca1178..2d66ccfb36c632103f86179ab012332ff7395eb6 100644 |
| --- a/syzygy/integration_tests/instrument_integration_test.cc |
| +++ b/syzygy/integration_tests/instrument_integration_test.cc |
| @@ -347,6 +347,11 @@ class TestingProfileGrinder : public grinder::grinders::ProfileGrinder { |
| using grinder::grinders::ProfileGrinder::parts_; |
| }; |
| +enum InstrumentationMode { |
| + SYZYGY, |
| + CLANG, |
| +}; |
| + |
| class LenientInstrumentAppIntegrationTest : public testing::PELibUnitTest { |
| public: |
| typedef testing::PELibUnitTest Super; |
| @@ -379,7 +384,7 @@ class LenientInstrumentAppIntegrationTest : public testing::PELibUnitTest { |
| base::FilePath abs_input_dll_path_ = |
| testing::GetExeRelativePath(testing::kIntegrationTestsDllName); |
| input_dll_path_ = testing::GetRelativePath(abs_input_dll_path_); |
| - output_dll_path_ = temp_dir_.Append(input_dll_path_.BaseName()); |
| + test_dll_path_ = temp_dir_.Append(input_dll_path_.BaseName()); |
| // Initialize call_service output directory for produced trace files. |
| traces_dir_ = temp_dir_.Append(L"traces"); |
| @@ -422,7 +427,7 @@ class LenientInstrumentAppIntegrationTest : public testing::PELibUnitTest { |
| // resulting output DLL loads. |
| void EndToEndTest(const std::string& mode) { |
| cmd_line_.AppendSwitchPath("input-image", input_dll_path_); |
| - cmd_line_.AppendSwitchPath("output-image", output_dll_path_); |
| + cmd_line_.AppendSwitchPath("output-image", test_dll_path_); |
| cmd_line_.AppendSwitchASCII("mode", mode); |
| // Create the instrumented DLL. |
| @@ -431,7 +436,7 @@ class LenientInstrumentAppIntegrationTest : public testing::PELibUnitTest { |
| ASSERT_EQ(0, app.Run()); |
| // Validate that the test dll loads post instrumentation. |
| - ASSERT_NO_FATAL_FAILURE(LoadTestDll(output_dll_path_, &module_)); |
| + ASSERT_NO_FATAL_FAILURE(LoadTestDll(test_dll_path_, &module_)); |
| } |
| // Invoke a test function inside test_dll by addressing it with a test id. |
| @@ -453,7 +458,7 @@ class LenientInstrumentAppIntegrationTest : public testing::PELibUnitTest { |
| base::FilePath harness = testing::GetExeRelativePath(harness_name.c_str()); |
| base::CommandLine cmd_line(harness); |
| cmd_line.AppendSwitchASCII("test", base::StringPrintf("%d", test)); |
| - cmd_line.AppendSwitchPath("dll", output_dll_path_); |
| + cmd_line.AppendSwitchPath("dll", test_dll_path_); |
| if (expect_exception) |
| cmd_line.AppendSwitch("expect-exception"); |
| @@ -617,7 +622,7 @@ class LenientInstrumentAppIntegrationTest : public testing::PELibUnitTest { |
| if (asan_error_count == 0 && i + 1 < max_tries) { |
| // If the module was unloaded and the test is retrying, then reload it. |
| if (unload) |
| - EXPECT_NO_FATAL_FAILURE(LoadTestDll(output_dll_path_, &module_)); |
| + EXPECT_NO_FATAL_FAILURE(LoadTestDll(test_dll_path_, &module_)); |
| continue; |
| } |
| @@ -880,8 +885,6 @@ class LenientInstrumentAppIntegrationTest : public testing::PELibUnitTest { |
| kAsanAccessViolationLog, kAsanHeapUseAfterFree); |
| } |
| - void AsanZebraHeapTest(bool enabled); |
| - |
| void BBEntryInvokeTestDll() { |
| EXPECT_EQ(42, InvokeTestDllFunction(testing::kBBEntryCallOnce)); |
| EXPECT_EQ(42, InvokeTestDllFunction(testing::kBBEntryCallTree)); |
| @@ -1269,7 +1272,7 @@ class LenientInstrumentAppIntegrationTest : public testing::PELibUnitTest { |
| // @{ |
| base::CommandLine cmd_line_; |
| base::FilePath input_dll_path_; |
| - base::FilePath output_dll_path_; |
| + base::FilePath test_dll_path_; |
| base::FilePath traces_dir_; |
| // @} |
| @@ -1285,6 +1288,30 @@ class LenientInstrumentAppIntegrationTest : public testing::PELibUnitTest { |
| block_graph::BlockGraph block_graph_; |
| uint32_t get_my_rva_; |
| }; |
| + |
| +class ParametrizedLenientInstrumentAppIntegrationTest |
|
Sébastien Marchand
2017/08/07 16:46:59
Add a comment explaining the purpose of this class
njanevsk
2017/08/07 17:39:22
Done.
|
| + : public LenientInstrumentAppIntegrationTest, |
| + public ::testing::WithParamInterface<InstrumentationMode> { |
| + public: |
| + void SetUp() { LenientInstrumentAppIntegrationTest::SetUp(); } |
|
Sébastien Marchand
2017/08/07 16:46:59
You don't need this?
njanevsk
2017/08/07 17:39:21
I need this when adding CLANG to set the path:
if
|
| + |
| + void EndToEndTest(const std::string& mode) { |
|
Sébastien Marchand
2017/08/07 16:46:59
Add an "override" keyword.
njanevsk
2017/08/07 17:39:22
Done.
|
| + if (GetParam() == SYZYGY) { |
| + LenientInstrumentAppIntegrationTest::EndToEndTest(mode); |
| + } |
| + } |
| + void AsanZebraHeapTest(bool enabled); |
|
Sébastien Marchand
2017/08/07 16:46:59
As mentioned in the previous comment, leave this i
njanevsk
2017/08/07 17:39:22
Done.
|
| + |
| + void EndToEndCheckTestDll() { |
|
Sébastien Marchand
2017/08/07 16:46:59
Add the override keyword.
njanevsk
2017/08/07 17:39:22
Done.
|
| + if (GetParam() == SYZYGY) { |
| + LenientInstrumentAppIntegrationTest::EndToEndCheckTestDll(); |
| + } |
| + } |
| +}; |
| + |
| +typedef testing::StrictMock<ParametrizedLenientInstrumentAppIntegrationTest> |
| + ParametrizedInstrumentAppIntegrationTest; |
| + |
| typedef testing::StrictMock<LenientInstrumentAppIntegrationTest> |
| InstrumentAppIntegrationTest; |
| @@ -1370,7 +1397,8 @@ void GetCallOffsets(const base::FilePath& image_path, |
| } |
| } |
| -void LenientInstrumentAppIntegrationTest::AsanZebraHeapTest(bool enabled) { |
| +void ParametrizedLenientInstrumentAppIntegrationTest::AsanZebraHeapTest( |
| + bool enabled) { |
| // Find the offset of the call we want to instrument. |
| static const char kTest1[] = |
| "testing::AsanReadPageAllocationTrailerBeforeFree"; |
| @@ -1407,7 +1435,7 @@ void LenientInstrumentAppIntegrationTest::AsanZebraHeapTest(bool enabled) { |
| } // namespace |
| -TEST_F(InstrumentAppIntegrationTest, AsanEndToEnd) { |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, AsanEndToEnd) { |
| // Disable the heap checking as this is implies touching all the shadow bytes |
| // and this make those tests really slow. |
| cmd_line_.AppendSwitchASCII("asan-rtl-options", "--no_check_heap_on_failure"); |
| @@ -1417,7 +1445,7 @@ TEST_F(InstrumentAppIntegrationTest, AsanEndToEnd) { |
| ASSERT_NO_FATAL_FAILURE(CheckTestDllImportsRedirected()); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, AsanEndToEndNoLiveness) { |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, AsanEndToEndNoLiveness) { |
| // Disable the heap checking as this is implies touching all the shadow bytes |
| // and this make those tests really slow. |
| cmd_line_.AppendSwitchASCII("asan-rtl-options", "--no_check_heap_on_failure"); |
| @@ -1427,7 +1455,8 @@ TEST_F(InstrumentAppIntegrationTest, AsanEndToEndNoLiveness) { |
| ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll()); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, AsanEndToEndNoRedundancyAnalysis) { |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, |
| + AsanEndToEndNoRedundancyAnalysis) { |
| // Disable the heap checking as this is implies touching all the shadow bytes |
| // and this make those tests really slow. |
| cmd_line_.AppendSwitchASCII("asan-rtl-options", "--no_check_heap_on_failure"); |
| @@ -1437,7 +1466,8 @@ TEST_F(InstrumentAppIntegrationTest, AsanEndToEndNoRedundancyAnalysis) { |
| ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll()); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, AsanEndToEndNoFunctionInterceptors) { |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, |
| + AsanEndToEndNoFunctionInterceptors) { |
| // Disable the heap checking as this is implies touching all the shadow bytes |
| // and this make those tests really slow. |
| cmd_line_.AppendSwitchASCII("asan-rtl-options", "--no_check_heap_on_failure"); |
| @@ -1447,7 +1477,7 @@ TEST_F(InstrumentAppIntegrationTest, AsanEndToEndNoFunctionInterceptors) { |
| ASSERT_NO_FATAL_FAILURE(AsanErrorCheckTestDll()); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, AsanEndToEndWithRtlOptions) { |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, AsanEndToEndWithRtlOptions) { |
| cmd_line_.AppendSwitchASCII( |
| "asan-rtl-options", |
| "--quarantine_size=20000000 --quarantine_block_size=1000000 " |
| @@ -1463,7 +1493,7 @@ TEST_F(InstrumentAppIntegrationTest, AsanEndToEndWithRtlOptions) { |
| ASSERT_EQ(1000000u, runtime->params().quarantine_block_size); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, |
| AsanEndToEndWithRtlOptionsOverrideWithEnvironment) { |
| std::unique_ptr<base::Environment> env(base::Environment::Create()); |
| ASSERT_NE(env.get(), nullptr); |
| @@ -1489,7 +1519,7 @@ TEST_F(InstrumentAppIntegrationTest, |
| env->UnSetVar(::common::kSyzyAsanOptionsEnvVar); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, FullOptimizedAsanEndToEnd) { |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, FullOptimizedAsanEndToEnd) { |
| // Disable the heap checking as this implies touching all the shadow bytes |
| // and this make these tests really slow. |
| cmd_line_.AppendSwitchASCII("asan-rtl-options", "--no_check_heap_on_failure"); |
| @@ -1499,7 +1529,7 @@ TEST_F(InstrumentAppIntegrationTest, FullOptimizedAsanEndToEnd) { |
| ASSERT_NO_FATAL_FAILURE(AsanErrorCheckInterceptedFunctions()); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, |
| AsanInvalidAccessWithCorruptAllocatedBlockHeader) { |
| ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); |
| ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); |
| @@ -1508,7 +1538,8 @@ TEST_F(InstrumentAppIntegrationTest, |
| kAsanCorruptHeap, NULL); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, AsanOverflowCallsCrashForException) { |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, |
| + AsanOverflowCallsCrashForException) { |
| // Asan-detected violations go through CrashForException if it is available. |
| ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); |
| ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); |
| @@ -1518,7 +1549,7 @@ TEST_F(InstrumentAppIntegrationTest, AsanOverflowCallsCrashForException) { |
| EXPECT_EQ(kExeCrashForExceptionExitCode, exit_code); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, |
| AsanInvalidAccessWithCorruptAllocatedBlockTrailer) { |
| ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); |
| ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); |
| @@ -1527,7 +1558,7 @@ TEST_F(InstrumentAppIntegrationTest, |
| kAsanCorruptHeap, NULL); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, |
| AsanInvalidAccessWithCorruptFreedBlock) { |
| ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); |
| ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); |
| @@ -1536,7 +1567,8 @@ TEST_F(InstrumentAppIntegrationTest, |
| NULL); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, AsanCorruptBlockWithPageProtections) { |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, |
| + AsanCorruptBlockWithPageProtections) { |
| ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); |
| ASSERT_NO_FATAL_FAILURE(EndToEndCheckTestDll()); |
| OutOfProcessAsanErrorCheckAndValidateLog( |
| @@ -1544,7 +1576,8 @@ TEST_F(InstrumentAppIntegrationTest, AsanCorruptBlockWithPageProtections) { |
| kAsanHeapUseAfterFree, kAsanCorruptHeap); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, SampledAllocationsAsanEndToEnd) { |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, |
| + SampledAllocationsAsanEndToEnd) { |
| cmd_line_.AppendSwitchASCII("asan-rtl-options", |
| "--allocation_guard_rate=0.5 " |
| "--no_check_heap_on_failure"); |
| @@ -1553,7 +1586,8 @@ TEST_F(InstrumentAppIntegrationTest, SampledAllocationsAsanEndToEnd) { |
| ASSERT_NO_FATAL_FAILURE(AsanErrorCheckSampledAllocations()); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, AsanLargeBlockHeapEnabledTest) { |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, |
| + AsanLargeBlockHeapEnabledTest) { |
| cmd_line_.AppendSwitchASCII("asan-rtl-options", |
| "--no_check_heap_on_failure " |
| "--quarantine_size=4000000 " |
| @@ -1563,7 +1597,8 @@ TEST_F(InstrumentAppIntegrationTest, AsanLargeBlockHeapEnabledTest) { |
| ASSERT_NO_FATAL_FAILURE(AsanLargeBlockHeapTests(true)); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, AsanLargeBlockHeapDisabledTest) { |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, |
| + AsanLargeBlockHeapDisabledTest) { |
| cmd_line_.AppendSwitchASCII("asan-rtl-options", |
| "--no_check_heap_on_failure " |
| "--disable_large_block_heap"); |
| @@ -1572,15 +1607,16 @@ TEST_F(InstrumentAppIntegrationTest, AsanLargeBlockHeapDisabledTest) { |
| ASSERT_NO_FATAL_FAILURE(AsanLargeBlockHeapTests(false)); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, AsanZebraHeapDisabledTest) { |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, AsanZebraHeapDisabledTest) { |
| AsanZebraHeapTest(false); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, AsanZebraHeapEnabledTest) { |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, AsanZebraHeapEnabledTest) { |
| AsanZebraHeapTest(true); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, AsanSymbolizerTestAsanBufferOverflow) { |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, |
| + AsanSymbolizerTestAsanBufferOverflow) { |
| AsanSymbolizerTest(testing::kAsanRead8BufferOverflow, |
| STRINGIFY(HEAP_BUFFER_OVERFLOW), |
| STRINGIFY(ASAN_READ_ACCESS), |
| @@ -1588,7 +1624,8 @@ TEST_F(InstrumentAppIntegrationTest, AsanSymbolizerTestAsanBufferOverflow) { |
| false); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, AsanSymbolizerTestAsanBufferUnderflow) { |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, |
| + AsanSymbolizerTestAsanBufferUnderflow) { |
| AsanSymbolizerTest(testing::kAsanWrite32BufferUnderflow, |
| STRINGIFY(HEAP_BUFFER_UNDERFLOW), |
| STRINGIFY(ASAN_WRITE_ACCESS), |
| @@ -1596,7 +1633,8 @@ TEST_F(InstrumentAppIntegrationTest, AsanSymbolizerTestAsanBufferUnderflow) { |
| false); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, AsanSymbolizerTestAsanUseAfterFree) { |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, |
| + AsanSymbolizerTestAsanUseAfterFree) { |
| AsanSymbolizerTest(testing::kAsanRead64UseAfterFree, |
| STRINGIFY(USE_AFTER_FREE), |
| STRINGIFY(ASAN_READ_ACCESS), |
| @@ -1604,7 +1642,8 @@ TEST_F(InstrumentAppIntegrationTest, AsanSymbolizerTestAsanUseAfterFree) { |
| false); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, AsanSymbolizerTestAsanCorruptBlock) { |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, |
| + AsanSymbolizerTestAsanCorruptBlock) { |
| AsanSymbolizerTest(testing::kAsanCorruptBlock, |
| STRINGIFY(CORRUPT_BLOCK), |
| STRINGIFY(ASAN_UNKNOWN_ACCESS), |
| @@ -1612,7 +1651,7 @@ TEST_F(InstrumentAppIntegrationTest, AsanSymbolizerTestAsanCorruptBlock) { |
| false); |
| } |
| -TEST_F(InstrumentAppIntegrationTest, |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, |
| AsanSymbolizerTestAsanCorruptBlockInQuarantine) { |
| AsanSymbolizerTest(testing::kAsanCorruptBlockInQuarantine, |
| STRINGIFY(CORRUPT_BLOCK), |
| @@ -1622,7 +1661,7 @@ TEST_F(InstrumentAppIntegrationTest, |
| } |
| // These tests require corrupt heap checking to be enabled. |
| -TEST_F(InstrumentAppIntegrationTest, AsanNearNullptrAccess) { |
| +TEST_P(ParametrizedInstrumentAppIntegrationTest, AsanNearNullptrAccess) { |
| ASSERT_NO_FATAL_FAILURE(EndToEndTest("asan")); |
| OutOfProcessAsanErrorCheckAndValidateLog( |
| @@ -1642,6 +1681,11 @@ TEST_F(InstrumentAppIntegrationTest, AsanNearNullptrAccess) { |
| kAsanHandlingException, kAsanNearNullptrAccessNoHeapCorruption); |
| } |
| +// Instantiate the test cases only with SYZYGY until some problems are fixed. |
| +INSTANTIATE_TEST_CASE_P(InstantiationName, |
| + ParametrizedInstrumentAppIntegrationTest, |
| + testing::Values(SYZYGY)); |
| + |
| TEST_F(InstrumentAppIntegrationTest, BBEntryEndToEnd) { |
| ASSERT_NO_FATAL_FAILURE(StartService()); |
| ASSERT_NO_FATAL_FAILURE(EndToEndTest("bbentry")); |