Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Tiancong Wang | cca93c3 | 2019-03-19 14:42:27 -0700 | [diff] [blame] | 2 | # -*- coding: utf-8 -*- |
Ting-Yuan Huang | 4f59a62 | 2017-08-16 12:32:56 -0700 | [diff] [blame] | 3 | # |
| 4 | # Copyright 2017 The Chromium OS Authors. All rights reserved. |
| 5 | # Use of this source code is governed by a BSD-style license that can be |
| 6 | # found in the LICENSE file. |
Tiancong Wang | cca93c3 | 2019-03-19 14:42:27 -0700 | [diff] [blame] | 7 | |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 8 | """Script for running llvm validation tests on ChromeOS. |
| 9 | |
| 10 | This script launches a buildbot to build ChromeOS with the llvm on |
| 11 | a particular board; then it finds and downloads the trybot image and the |
| 12 | corresponding official image, and runs test for correctness. |
| 13 | It then generates a report, emails it to the c-compiler-chrome, as |
| 14 | well as copying the result into a directory. |
| 15 | """ |
| 16 | |
| 17 | # Script to test different toolchains against ChromeOS benchmarks. |
| 18 | |
| 19 | from __future__ import print_function |
| 20 | |
| 21 | import argparse |
| 22 | import datetime |
| 23 | import os |
| 24 | import sys |
| 25 | import time |
| 26 | |
Caroline Tice | a8af9a7 | 2016-07-20 12:52:59 -0700 | [diff] [blame] | 27 | from cros_utils import command_executer |
| 28 | from cros_utils import logger |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 29 | |
Caroline Tice | a8af9a7 | 2016-07-20 12:52:59 -0700 | [diff] [blame] | 30 | from cros_utils import buildbot_utils |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 31 | |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 32 | CROSTC_ROOT = '/usr/local/google/crostc' |
| 33 | ROLE_ACCOUNT = 'mobiletc-prebuild' |
| 34 | TOOLCHAIN_DIR = os.path.dirname(os.path.realpath(__file__)) |
| 35 | MAIL_PROGRAM = '~/var/bin/mail-sheriff' |
| 36 | VALIDATION_RESULT_DIR = os.path.join(CROSTC_ROOT, 'validation_result') |
| 37 | START_DATE = datetime.date(2016, 1, 1) |
Manoj Gupta | dd8675b | 2018-01-25 10:59:06 -0800 | [diff] [blame] | 38 | TEST_PER_DAY = 4 |
Caroline Tice | feb442e | 2018-04-19 23:27:38 -0700 | [diff] [blame] | 39 | DATA_DIR = '/google/data/rw/users/mo/mobiletc-prebuild/waterfall-report-data/' |
Caroline Tice | 09cacd0 | 2017-08-11 13:02:29 -0700 | [diff] [blame] | 40 | |
| 41 | # Information about Rotating Boards |
Manoj Gupta | 1f0302d | 2019-04-19 10:53:43 -0700 | [diff] [blame] | 42 | # Board Arch Reference Platform Kernel |
| 43 | # Board Version |
| 44 | # ------------ ------- ------------ ------------- ------- |
Manoj Gupta | 1f0302d | 2019-04-19 10:53:43 -0700 | [diff] [blame] | 45 | # atlas x86_64 poppy kabylake-y 4.4.* |
| 46 | # cave x86_64 glados skylake-y 3.18 |
| 47 | # coral x86_64 reef apollo lake 4.4.* |
| 48 | # cyan x86_64 strago braswell 3.18 |
Manoj Gupta | 1f0302d | 2019-04-19 10:53:43 -0700 | [diff] [blame] | 49 | # elm aarch64 oak mediatek-8173 3.18 arm32 userspace |
| 50 | # eve x86_64 poppy kabylake-u/r 4.4.* |
| 51 | # gale armv7 3.18 |
| 52 | # grunt x86_64 grunt stoney ridge 4.14.* |
Zhizhou Yang | 64a2ef0 | 2019-08-20 16:20:42 -0700 | [diff] [blame] | 53 | # fizz-moblab x86_64 4.4 |
Manoj Gupta | 1f0302d | 2019-04-19 10:53:43 -0700 | [diff] [blame] | 54 | # kevin aarch64 gru rockchip-3399 4.4.* arm32 userspace |
| 55 | # kevin64 aarch64 gru rockchip-3399 4.4.* arm64 userspace |
| 56 | # lakitu x86_64 4.4.* |
Zhizhou Yang | 739e6ab | 2019-06-28 10:23:09 -0700 | [diff] [blame] | 57 | # nyan_kitty armv7 nyan tegra 3.10.18 |
| 58 | # octopus x86_64 octopus GLK 4.14.* |
Tiancong Wang | 9506af1 | 2019-05-02 09:26:48 -0700 | [diff] [blame] | 59 | # sentry x86_64 kunimitsu skylake-u 3.18 |
Manoj Gupta | 1f0302d | 2019-04-19 10:53:43 -0700 | [diff] [blame] | 60 | # tidus x86_64 auron broadwell 3.14 |
| 61 | # veyron_mighty armv7 veyron-pinky rockchip-3288 3.14 |
| 62 | # whirlwind armv7 3.14 |
Zhizhou Yang | 739e6ab | 2019-06-28 10:23:09 -0700 | [diff] [blame] | 63 | # winky x86_64 rambi baytrail 4.4.* |
Caroline Tice | 09cacd0 | 2017-08-11 13:02:29 -0700 | [diff] [blame] | 64 | |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 65 | TEST_BOARD = [ |
Manoj Gupta | 1f0302d | 2019-04-19 10:53:43 -0700 | [diff] [blame] | 66 | 'atlas', |
Manoj Gupta | 26391db | 2018-03-15 11:14:18 -0700 | [diff] [blame] | 67 | 'cave', |
Manoj Gupta | 1f0302d | 2019-04-19 10:53:43 -0700 | [diff] [blame] | 68 | 'coral', |
| 69 | 'cyan', |
Manoj Gupta | 1f0302d | 2019-04-19 10:53:43 -0700 | [diff] [blame] | 70 | 'elm', |
| 71 | # 'eve', tested by amd64-llvm-next-toolchain builder. |
Caroline Tice | 09cacd0 | 2017-08-11 13:02:29 -0700 | [diff] [blame] | 72 | 'gale', |
Manoj Gupta | e8ba054 | 2018-04-18 13:58:43 -0700 | [diff] [blame] | 73 | 'grunt', |
Zhizhou Yang | 64a2ef0 | 2019-08-20 16:20:42 -0700 | [diff] [blame] | 74 | 'fizz-moblab', |
Manoj Gupta | 1f0302d | 2019-04-19 10:53:43 -0700 | [diff] [blame] | 75 | # 'kevin', tested by arm64-llvm-next-toolchain builder. |
Manoj Gupta | cd2cf15 | 2019-03-01 10:50:59 -0800 | [diff] [blame] | 76 | 'kevin64', |
Caroline Tice | 856bc6c | 2017-06-29 16:21:43 -0700 | [diff] [blame] | 77 | 'lakitu', |
Zhizhou Yang | 739e6ab | 2019-06-28 10:23:09 -0700 | [diff] [blame] | 78 | 'nyan_kitty', |
| 79 | 'octopus', |
Tiancong Wang | 9506af1 | 2019-05-02 09:26:48 -0700 | [diff] [blame] | 80 | 'sentry', |
Manoj Gupta | 1f0302d | 2019-04-19 10:53:43 -0700 | [diff] [blame] | 81 | 'tidus', |
| 82 | # 'veyron_mighty', tested by arm-llvm-next-toolchain builder. |
Caroline Tice | 856bc6c | 2017-06-29 16:21:43 -0700 | [diff] [blame] | 83 | 'whirlwind', |
Zhizhou Yang | 739e6ab | 2019-06-28 10:23:09 -0700 | [diff] [blame] | 84 | 'winky', |
Caroline Tice | a12e974 | 2016-09-08 13:35:02 -0700 | [diff] [blame] | 85 | ] |
| 86 | |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 87 | |
| 88 | class ToolchainVerifier(object): |
| 89 | """Class for the toolchain verifier.""" |
| 90 | |
Caroline Tice | a12e974 | 2016-09-08 13:35:02 -0700 | [diff] [blame] | 91 | def __init__(self, board, chromeos_root, weekday, patches, compiler): |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 92 | self._board = board |
| 93 | self._chromeos_root = chromeos_root |
| 94 | self._base_dir = os.getcwd() |
| 95 | self._ce = command_executer.GetCommandExecuter() |
| 96 | self._l = logger.GetLogger() |
Caroline Tice | 314ea56 | 2016-06-24 15:59:01 -0700 | [diff] [blame] | 97 | self._compiler = compiler |
Yunlian Jiang | bddbcd3 | 2017-11-27 10:59:30 -0800 | [diff] [blame] | 98 | self._build = '%s-%s-toolchain-tryjob' % (board, compiler) |
Caroline Tice | de60077 | 2016-10-18 15:27:51 -0700 | [diff] [blame] | 99 | self._patches = patches.split(',') if patches else [] |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 100 | self._patches_string = '_'.join(str(p) for p in self._patches) |
| 101 | |
| 102 | if not weekday: |
| 103 | self._weekday = time.strftime('%a') |
| 104 | else: |
| 105 | self._weekday = weekday |
Caroline Tice | d00ad41 | 2016-07-02 18:00:18 -0700 | [diff] [blame] | 106 | self._reports = os.path.join(VALIDATION_RESULT_DIR, compiler, board) |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 107 | |
Ting-Yuan Huang | 6a9a98a | 2018-03-07 17:35:13 -0800 | [diff] [blame] | 108 | def DoAll(self): |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 109 | """Main function inside ToolchainComparator class. |
| 110 | |
| 111 | Launch trybot, get image names, create crosperf experiment file, run |
| 112 | crosperf, and copy images into seven-day report directories. |
| 113 | """ |
Caroline Tice | feb442e | 2018-04-19 23:27:38 -0700 | [diff] [blame] | 114 | buildbucket_id, _ = buildbot_utils.GetTrybotImage( |
Ting-Yuan Huang | 6a9a98a | 2018-03-07 17:35:13 -0800 | [diff] [blame] | 115 | self._chromeos_root, |
| 116 | self._build, |
| 117 | self._patches, |
Jian Cai | 9d57640 | 2019-06-17 20:49:35 +0000 | [diff] [blame] | 118 | tryjob_flags=['--hwtest'], |
Zhizhou Yang | 2841733 | 2020-01-09 11:12:14 -0800 | [diff] [blame] | 119 | asynchronous=True) |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 120 | |
Caroline Tice | feb442e | 2018-04-19 23:27:38 -0700 | [diff] [blame] | 121 | return buildbucket_id |
| 122 | |
| 123 | |
| 124 | def WriteRotatingReportsData(results_dict, date): |
| 125 | """Write data for waterfall report.""" |
| 126 | fname = '%d-%02d-%02d.builds' % (date.year, date.month, date.day) |
| 127 | filename = os.path.join(DATA_DIR, 'rotating-builders', fname) |
Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 128 | with open(filename, 'w', encoding='utf-8') as out_file: |
Caroline Tice | feb442e | 2018-04-19 23:27:38 -0700 | [diff] [blame] | 129 | for board in results_dict.keys(): |
| 130 | buildbucket_id = results_dict[board] |
| 131 | out_file.write('%s,%s\n' % (buildbucket_id, board)) |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 132 | |
Manoj Gupta | d575b8a | 2017-03-08 10:51:28 -0800 | [diff] [blame] | 133 | |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 134 | def Main(argv): |
| 135 | """The main function.""" |
| 136 | |
| 137 | # Common initializations |
| 138 | command_executer.InitCommandExecuter() |
| 139 | parser = argparse.ArgumentParser() |
Caroline Tice | a12e974 | 2016-09-08 13:35:02 -0700 | [diff] [blame] | 140 | parser.add_argument( |
| 141 | '--chromeos_root', |
| 142 | dest='chromeos_root', |
| 143 | help='The chromeos root from which to run tests.') |
| 144 | parser.add_argument( |
| 145 | '--weekday', |
| 146 | default='', |
| 147 | dest='weekday', |
| 148 | help='The day of the week for which to run tests.') |
| 149 | parser.add_argument( |
| 150 | '--board', default='', dest='board', help='The board to test.') |
| 151 | parser.add_argument( |
| 152 | '--patch', |
| 153 | dest='patches', |
Caroline Tice | de60077 | 2016-10-18 15:27:51 -0700 | [diff] [blame] | 154 | default='', |
Caroline Tice | a12e974 | 2016-09-08 13:35:02 -0700 | [diff] [blame] | 155 | help='The patches to use for the testing, ' |
| 156 | "seprate the patch numbers with ',' " |
| 157 | 'for more than one patches.') |
| 158 | parser.add_argument( |
| 159 | '--compiler', |
| 160 | dest='compiler', |
Caroline Tice | 4bd7046 | 2016-10-05 15:41:13 -0700 | [diff] [blame] | 161 | help='Which compiler (llvm, llvm-next or gcc) to use for ' |
Caroline Tice | a12e974 | 2016-09-08 13:35:02 -0700 | [diff] [blame] | 162 | 'testing.') |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 163 | |
| 164 | options = parser.parse_args(argv[1:]) |
| 165 | if not options.chromeos_root: |
| 166 | print('Please specify the ChromeOS root directory.') |
| 167 | return 1 |
Caroline Tice | 314ea56 | 2016-06-24 15:59:01 -0700 | [diff] [blame] | 168 | if not options.compiler: |
Caroline Tice | 4bd7046 | 2016-10-05 15:41:13 -0700 | [diff] [blame] | 169 | print('Please specify which compiler to test (gcc, llvm, or llvm-next).') |
Caroline Tice | 314ea56 | 2016-06-24 15:59:01 -0700 | [diff] [blame] | 170 | return 1 |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 171 | |
| 172 | if options.board: |
| 173 | fv = ToolchainVerifier(options.board, options.chromeos_root, |
Manoj Gupta | d575b8a | 2017-03-08 10:51:28 -0800 | [diff] [blame] | 174 | options.weekday, options.patches, options.compiler) |
Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 175 | return fv.DoAll() |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 176 | |
| 177 | today = datetime.date.today() |
| 178 | delta = today - START_DATE |
| 179 | days = delta.days |
| 180 | |
| 181 | start_board = (days * TEST_PER_DAY) % len(TEST_BOARD) |
Caroline Tice | feb442e | 2018-04-19 23:27:38 -0700 | [diff] [blame] | 182 | results_dict = dict() |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 183 | for i in range(TEST_PER_DAY): |
Yunlian Jiang | 54e72b3 | 2016-06-21 14:13:03 -0700 | [diff] [blame] | 184 | try: |
Caroline Tice | a12e974 | 2016-09-08 13:35:02 -0700 | [diff] [blame] | 185 | board = TEST_BOARD[(start_board + i) % len(TEST_BOARD)] |
| 186 | fv = ToolchainVerifier(board, options.chromeos_root, options.weekday, |
Manoj Gupta | 86fe1ed | 2017-03-09 10:37:35 -0800 | [diff] [blame] | 187 | options.patches, options.compiler) |
Caroline Tice | feb442e | 2018-04-19 23:27:38 -0700 | [diff] [blame] | 188 | buildbucket_id = fv.DoAll() |
| 189 | if buildbucket_id: |
| 190 | results_dict[board] = buildbucket_id |
Yunlian Jiang | 54e72b3 | 2016-06-21 14:13:03 -0700 | [diff] [blame] | 191 | except SystemExit: |
Caroline Tice | d00ad41 | 2016-07-02 18:00:18 -0700 | [diff] [blame] | 192 | logfile = os.path.join(VALIDATION_RESULT_DIR, options.compiler, board) |
Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 193 | with open(logfile, 'w', encoding='utf-8') as f: |
Caroline Tice | a12e974 | 2016-09-08 13:35:02 -0700 | [diff] [blame] | 194 | f.write('Verifier got an exception, please check the log.\n') |
Caroline Tice | feb442e | 2018-04-19 23:27:38 -0700 | [diff] [blame] | 195 | WriteRotatingReportsData(results_dict, today) |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 196 | |
Caroline Tice | a12e974 | 2016-09-08 13:35:02 -0700 | [diff] [blame] | 197 | |
Yunlian Jiang | c571337 | 2016-06-15 11:37:50 -0700 | [diff] [blame] | 198 | if __name__ == '__main__': |
| 199 | retval = Main(sys.argv) |
| 200 | sys.exit(retval) |