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

Side by Side Diff: syzygy/agent/asan/runtime_unittest.cc

Issue 1992773002: [SyzyAsan] Enable Crashpad reporter as a 50/50 experiment. (Closed) Base URL: https://github.com/google/syzygy.git@master
Patch Set: Fix broken unittest. Created 4 years, 6 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 | « syzygy/agent/asan/runtime.cc ('k') | syzygy/agent/asan/syzyasan_rtl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 Google Inc. All Rights Reserved. 1 // Copyright 2012 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 for (const auto& iter : feature_group_frequency) { 281 for (const auto& iter : feature_group_frequency) {
282 EXPECT_LT(kExpectedCount - kErrorMargin, iter.second); 282 EXPECT_LT(kExpectedCount - kErrorMargin, iter.second);
283 EXPECT_GT(kExpectedCount + kErrorMargin, iter.second); 283 EXPECT_GT(kExpectedCount + kErrorMargin, iter.second);
284 } 284 }
285 } 285 }
286 286
287 TEST_F(AsanRuntimeTest, PropagateFeatureSet) { 287 TEST_F(AsanRuntimeTest, PropagateFeatureSet) {
288 ASSERT_NO_FATAL_FAILURE( 288 ASSERT_NO_FATAL_FAILURE(
289 asan_runtime_.SetUp(current_command_line_.GetCommandLineString())); 289 asan_runtime_.SetUp(current_command_line_.GetCommandLineString()));
290 290
291 AsanFeatureSet valid_feature_sets[] = { 291 for (uint32_t feature_set = 0; feature_set < ASAN_FEATURE_MAX;
292 0, 292 ++feature_set) {
293 ASAN_FEATURE_ENABLE_LARGE_BLOCK_HEAP, 293 // Skip feature sets that enable deprecated features.
294 ASAN_FEATURE_ENABLE_PAGE_PROTECTIONS, 294 if (feature_set & kAsanDeprecatedFeatures)
295 ASAN_FEATURE_ENABLE_PAGE_PROTECTIONS | 295 continue;
296 ASAN_FEATURE_ENABLE_LARGE_BLOCK_HEAP};
297 296
298 size_t number_of_valid_features = 0U;
299 for (size_t i = 0; i < sizeof(kAsanValidFeatures) * 8; ++i) {
300 if ((kAsanDeprecatedFeatures & (1 << i)) != 0U)
301 number_of_valid_features++;
302 }
303
304 EXPECT_EQ(arraysize(valid_feature_sets), 1 << number_of_valid_features);
305
306 for (auto feature_set : valid_feature_sets) {
307 asan_runtime_.PropagateFeatureSet(feature_set); 297 asan_runtime_.PropagateFeatureSet(feature_set);
308 ::common::AsanParameters expected_params = {}; 298 ::common::AsanParameters expected_params = {};
309 ::common::SetDefaultAsanParameters(&expected_params); 299 ::common::SetDefaultAsanParameters(&expected_params);
310 expected_params.enable_large_block_heap = 300 expected_params.enable_large_block_heap =
311 ((feature_set & ASAN_FEATURE_ENABLE_LARGE_BLOCK_HEAP) != 0U); 301 ((feature_set & ASAN_FEATURE_ENABLE_LARGE_BLOCK_HEAP) != 0U);
312 EXPECT_EQ(0U, ::memcmp(&expected_params, &asan_runtime_.params(), 302 EXPECT_EQ(0U, ::memcmp(&expected_params, &asan_runtime_.params(),
313 sizeof(::common::AsanParameters))); 303 sizeof(::common::AsanParameters)));
314 TestBlockHeapManager* test_block_heap_manager = 304 TestBlockHeapManager* test_block_heap_manager =
315 static_cast<TestBlockHeapManager*>(asan_runtime_.heap_manager_.get()); 305 static_cast<TestBlockHeapManager*>(asan_runtime_.heap_manager_.get());
316 EXPECT_EQ(test_block_heap_manager->enable_page_protections_, 306 EXPECT_EQ(test_block_heap_manager->enable_page_protections_,
317 ((feature_set & ASAN_FEATURE_ENABLE_PAGE_PROTECTIONS) != 0U)); 307 ((feature_set & ASAN_FEATURE_ENABLE_PAGE_PROTECTIONS) != 0U));
308
309 // Expect the Crashpad bit to always be cleared, as the crash reporter
310 // can't be initialized without a Crashpad server running.
311 EXPECT_EQ(0u,
312 asan_runtime_.GetEnabledFeatureSet() & ASAN_FEATURE_ENABLE_CRASHPAD);
318 } 313 }
319 314
320 ASSERT_NO_FATAL_FAILURE(asan_runtime_.TearDown()); 315 ASSERT_NO_FATAL_FAILURE(asan_runtime_.TearDown());
321 } 316 }
322 317
323 TEST_F(AsanRuntimeTest, OnErrorSaveEnabledFeatureList) { 318 TEST_F(AsanRuntimeTest, OnErrorSaveEnabledFeatureList) {
324 asan_runtime_.params().feature_randomization = true; 319 asan_runtime_.params().feature_randomization = true;
325 ASSERT_NO_FATAL_FAILURE( 320 ASSERT_NO_FATAL_FAILURE(
326 asan_runtime_.SetUp(current_command_line_.GetCommandLineString())); 321 asan_runtime_.SetUp(current_command_line_.GetCommandLineString()));
327 322
328 // Disable the heap checking as this really slows down the unittests. 323 // Disable the heap checking as this really slows down the unittests.
329 asan_runtime_.params().check_heap_on_failure = false; 324 asan_runtime_.params().check_heap_on_failure = false;
330 asan_runtime_.SetErrorCallBack(base::Bind(&TestCallback)); 325 asan_runtime_.SetErrorCallBack(base::Bind(&TestCallback));
331 callback_called = false; 326 callback_called = false;
332 callback_error_info.feature_set = ASAN_FEATURE_MAX; 327 callback_error_info.feature_set = ASAN_FEATURE_MAX;
333 AsanErrorInfo bad_access_info = {}; 328 AsanErrorInfo bad_access_info = {};
334 RtlCaptureContext(&bad_access_info.context); 329 RtlCaptureContext(&bad_access_info.context);
335 AsanFeatureSet expected_feature_set = static_cast<AsanFeatureSet>( 330 AsanFeatureSet expected_feature_set = static_cast<AsanFeatureSet>(
336 ASAN_FEATURE_ENABLE_LARGE_BLOCK_HEAP); 331 ASAN_FEATURE_ENABLE_LARGE_BLOCK_HEAP);
337 asan_runtime_.PropagateFeatureSet(expected_feature_set); 332 asan_runtime_.PropagateFeatureSet(expected_feature_set);
338 asan_runtime_.OnError(&bad_access_info); 333 asan_runtime_.OnError(&bad_access_info);
339 EXPECT_TRUE(callback_called); 334 EXPECT_TRUE(callback_called);
340 EXPECT_EQ(expected_feature_set, callback_error_info.feature_set); 335 EXPECT_EQ(expected_feature_set, callback_error_info.feature_set);
341 ASSERT_NO_FATAL_FAILURE(asan_runtime_.TearDown()); 336 ASSERT_NO_FATAL_FAILURE(asan_runtime_.TearDown());
342 } 337 }
343 338
344 } // namespace asan 339 } // namespace asan
345 } // namespace agent 340 } // namespace agent
OLDNEW
« no previous file with comments | « syzygy/agent/asan/runtime.cc ('k') | syzygy/agent/asan/syzyasan_rtl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698