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

Side by Side Diff: sandbox/win/src/address_sanitizer_test.cc

Issue 1849323003: Convert //sandbox to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixup nonsfi_sandbox_unittest.cc Created 4 years, 8 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 | « sandbox/win/src/acl.cc ('k') | sandbox/win/src/app_container.h » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdio.h> 5 #include <stdio.h>
6 6
7 #include <memory>
8
7 #include "base/environment.h" 9 #include "base/environment.h"
8 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
11 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
12 #include "base/path_service.h" 14 #include "base/path_service.h"
13 #include "base/win/scoped_handle.h" 15 #include "base/win/scoped_handle.h"
14 #include "base/win/windows_version.h" 16 #include "base/win/windows_version.h"
15 #include "sandbox/win/tests/common/controller.h" 17 #include "sandbox/win/tests/common/controller.h"
16 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
17 19
18 namespace sandbox { 20 namespace sandbox {
19 21
20 class AddressSanitizerTests : public ::testing::Test { 22 class AddressSanitizerTests : public ::testing::Test {
21 public: 23 public:
22 void SetUp() override { 24 void SetUp() override {
23 env_.reset(base::Environment::Create()); 25 env_.reset(base::Environment::Create());
24 had_asan_options_ = env_->GetVar("ASAN_OPTIONS", &old_asan_options_); 26 had_asan_options_ = env_->GetVar("ASAN_OPTIONS", &old_asan_options_);
25 } 27 }
26 28
27 void TearDown() override { 29 void TearDown() override {
28 if (had_asan_options_) 30 if (had_asan_options_)
29 ASSERT_TRUE(env_->SetVar("ASAN_OPTIONS", old_asan_options_)); 31 ASSERT_TRUE(env_->SetVar("ASAN_OPTIONS", old_asan_options_));
30 else 32 else
31 env_->UnSetVar("ASAN_OPTIONS"); 33 env_->UnSetVar("ASAN_OPTIONS");
32 } 34 }
33 35
34 protected: 36 protected:
35 scoped_ptr<base::Environment> env_; 37 std::unique_ptr<base::Environment> env_;
36 bool had_asan_options_; 38 bool had_asan_options_;
37 std::string old_asan_options_; 39 std::string old_asan_options_;
38 }; 40 };
39 41
40 SBOX_TESTS_COMMAND int AddressSanitizerTests_Report(int argc, wchar_t** argv) { 42 SBOX_TESTS_COMMAND int AddressSanitizerTests_Report(int argc, wchar_t** argv) {
41 // AddressSanitizer should detect an out of bounds write (heap buffer 43 // AddressSanitizer should detect an out of bounds write (heap buffer
42 // overflow) in this code. 44 // overflow) in this code.
43 volatile int idx = 42; 45 volatile int idx = 42;
44 int *volatile blah = new int[42]; 46 int *volatile blah = new int[42];
45 blah[idx] = 42; 47 blah[idx] = 42;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 size_t last_slash = source_file_basename.find_last_of("/\\"); 100 size_t last_slash = source_file_basename.find_last_of("/\\");
99 last_slash = last_slash == std::string::npos ? 0 : last_slash + 1; 101 last_slash = last_slash == std::string::npos ? 0 : last_slash + 1;
100 ASSERT_TRUE(strstr(data.c_str(), &source_file_basename[last_slash])) 102 ASSERT_TRUE(strstr(data.c_str(), &source_file_basename[last_slash]))
101 << "The stack trace doesn't have a correct filename:\n" << data; 103 << "The stack trace doesn't have a correct filename:\n" << data;
102 } else { 104 } else {
103 LOG(WARNING) << "Not an AddressSanitizer build, skipping the run."; 105 LOG(WARNING) << "Not an AddressSanitizer build, skipping the run.";
104 } 106 }
105 } 107 }
106 108
107 } 109 }
OLDNEW
« no previous file with comments | « sandbox/win/src/acl.cc ('k') | sandbox/win/src/app_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698