aboutsummaryrefslogtreecommitdiff
path: root/crosperf
diff options
context:
space:
mode:
authorCaroline Tice <cmtice@google.com>2015-09-02 09:51:34 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-09-03 18:02:23 -0700
commit225fc17884a659647ed53ffd305b5e87533c18eb (patch)
treeeac8b461fd5b2269f7e5ed0469f0eb154c1cf977 /crosperf
parent98351672bfc0c9082081a22f27282e0bfc471b99 (diff)
downloadtoolchain-utils-225fc17884a659647ed53ffd305b5e87533c18eb.tar.gz
Make ParseChromeosImage globally callable.
Move the _ParseChromeosImage out of the JSONResultsReport class, and make it a global function, so it can be easily called from other places. BUG=None TEST=Tested with and without generating json reports, with the function moved, and everything still works. Change-Id: I71c0435e0da9e687f69b4cebd5e3f36764d495e1 Reviewed-on: https://chrome-internal-review.googlesource.com/228840 Commit-Ready: Caroline Tice <cmtice@google.com> Tested-by: Caroline Tice <cmtice@google.com> Reviewed-by: Caroline Tice <cmtice@google.com>
Diffstat (limited to 'crosperf')
-rw-r--r--crosperf/results_report.py91
1 files changed, 46 insertions, 45 deletions
diff --git a/crosperf/results_report.py b/crosperf/results_report.py
index 9d1d2be8..e04baae9 100644
--- a/crosperf/results_report.py
+++ b/crosperf/results_report.py
@@ -16,6 +16,51 @@ from results_organizer import ResultOrganizer
from perf_table import PerfTable
+def ParseChromeosImage(chromeos_image):
+ """Parse the chromeos_image string for the image and version.
+
+ The chromeos_image string will probably be in one of two formats:
+ 1: <path-to-chroot>/src/build/images/<board>/<ChromeOS-version>.<datetime>/ \
+ chromiumos_test_image.bin
+ 2: <path-to-chroot>/chroot/tmp/<buildbot-build>/<ChromeOS-version>/ \
+ chromiumos_test_image.bin
+
+ We parse these strings to find the 'chromeos_version' to store in the
+ json archive (without the .datatime bit in the first case); and also
+ the 'chromeos_image', which would be all of the first case, but only the
+ part after '/chroot/tmp' in the second case.
+
+ Args:
+ chromeos_image: String containing the path to the chromeos_image that
+ crosperf used for the test.
+
+ Returns:
+ version, image: The results of parsing the input string, as explained
+ above.
+ """
+ version = ''
+ real_file = os.path.realpath(os.path.expanduser(chromeos_image))
+ pieces = real_file.split('/')
+ # Find the Chromeos Version, e.g. R45-2345.0.0.....
+ # chromeos_image should have been something like:
+ # <path>/<board-trybot-release>/<chromeos-version>/chromiumos_test_image.bin"
+ num_pieces = len(pieces)
+ if pieces[num_pieces-1] == "chromiumos_test_image.bin":
+ version = pieces[num_pieces-2]
+ # Find last '.' in the version and chop it off (removing the .datatime
+ # piece from local builds).
+ loc = version.rfind('.')
+ version = version[:loc]
+ # Find the chromeos image. If it's somewhere in .../chroot/tmp/..., then
+ # it's an official image that got downloaded, so chop off the download path
+ # to make the official image name more clear.
+ loc = real_file.find('/chroot/tmp')
+ if loc != -1:
+ loc += len('/chroot/tmp')
+ real_file = real_file[loc:]
+ image = real_file
+ return version,image
+
class ResultsReport(object):
MAX_COLOR_CODE = 255
PERF_ROWS = 5
@@ -534,50 +579,6 @@ class JSONResultsReport(ResultsReport):
self.date = date
self.time = time
-
- def _ParseChromeosImage(self, chromeos_image):
- """Parse the chromeos_image string for the image and version.
-
- The chromeos_image string will probably be in one of two formats:
- 1: <path-to-chroot>/src/build/images/<board>/<ChromeOS-version>.<datetime>/chromiumos_test_image.bin
- 2: <path-to-chroot>/chroot/tmp/<buildbot-build>/<ChromeOS-version>/chromiumos_test_image.bin
-
- We parse these strings to find the 'chromeos_version' to store in the
- json archive (without the .datatime bit in the first case); and also
- the 'chromeos_image', which would be all of the first case, but only the
- part after '/chroot/tmp' in the second case.
-
- Args:
- chromeos_image: String containing the path to the chromeos_image that
- crosperf used for the test.
-
- Returns:
- version, image: The results of parsing the input string, as explained
- above.
- """
- version = ''
- real_file = os.path.realpath(os.path.expanduser(chromeos_image))
- pieces = real_file.split('/')
- # Find the Chromeos Version, e.g. R45-2345.0.0.....
- # chromeos_image should have been something like:
- # <path>/<board-trybot-release>/<chromeos-version>/chromiumos_test_image.bin"
- num_pieces = len(pieces)
- if pieces[num_pieces-1] == "chromiumos_test_image.bin":
- version = pieces[num_pieces-2]
- # Find last '.' in the version and chop it off (removing the .datatime
- # piece from local builds).
- loc = version.rfind('.')
- version = version[:loc]
- # Find the chromeos image. If it's somewhere in .../chroot/tmp/..., then
- # it's an official image that got downloaded, so chop off the download path
- # to make the official image name more clear.
- loc = real_file.find('/chroot/tmp')
- if loc != -1:
- loc += len('/chroot/tmp')
- real_file = real_file[loc:]
- image = real_file
- return version,image
-
def GetReport(self, results_dir):
self.defaults.ReadDefaultsFile()
final_results = []
@@ -593,7 +594,7 @@ class JSONResultsReport(ResultsReport):
json_results['board'] = board
for l in self.experiment.labels:
if l.name == label:
- ver, img = self._ParseChromeosImage(l.chromeos_image)
+ ver, img = ParseChromeosImage(l.chromeos_image)
json_results['chromeos_image'] = img
json_results['chromeos_version'] = ver
break