OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 """Wraps the upstream safebrowsing_test_server.py to run in Chrome tests.""" | |
7 | |
8 import os | |
9 import sys | |
10 | |
11 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | |
12 | |
13 sys.path.append(os.path.join(BASE_DIR, '..', '..', '..', 'net', | |
14 'tools', 'testserver')) | |
15 import testserver_base | |
16 | |
17 | |
18 class ServerRunner(testserver_base.TestServerRunner): | |
Nico
2012/09/04 20:11:20
docstring
| |
19 def create_server(self, server_data): | |
20 sys.path.append(os.path.join(BASE_DIR, '..', '..', '..', 'third_party', | |
21 'safe_browsing', 'testing')) | |
22 import safebrowsing_test_server | |
23 server = safebrowsing_test_server.SetupServer( | |
24 self.options.data_file, self.options.host, self.options.port, | |
25 opt_enforce_caching=False, opt_validate_database=True) | |
26 print 'Safebrowsing HTTP server started on port %d...' % server.server_port | |
27 server_data['port'] = server.server_port | |
28 | |
29 return server | |
30 | |
31 def add_options(self): | |
32 testserver_base.TestServerRunner.add_options(self) | |
33 self.option_parser.add_option('--data-file', dest='data_file', | |
34 help='File containing safebrowsing test ' | |
35 'data and expectations') | |
36 # TODO(mattm): we define an unnecessary --data-dir option because | |
37 # BaseTestServer unconditionally sets --data-dir. This should be removed | |
38 # when BaseTestServer is refactored to not contain all the net/ | |
39 # test_server.py specific stuff. | |
40 self.option_parser.add_option('--data-dir', dest='data_dir', | |
41 help='unused') | |
42 | |
43 | |
44 if __name__ == '__main__': | |
45 sys.exit(ServerRunner().main()) | |
OLD | NEW |