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

Side by Side Diff: net/base/run_all_unittests.cc

Issue 24006: Work around a Purify bug by making an object used by NetTestSuite stack alloc... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « net/base/host_resolver_unittest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008, Google Inc. 1 // Copyright 2008, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 16 matching lines...) Expand all
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 #include "base/message_loop.h" 30 #include "base/message_loop.h"
31 #include "base/ref_counted.h" 31 #include "base/ref_counted.h"
32 #include "base/test_suite.h" 32 #include "base/test_suite.h"
33 #include "net/base/host_resolver_unittest.h" 33 #include "net/base/host_resolver_unittest.h"
34 34
35 class NetTestSuite : public TestSuite { 35 class NetTestSuite : public TestSuite {
36 public: 36 public:
37 NetTestSuite(int argc, char** argv) 37 NetTestSuite(int argc, char** argv) : TestSuite(argc, argv) {
38 : TestSuite(argc, argv),
39 host_mapper_(new net::RuleBasedHostMapper()),
40 scoped_host_mapper_(host_mapper_.get()) {
41 // In case any attempts are made to resolve host names, force them all to
42 // be mapped to localhost. This prevents DNS queries from being sent in
43 // the process of running these unit tests.
44 host_mapper_->AddRule("*", "127.0.0.1");
45 } 38 }
46 39
47 virtual void Initialize() { 40 virtual void Initialize() {
48 TestSuite::Initialize(); 41 TestSuite::Initialize();
49 42
43 host_mapper_ = new net::RuleBasedHostMapper();
44 scoped_host_mapper_.Init(host_mapper_.get());
45 // In case any attempts are made to resolve host names, force them all to
46 // be mapped to localhost. This prevents DNS queries from being sent in
47 // the process of running these unit tests.
48 host_mapper_->AddRule("*", "127.0.0.1");
49
50 message_loop_.reset(new MessageLoopForIO()); 50 message_loop_.reset(new MessageLoopForIO());
51 } 51 }
52 52
53 virtual void Shutdown() { 53 virtual void Shutdown() {
54 // We want to destroy this here before the TestSuite continues to tear down 54 // We want to destroy this here before the TestSuite continues to tear down
55 // the environment. 55 // the environment.
56 message_loop_.reset(); 56 message_loop_.reset();
57 57
58 TestSuite::Shutdown(); 58 TestSuite::Shutdown();
59 } 59 }
60 60
61 private: 61 private:
62 scoped_ptr<MessageLoop> message_loop_; 62 scoped_ptr<MessageLoop> message_loop_;
63 scoped_refptr<net::RuleBasedHostMapper> host_mapper_; 63 scoped_refptr<net::RuleBasedHostMapper> host_mapper_;
64 net::ScopedHostMapper scoped_host_mapper_; 64 net::ScopedHostMapper scoped_host_mapper_;
65 }; 65 };
66 66
67 int main(int argc, char** argv) { 67 int main(int argc, char** argv) {
68 return NetTestSuite(argc, argv).Run(); 68 return NetTestSuite(argc, argv).Run();
69 } 69 }
OLDNEW
« no previous file with comments | « net/base/host_resolver_unittest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698