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

Side by Side Diff: tools/memory_inspector/tests/mock_adb/adb

Issue 158993002: Add Android-backend to the memory_inspector (prerequisites). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update ps_ext prebuilt sha1 Created 6 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
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # Copyright 2014 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 """Client side of the mock adb (i.e. the one called instead of the actual adb).
7
8 This file is meant to be put in front of the PATH during integration tests, in
9 order to route all the adb calls here and serve them using a pre-configured
10 dictionary (epxected commands -> planned responses).
11 mock_adb.py is the counterpart of this file, and is meant to be used in the
12 unittests for configuring the behavior (i.e. the dictionary) of this script.
13 """
14
15 import json
16 import optparse
17 import os
18 import sys
19
20
21 def main(argv):
22 # Load the dictionary of expected_cmd -> planned_response from the json file
23 # which mock_adb.py creates.
24 with open(os.environ['MOCK_ADB_CFG']) as f:
25 responses = json.load(f)
26
27 # Swallow the irrelevant adb extra arguments (e.g., device id).
28 parser = optparse.OptionParser()
29 parser.add_option('-s')
30 options, args = parser.parse_args(argv[1:])
31 adb_args = ' '.join(args)
32
33 response = ''
34 for (cmd, planned_response) in responses.iteritems():
35 if adb_args.startswith(cmd):
36 response = planned_response
37 print response
38
39 if __name__ == '__main__':
40 main(sys.argv)
OLDNEW
« no previous file with comments | « tools/memory_inspector/tests/mock_adb/__init__.py ('k') | tools/memory_inspector/tests/mock_adb/mock_adb.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698