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

Side by Side Diff: build/android/pylib/flag_changer.py

Issue 11876021: Support startup performance tests on Galaxy S3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: S3 startup performance tests - fixes to file_changer Created 7 years, 11 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 | « build/android/pylib/android_commands.py ('k') | build/android/pylib/perf_tests_helper.py » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 import constants 5 import constants
6 import traceback 6 import traceback
7 import warnings 7 import warnings
8 8
9 9
10 # Location where chrome reads command line flags from 10 # Location where chrome reads command line flags from
11 CHROME_COMMAND_FILE = '/data/local/chrome-command-line' 11 CHROME_COMMAND_FILE = '/data/local/chrome-command-line'
12 CHROME_TEMP_COMMAND_FILE='/sdcard/chrome-command-line-temp'
bulach 2013/01/15 09:51:01 I guess "sdcard" should be "$EXTERNAL_STORAGE"
12 13
13 class FlagChanger(object): 14 class FlagChanger(object):
14 """Changes the flags Chrome runs with. 15 """Changes the flags Chrome runs with.
15 16
16 There are two different use cases for this file: 17 There are two different use cases for this file:
17 * Flags are permanently set by calling Set(). 18 * Flags are permanently set by calling Set().
18 * Flags can be temporarily set for a particular set of unit tests. These 19 * Flags can be temporarily set for a particular set of unit tests. These
19 tests should call Restore() to revert the flags to their original state 20 tests should call Restore() to revert the flags to their original state
20 once the tests have completed. 21 once the tests have completed.
21 """ 22 """
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 def Restore(self): 83 def Restore(self):
83 """Restores the flags to their original state.""" 84 """Restores the flags to their original state."""
84 self._current_flags = self._TokenizeFlags(self._orig_line) 85 self._current_flags = self._TokenizeFlags(self._orig_line)
85 self._UpdateCommandLineFile() 86 self._UpdateCommandLineFile()
86 87
87 def _UpdateCommandLineFile(self): 88 def _UpdateCommandLineFile(self):
88 """Writes out the command line to the file, or removes it if empty.""" 89 """Writes out the command line to the file, or removes it if empty."""
89 print "Current flags: ", self._current_flags 90 print "Current flags: ", self._current_flags
90 91
91 if self._current_flags: 92 if self._current_flags:
92 self._android_cmd.SetFileContents(CHROME_COMMAND_FILE, 93 # The command file is protected, so we have to go via a temp file
94 self._android_cmd.SetFileContents(CHROME_TEMP_COMMAND_FILE,
93 'chrome ' + 95 'chrome ' +
94 ' '.join(self._current_flags)) 96 ' '.join(self._current_flags))
97 self._android_cmd.RunShellCommand('su -c dd if=' +
98 CHROME_TEMP_COMMAND_FILE +
99 ' of=' + CHROME_COMMAND_FILE)
100 self._android_cmd.RunShellCommand('su -c chmod 777 ' +
101 CHROME_COMMAND_FILE)
102 self._android_cmd.RunShellCommand('rm ' + CHROME_TEMP_COMMAND_FILE)
bulach 2013/01/15 09:51:01 we could potentially generate a shell script for t
95 else: 103 else:
96 self._android_cmd.RunShellCommand('rm ' + CHROME_COMMAND_FILE) 104 self._android_cmd.RunShellCommand('su -c rm ' + CHROME_COMMAND_FILE)
97 105
98 def _TokenizeFlags(self, line): 106 def _TokenizeFlags(self, line):
99 """Changes the string containing the command line into a list of flags. 107 """Changes the string containing the command line into a list of flags.
100 108
101 Follows similar logic to CommandLine.java::tokenizeQuotedArguments: 109 Follows similar logic to CommandLine.java::tokenizeQuotedArguments:
102 * Flags are split using whitespace, unless the whitespace is within a 110 * Flags are split using whitespace, unless the whitespace is within a
103 pair of quotation marks. 111 pair of quotation marks.
104 * Unlike the Java version, we keep the quotation marks around switch 112 * Unlike the Java version, we keep the quotation marks around switch
105 values since we need them to re-create the file when new flags are 113 values since we need them to re-create the file when new flags are
106 appended. 114 appended.
(...skipping 28 matching lines...) Expand all
135 143
136 # Tack on the last flag. 144 # Tack on the last flag.
137 if not current_flag: 145 if not current_flag:
138 if within_quotations: 146 if within_quotations:
139 warnings.warn("Unterminated quoted string: " + current_flag) 147 warnings.warn("Unterminated quoted string: " + current_flag)
140 else: 148 else:
141 tokenized_flags.append(current_flag) 149 tokenized_flags.append(current_flag)
142 150
143 # Return everything but the program name. 151 # Return everything but the program name.
144 return tokenized_flags[1:] 152 return tokenized_flags[1:]
OLDNEW
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | build/android/pylib/perf_tests_helper.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698