blob: 365b8cbdeb3f612a7874a0b18a042a6a59c54b2c [file] [log] [blame]
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -08001#!/usr/bin/python
2
Yunlian Jiang00cc30e2013-03-28 13:23:57 -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.
6
Ahmad Sharif4467f002012-12-20 12:09:49 -08007"""Setting files for global, benchmark and labels."""
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -08008
9from field import BooleanField
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -080010from field import FloatField
11from field import IntegerField
12from field import ListField
13from field import TextField
14from settings import Settings
15
16
17class BenchmarkSettings(Settings):
18 def __init__(self, name):
19 super(BenchmarkSettings, self).__init__(name, "benchmark")
Yunlian Jiang04dc5dc2013-04-23 15:05:05 -070020 self.AddField(TextField("test_name",
21 description="The name of the test to run."
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -080022 "Defaults to the name of the benchmark."))
Yunlian Jiang04dc5dc2013-04-23 15:05:05 -070023 self.AddField(TextField("test_args",
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -080024 description="Arguments to be passed to the "
Yunlian Jiang04dc5dc2013-04-23 15:05:05 -070025 "test."))
Ahmad Sharifee988c82012-05-14 17:11:56 -070026 self.AddField(IntegerField("iterations", default=1,
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -080027 description="Number of iterations to run the "
Yunlian Jiang04dc5dc2013-04-23 15:05:05 -070028 "test."))
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -080029 self.AddField(FloatField("outlier_range", default=0.2,
30 description="The percentage of highest/lowest "
31 "values to omit when computing the average."))
Luis Lozanof81680c2013-03-15 14:44:13 -070032 self.AddField(BooleanField("rm_chroot_tmp", default=False,
33 description="Whether remove the run_remote_test"
34 "result in the chroot"))
35 self.AddField(BooleanField("key_results_only", default=True,
36 description="Whether only show the key results"
37 "of pyautoperf"))
Ahmad Shariff395c262012-10-09 17:48:09 -070038 self.AddField(TextField("perf_args", default="",
39 description="The optional profile command. It "
40 "enables perf commands to record perforamance "
41 "related counters. It must start with perf "
42 "command record or stat followed by arguments."))
Yunlian Jiang04dc5dc2013-04-23 15:05:05 -070043 self.AddField(TextField("suite", default="pyauto",
44 description="The type of the benchmark"))
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -080045
46
47class LabelSettings(Settings):
48 def __init__(self, name):
49 super(LabelSettings, self).__init__(name, "label")
50 self.AddField(TextField("chromeos_image", required=True,
51 description="The path to the image to run tests "
52 "on."))
53 self.AddField(TextField("chromeos_root",
54 description="The path to a chromeos checkout which "
55 "contains a src/scripts directory. Defaults to "
56 "the chromeos checkout which contains the "
57 "chromeos_image."))
Luis Lozanof81680c2013-03-15 14:44:13 -070058 self.AddField(TextField("md5sum", default="",
59 description="The md5sum of this image"))
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -080060 self.AddField(TextField("board", required=True, description="The target "
61 "board for running experiments on, e.g. x86-alex."))
Ahmad Sharif4467f002012-12-20 12:09:49 -080062 self.AddField(ListField("remote", description=
63 "A comma-separated list of ip's of chromeos"
64 "devices to run experiments on."))
65 self.AddField(TextField("image_args", required=False,
66 default="",
67 description="Extra arguments to pass to "
68 "image_chromeos.py."))
Luis Lozanof81680c2013-03-15 14:44:13 -070069 self.AddField(TextField("cache_dir", default="",
70 description="The cache dir for this image."))
Yunlian Jiang04dc5dc2013-04-23 15:05:05 -070071 self.AddField(TextField("chrome_src",
72 description="The path to the source of chrome. "
73 "This is used to run telemetry benchmarks. "
74 "The default one is the src inside chroot.",
75 required=False, default=""))
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -080076
77
78class GlobalSettings(Settings):
79 def __init__(self, name):
80 super(GlobalSettings, self).__init__(name, "global")
Ahmad Sharif822c55d2012-02-08 20:55:47 -080081 self.AddField(TextField("name",
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -080082 description="The name of the experiment. Just an "
83 "identifier."))
84 self.AddField(TextField("board", description="The target "
85 "board for running experiments on, e.g. x86-alex."))
Ahmad Sharif4467f002012-12-20 12:09:49 -080086 self.AddField(ListField("remote",
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -080087 description="A comma-separated list of ip's of "
88 "chromeos devices to run experiments on."))
89 self.AddField(BooleanField("rerun_if_failed", description="Whether to "
Yunlian Jiang04dc5dc2013-04-23 15:05:05 -070090 "re-run failed test runs or not.",
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -080091 default=False))
Luis Lozanof81680c2013-03-15 14:44:13 -070092 self.AddField(BooleanField("rm_chroot_tmp", default=False,
93 description="Whether remove the run_remote_test"
94 "result in the chroot"))
Ahmad Shariff395c262012-10-09 17:48:09 -070095 self.AddField(ListField("email", description="Space-seperated"
Ahmad Sharif4467f002012-12-20 12:09:49 -080096 "list of email addresses to send email to."))
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -080097 self.AddField(BooleanField("rerun", description="Whether to ignore the "
Yunlian Jiang04dc5dc2013-04-23 15:05:05 -070098 "cache and for tests to be re-run.",
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -080099 default=False))
Ahmad Sharif4467f002012-12-20 12:09:49 -0800100 self.AddField(BooleanField("same_specs", default=True,
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -0800101 description="Ensure cached runs are run on the "
Ahmad Sharif4467f002012-12-20 12:09:49 -0800102 "same kind of devices which are specified as a "
103 "remote."))
104 self.AddField(BooleanField("same_machine", default=False,
105 description="Ensure cached runs are run on the "
106 "exact the same remote"))
Ahmad Sharifee988c82012-05-14 17:11:56 -0700107 self.AddField(IntegerField("iterations", default=1,
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -0800108 description="Number of iterations to run all "
Yunlian Jiang04dc5dc2013-04-23 15:05:05 -0700109 "tests."))
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -0800110 self.AddField(TextField("chromeos_root",
111 description="The path to a chromeos checkout which "
112 "contains a src/scripts directory. Defaults to "
113 "the chromeos checkout which contains the "
114 "chromeos_image."))
Luis Lozanof81680c2013-03-15 14:44:13 -0700115 self.AddField(BooleanField("key_results_only", default=True,
116 description="Whether only show the key results"
117 "of pyautoperf"))
118 self.AddField(IntegerField("acquire_timeout", default=0,
119 description="Number of seconds to wait for "
120 "machine before exit if all the machines in "
121 "the experiment file are busy. Default is 0"))
Ahmad Shariff395c262012-10-09 17:48:09 -0700122 self.AddField(TextField("perf_args", default="",
123 description="The optional profile command. It "
124 "enables perf commands to record perforamance "
125 "related counters. It must start with perf "
126 "command record or stat followed by arguments."))
Luis Lozanof81680c2013-03-15 14:44:13 -0700127 self.AddField(TextField("cache_dir", default="",
128 description="The abs path of cache dir. "
129 "Default is /home/$(whoami)/cros_scratch."))
130 self.AddField(BooleanField("no_email", default=False,
131 description="Whether to disable the email to "
132 "user after crosperf finishes."))
133 self.AddField(TextField("share_users", default="",
134 description="Who's cache data you want to "
135 "use. It accepts multiple users seperated by \",\""))
Yunlian Jiang00cc30e2013-03-28 13:23:57 -0700136 self.AddField(TextField("results_dir", default="",
137 description="The results dir"))
Yunlian Jiang04dc5dc2013-04-23 15:05:05 -0700138 self.AddField(TextField("chrome_src",
139 description="The path to the source of chrome. "
140 "This is used to run telemetry benchmarks. "
141 "The default one is the src inside chroot.",
142
143 required=False, default=""))
Ahmad Sharif0dcbc4b2012-02-02 16:37:18 -0800144
145
146class SettingsFactory(object):
147 """Factory class for building different types of Settings objects.
148
149 This factory is currently hardcoded to produce settings for ChromeOS
150 experiment files. The idea is that in the future, other types
151 of settings could be produced.
152 """
153
154 def GetSettings(self, name, settings_type):
155 if settings_type == "label" or not settings_type:
156 return LabelSettings(name)
157 if settings_type == "global":
158 return GlobalSettings(name)
159 if settings_type == "benchmark":
160 return BenchmarkSettings(name)
161
162 raise Exception("Invalid settings type: '%s'." % settings_type)