blob: e819352984e2bf96582c1100238aa92e384c9414 [file] [log] [blame]
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -08001#!/usr/bin/python
2
Yunlian Jiang04dc5dc2013-04-23 15:05:05 -07003# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -08006
Ahmad Sharif4467f002012-12-20 12:09:49 -08007"""The label of benchamrks."""
8
9import os
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -080010from utils.file_utils import FileUtils
11
12
13class Label(object):
Ahmad Sharif4467f002012-12-20 12:09:49 -080014 def __init__(self, name, chromeos_image, chromeos_root, board, remote,
Yunlian Jiang04dc5dc2013-04-23 15:05:05 -070015 image_args, image_md5sum, cache_dir, chrome_src=None):
Ahmad Sharif4467f002012-12-20 12:09:49 -080016 # Expand ~
17 chromeos_root = os.path.expanduser(chromeos_root)
18 chromeos_image = os.path.expanduser(chromeos_image)
19
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -080020 self.name = name
21 self.chromeos_image = chromeos_image
22 self.board = board
Ahmad Sharif4467f002012-12-20 12:09:49 -080023 self.remote = remote
24 self.image_args = image_args
Luis Lozanof81680c2013-03-15 14:44:13 -070025 self.image_md5sum = image_md5sum
26 self.cache_dir = cache_dir
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -080027
28 if not chromeos_root:
29 chromeos_root = FileUtils().ChromeOSRootFromImage(chromeos_image)
30 if not chromeos_root:
31 raise Exception("No ChromeOS root given for label '%s' and could not "
32 "determine one from image path: '%s'." %
33 (name, chromeos_image))
34 else:
35 chromeos_root = FileUtils().CanonicalizeChromeOSRoot(chromeos_root)
36 if not chromeos_root:
37 raise Exception("Invalid ChromeOS root given for label '%s': '%s'."
38 % (name, chromeos_root))
39
40 self.chromeos_root = chromeos_root
Yunlian Jiang04dc5dc2013-04-23 15:05:05 -070041 if not chrome_src:
42 self.chrome_src = os.path.join(self.chromeos_root,
43 "chroot/var/cache/chromeos-chrome/chrome-src-internal/src")
44 else:
45 chromeos_root = FileUtils().CanonicalizeChromeOSRoot(chrome_src)
Ahmad Sharif4467f002012-12-20 12:09:49 -080046
47
48class MockLabel(object):
49 def __init__(self, name, chromeos_image, chromeos_root, board, remote,
Luis Lozanof81680c2013-03-15 14:44:13 -070050 image_args, image_md5sum, cache_dir):
Ahmad Sharif4467f002012-12-20 12:09:49 -080051 self.name = name
52 self.chromeos_image = chromeos_image
53 self.board = board
54 self.remote = remote
Luis Lozanof81680c2013-03-15 14:44:13 -070055 self.cache_dir = cache_dir
Ahmad Sharif4467f002012-12-20 12:09:49 -080056 if not chromeos_root:
57 self.chromeos_root = "/tmp/chromeos_root"
58 else:
59 self.chromeos_root = chromeos_root
60 self.image_args = image_args
Luis Lozanof81680c2013-03-15 14:44:13 -070061 self.image_md5sum = image_md5sum