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

Unified Diff: syzygy/integration_tests/instrument_integration_test.cc

Issue 2984303002: Split the testing class into two. (Closed)
Patch Set: Response to reviewers comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6e89d74c9d10f05a2acc473e6d34cb29f704933f 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");
@@ -420,9 +425,9 @@ class LenientInstrumentAppIntegrationTest : public testing::PELibUnitTest {
// Runs an instrumentation pass in the given mode and validates that the
// resulting output DLL loads.
- void EndToEndTest(const std::string& mode) {
+ virtual 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");
@@ -575,7 +580,7 @@ class LenientInstrumentAppIntegrationTest : public testing::PELibUnitTest {
}
}
- void EndToEndCheckTestDll() {
+ virtual void EndToEndCheckTestDll() {
// Validate that behavior is unchanged after instrumentation.
EXPECT_EQ(0xfff80200, InvokeTestDllFunction(testing::kArrayComputation1));
EXPECT_EQ(0x00000200, InvokeTestDllFunction(testing::kArrayComputation2));
@@ -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;
}
@@ -1269,7 +1274,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 +1290,30 @@ class LenientInstrumentAppIntegrationTest : public testing::PELibUnitTest {
block_graph::BlockGraph block_graph_;
uint32_t get_my_rva_;
};
+
+// Class created to enable parametrization of the tests with clang.
Sébastien Marchand 2017/08/07 18:21:50 Clang.
+// Currently only Syzygy is supported but will be extended to work with CLANG.
+// Rigth now it just forwards the calls to the parent class.
Sébastien Marchand 2017/08/07 18:21:50 right.
+class ParametrizedLenientInstrumentAppIntegrationTest
+ : public LenientInstrumentAppIntegrationTest,
+ public ::testing::WithParamInterface<InstrumentationMode> {
+ public:
+ void EndToEndTest(const std::string& mode) override {
+ if (GetParam() == SYZYGY) {
+ LenientInstrumentAppIntegrationTest::EndToEndTest(mode);
+ }
+ }
+
+ void EndToEndCheckTestDll() override {
+ if (GetParam() == SYZYGY) {
+ LenientInstrumentAppIntegrationTest::EndToEndCheckTestDll();
+ }
+ }
+};
+
+typedef testing::StrictMock<ParametrizedLenientInstrumentAppIntegrationTest>
+ ParametrizedInstrumentAppIntegrationTest;
+
typedef testing::StrictMock<LenientInstrumentAppIntegrationTest>
InstrumentAppIntegrationTest;
@@ -1407,7 +1436,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 +1446,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 +1456,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 +1467,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 +1478,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 +1494,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 +1520,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 +1530,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 +1539,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 +1550,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 +1559,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 +1568,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 +1577,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 +1587,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 +1598,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 +1608,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 +1625,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 +1634,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 +1643,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 +1652,7 @@ TEST_F(InstrumentAppIntegrationTest, AsanSymbolizerTestAsanCorruptBlock) {
false);
}
-TEST_F(InstrumentAppIntegrationTest,
+TEST_P(ParametrizedInstrumentAppIntegrationTest,
AsanSymbolizerTestAsanCorruptBlockInQuarantine) {
AsanSymbolizerTest(testing::kAsanCorruptBlockInQuarantine,
STRINGIFY(CORRUPT_BLOCK),
@@ -1622,7 +1662,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 +1682,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"));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698