Caroline Tice | 4bd7046 | 2016-10-05 15:41:13 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python2 |
Ting-Yuan Huang | 4f59a62 | 2017-08-16 12:32:56 -0700 | [diff] [blame] | 2 | # |
| 3 | # Copyright 2017 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. |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 6 | """Script for running llvm validation tests on ChromeOS. |
| 7 | |
| 8 | This script launches a buildbot to build ChromeOS with the llvm on |
| 9 | a particular board; then it finds and downloads the trybot image and the |
| 10 | corresponding official image, and runs test for correctness. |
| 11 | It then generates a report, emails it to the c-compiler-chrome, as |
| 12 | well as copying the result into a directory. |
| 13 | """ |
| 14 | |
| 15 | # Script to test different toolchains against ChromeOS benchmarks. |
| 16 | |
| 17 | from __future__ import print_function |
| 18 | |
| 19 | import argparse |
| 20 | import datetime |
| 21 | import os |
| 22 | import sys |
| 23 | import time |
| 24 | |
Caroline Tice | a8af9a7 | 2016-07-20 12:52:59 -0700 | [diff] [blame] | 25 | from cros_utils import command_executer |
| 26 | from cros_utils import logger |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 27 | |
Caroline Tice | a8af9a7 | 2016-07-20 12:52:59 -0700 | [diff] [blame] | 28 | from cros_utils import buildbot_utils |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 29 | |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 30 | CROSTC_ROOT = '/usr/local/google/crostc' |
| 31 | ROLE_ACCOUNT = 'mobiletc-prebuild' |
| 32 | TOOLCHAIN_DIR = os.path.dirname(os.path.realpath(__file__)) |
| 33 | MAIL_PROGRAM = '~/var/bin/mail-sheriff' |
| 34 | VALIDATION_RESULT_DIR = os.path.join(CROSTC_ROOT, 'validation_result') |
| 35 | START_DATE = datetime.date(2016, 1, 1) |
Manoj Gupta | dd8675b | 2018-01-25 10:59:06 -0800 | [diff] [blame] | 36 | TEST_PER_DAY = 4 |
Caroline Tice | 09cacd0 | 2017-08-11 13:02:29 -0700 | [diff] [blame] | 37 | |
| 38 | # Information about Rotating Boards |
Rahul Chaudhry | edcf3d3 | 2018-01-30 13:50:37 -0800 | [diff] [blame^] | 39 | # Board Arch Reference Platform Kernel |
| 40 | # Board Version |
| 41 | # ------------ ------- ------------ ------------- ------- |
| 42 | # caroline x86_64 glados skylake-y 3.18 |
| 43 | # daisy armv7 daisy exynos-5250 3.8.11 |
| 44 | # elm aarch64 oak mediatek-8173 3.18 |
| 45 | # eve x86_64 poppy kabylake-y 4.4.* |
| 46 | # fizz x86_64 fizz kabylake-u/r 4.4.* |
| 47 | # gale armv7 3.18 |
| 48 | # guado_moblab x86_64 3.14 |
| 49 | # kahlee x86_64 kahlee stoney ridge 4.14.* |
| 50 | # kevin aarch64 gru rockchip-3399 4.4.* |
| 51 | # lakitu x86_64 4.4.* |
| 52 | # link x86_64 ivybridge ivybridge 3.8.11 |
| 53 | # lumpy x86_64 -- sandybridge 3.8.11 |
| 54 | # nyan_big armv7 nyan tegra 3.10.18 |
| 55 | # peach_pit armv7 peach exynos-5420 3.8.11 |
| 56 | # peppy x86_64 slippy haswell 3.8.11 |
| 57 | # pyro x86_64 reef apollo lake 4.4.* |
| 58 | # samus x86_64 auron broadwell 3.14 |
| 59 | # sentry x86_64 kunimitsu skylake-u 3.18 |
| 60 | # swanky x86_64 rambi baytrail 4.4.* |
| 61 | # terra x86_64 strago braswell 3.18 |
| 62 | # veyron_jaq armv7 veyron-pinky rockchip-3288 3.14 |
| 63 | # whirlwind armv7 3.14 |
| 64 | # zoombini x86_64 zoombini cannonlake-y 4.14.* |
Caroline Tice | 09cacd0 | 2017-08-11 13:02:29 -0700 | [diff] [blame] | 65 | |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 66 | TEST_BOARD = [ |
Caroline Tice | 09cacd0 | 2017-08-11 13:02:29 -0700 | [diff] [blame] | 67 | 'caroline', |
| 68 | 'daisy', |
Rahul Chaudhry | edcf3d3 | 2018-01-30 13:50:37 -0800 | [diff] [blame^] | 69 | # 'elm', tested by arm64-llvm-next-toolchain builder. |
Caroline Tice | 09cacd0 | 2017-08-11 13:02:29 -0700 | [diff] [blame] | 70 | 'eve', |
Manoj Gupta | 470bbf5 | 2018-01-23 09:54:28 -0800 | [diff] [blame] | 71 | 'fizz', |
Caroline Tice | 09cacd0 | 2017-08-11 13:02:29 -0700 | [diff] [blame] | 72 | 'gale', |
Manoj Gupta | dd8675b | 2018-01-25 10:59:06 -0800 | [diff] [blame] | 73 | 'guado_moblab', |
Manoj Gupta | fc7d1e6 | 2018-01-16 16:21:18 -0800 | [diff] [blame] | 74 | 'kahlee', |
Caroline Tice | 09cacd0 | 2017-08-11 13:02:29 -0700 | [diff] [blame] | 75 | 'kevin', |
Caroline Tice | 856bc6c | 2017-06-29 16:21:43 -0700 | [diff] [blame] | 76 | 'lakitu', |
Caroline Tice | 09cacd0 | 2017-08-11 13:02:29 -0700 | [diff] [blame] | 77 | 'link', |
| 78 | 'lumpy', |
| 79 | 'nyan_big', |
| 80 | 'peach_pit', |
| 81 | 'peppy', |
Manoj Gupta | ac5072d | 2017-09-29 10:51:20 -0700 | [diff] [blame] | 82 | 'pyro', |
Rahul Chaudhry | edcf3d3 | 2018-01-30 13:50:37 -0800 | [diff] [blame^] | 83 | # 'samus', tested by amd64-llvm-next-toolchain builder. |
Caroline Tice | 09cacd0 | 2017-08-11 13:02:29 -0700 | [diff] [blame] | 84 | 'sentry', |
Manoj Gupta | ac5072d | 2017-09-29 10:51:20 -0700 | [diff] [blame] | 85 | 'swanky', |
Caroline Tice | 09cacd0 | 2017-08-11 13:02:29 -0700 | [diff] [blame] | 86 | 'terra', |
Rahul Chaudhry | edcf3d3 | 2018-01-30 13:50:37 -0800 | [diff] [blame^] | 87 | # 'veyron_jaq', tested by arm-llvm-next-toolchain builder. |
Caroline Tice | 856bc6c | 2017-06-29 16:21:43 -0700 | [diff] [blame] | 88 | 'whirlwind', |
Manoj Gupta | 470bbf5 | 2018-01-23 09:54:28 -0800 | [diff] [blame] | 89 | 'zoombini', |
Caroline Tice | a12e974 | 2016-09-08 13:35:02 -0700 | [diff] [blame] | 90 | ] |
| 91 | |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 92 | |
| 93 | class ToolchainVerifier(object): |
| 94 | """Class for the toolchain verifier.""" |
| 95 | |
Caroline Tice | a12e974 | 2016-09-08 13:35:02 -0700 | [diff] [blame] | 96 | def __init__(self, board, chromeos_root, weekday, patches, compiler): |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 97 | self._board = board |
| 98 | self._chromeos_root = chromeos_root |
| 99 | self._base_dir = os.getcwd() |
| 100 | self._ce = command_executer.GetCommandExecuter() |
| 101 | self._l = logger.GetLogger() |
Caroline Tice | 314ea56 | 2016-06-24 15:59:01 -0700 | [diff] [blame] | 102 | self._compiler = compiler |
Yunlian Jiang | bddbcd3 | 2017-11-27 10:59:30 -0800 | [diff] [blame] | 103 | self._build = '%s-%s-toolchain-tryjob' % (board, compiler) |
Caroline Tice | de60077 | 2016-10-18 15:27:51 -0700 | [diff] [blame] | 104 | self._patches = patches.split(',') if patches else [] |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 105 | self._patches_string = '_'.join(str(p) for p in self._patches) |
| 106 | |
| 107 | if not weekday: |
| 108 | self._weekday = time.strftime('%a') |
| 109 | else: |
| 110 | self._weekday = weekday |
Caroline Tice | d00ad41 | 2016-07-02 18:00:18 -0700 | [diff] [blame] | 111 | self._reports = os.path.join(VALIDATION_RESULT_DIR, compiler, board) |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 112 | |
| 113 | def _FinishSetup(self): |
| 114 | """Make sure testing_rsa file is properly set up.""" |
| 115 | # Fix protections on ssh key |
| 116 | command = ('chmod 600 /var/cache/chromeos-cache/distfiles/target' |
| 117 | '/chrome-src-internal/src/third_party/chromite/ssh_keys' |
| 118 | '/testing_rsa') |
| 119 | ret_val = self._ce.ChrootRunCommand(self._chromeos_root, command) |
| 120 | if ret_val != 0: |
| 121 | raise RuntimeError('chmod for testing_rsa failed') |
| 122 | |
Caroline Tice | 9c4003a | 2017-11-07 16:37:33 -0800 | [diff] [blame] | 123 | def DoAll(self, crostc_dir): |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 124 | """Main function inside ToolchainComparator class. |
| 125 | |
| 126 | Launch trybot, get image names, create crosperf experiment file, run |
| 127 | crosperf, and copy images into seven-day report directories. |
| 128 | """ |
| 129 | date_str = datetime.date.today() |
| 130 | description = 'master_%s_%s_%s' % (self._patches_string, self._build, |
| 131 | date_str) |
Caroline Tice | 9c4003a | 2017-11-07 16:37:33 -0800 | [diff] [blame] | 132 | if crostc_dir: |
| 133 | _ = buildbot_utils.GetTrybotImage( |
| 134 | self._chromeos_root, |
| 135 | self._build, |
| 136 | self._patches, |
| 137 | description, |
| 138 | tryjob_flags=['--hwtest'], |
| 139 | credentials_dir=crostc_dir, |
| 140 | async=True) |
| 141 | else: |
| 142 | _ = buildbot_utils.GetTrybotImage( |
| 143 | self._chromeos_root, |
| 144 | self._build, |
| 145 | self._patches, |
| 146 | description, |
| 147 | tryjob_flags=['--hwtest'], |
| 148 | async=True) |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 149 | |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 150 | return 0 |
| 151 | |
Manoj Gupta | d575b8a | 2017-03-08 10:51:28 -0800 | [diff] [blame] | 152 | |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 153 | def Main(argv): |
| 154 | """The main function.""" |
| 155 | |
| 156 | # Common initializations |
| 157 | command_executer.InitCommandExecuter() |
| 158 | parser = argparse.ArgumentParser() |
Caroline Tice | a12e974 | 2016-09-08 13:35:02 -0700 | [diff] [blame] | 159 | parser.add_argument( |
| 160 | '--chromeos_root', |
| 161 | dest='chromeos_root', |
| 162 | help='The chromeos root from which to run tests.') |
| 163 | parser.add_argument( |
| 164 | '--weekday', |
| 165 | default='', |
| 166 | dest='weekday', |
| 167 | help='The day of the week for which to run tests.') |
| 168 | parser.add_argument( |
| 169 | '--board', default='', dest='board', help='The board to test.') |
| 170 | parser.add_argument( |
| 171 | '--patch', |
| 172 | dest='patches', |
Caroline Tice | de60077 | 2016-10-18 15:27:51 -0700 | [diff] [blame] | 173 | default='', |
Caroline Tice | a12e974 | 2016-09-08 13:35:02 -0700 | [diff] [blame] | 174 | help='The patches to use for the testing, ' |
| 175 | "seprate the patch numbers with ',' " |
| 176 | 'for more than one patches.') |
| 177 | parser.add_argument( |
| 178 | '--compiler', |
| 179 | dest='compiler', |
Caroline Tice | 4bd7046 | 2016-10-05 15:41:13 -0700 | [diff] [blame] | 180 | help='Which compiler (llvm, llvm-next or gcc) to use for ' |
Caroline Tice | a12e974 | 2016-09-08 13:35:02 -0700 | [diff] [blame] | 181 | 'testing.') |
Caroline Tice | 9c4003a | 2017-11-07 16:37:33 -0800 | [diff] [blame] | 182 | parser.add_argument( |
| 183 | '--crostc_dir', |
| 184 | dest='crostc_dir', |
| 185 | help='Path to the directory containing the ' |
| 186 | 'chromeos-toolchain-credentials.json file; normally in the ' |
| 187 | 'crostc repo.') |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 188 | |
| 189 | options = parser.parse_args(argv[1:]) |
| 190 | if not options.chromeos_root: |
| 191 | print('Please specify the ChromeOS root directory.') |
| 192 | return 1 |
Caroline Tice | 314ea56 | 2016-06-24 15:59:01 -0700 | [diff] [blame] | 193 | if not options.compiler: |
Caroline Tice | 4bd7046 | 2016-10-05 15:41:13 -0700 | [diff] [blame] | 194 | print('Please specify which compiler to test (gcc, llvm, or llvm-next).') |
Caroline Tice | 314ea56 | 2016-06-24 15:59:01 -0700 | [diff] [blame] | 195 | return 1 |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 196 | |
| 197 | if options.board: |
| 198 | fv = ToolchainVerifier(options.board, options.chromeos_root, |
Manoj Gupta | d575b8a | 2017-03-08 10:51:28 -0800 | [diff] [blame] | 199 | options.weekday, options.patches, options.compiler) |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 200 | return fv.Doall() |
| 201 | |
| 202 | today = datetime.date.today() |
| 203 | delta = today - START_DATE |
| 204 | days = delta.days |
| 205 | |
| 206 | start_board = (days * TEST_PER_DAY) % len(TEST_BOARD) |
| 207 | for i in range(TEST_PER_DAY): |
Yunlian Jiang | 54e72b3 | 2016-06-21 14:13:03 -0700 | [diff] [blame] | 208 | try: |
Caroline Tice | a12e974 | 2016-09-08 13:35:02 -0700 | [diff] [blame] | 209 | board = TEST_BOARD[(start_board + i) % len(TEST_BOARD)] |
| 210 | fv = ToolchainVerifier(board, options.chromeos_root, options.weekday, |
Manoj Gupta | 86fe1ed | 2017-03-09 10:37:35 -0800 | [diff] [blame] | 211 | options.patches, options.compiler) |
Caroline Tice | 9c4003a | 2017-11-07 16:37:33 -0800 | [diff] [blame] | 212 | fv.DoAll(options.crostc_dir) |
Yunlian Jiang | 54e72b3 | 2016-06-21 14:13:03 -0700 | [diff] [blame] | 213 | except SystemExit: |
Caroline Tice | d00ad41 | 2016-07-02 18:00:18 -0700 | [diff] [blame] | 214 | logfile = os.path.join(VALIDATION_RESULT_DIR, options.compiler, board) |
Yunlian Jiang | 54e72b3 | 2016-06-21 14:13:03 -0700 | [diff] [blame] | 215 | with open(logfile, 'w') as f: |
Caroline Tice | a12e974 | 2016-09-08 13:35:02 -0700 | [diff] [blame] | 216 | f.write('Verifier got an exception, please check the log.\n') |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 217 | |
Caroline Tice | a12e974 | 2016-09-08 13:35:02 -0700 | [diff] [blame] | 218 | |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 219 | if __name__ == '__main__': |
| 220 | retval = Main(sys.argv) |
| 221 | sys.exit(retval) |