• Home
Name Date Size #Lines LOC

..--

README.mdD03-May-202412.3 KiB473344

assert_not_in_chroot.pyD03-May-2024677 2511

auto_llvm_bisection.pyD03-May-20244.2 KiB13569

auto_llvm_bisection_unittest.pyD03-May-20249.6 KiB233122

copy_helpers_to_chromiumos_overlay.pyD03-May-20241.9 KiB6846

custom_script_example.pyD03-May-20242.2 KiB7327

failure_modes.pyD03-May-2024642 2411

get_llvm_hash.pyD03-May-20249.8 KiB349229

get_llvm_hash_unittest.pyD03-May-20243.2 KiB9763

git_llvm_rev.pyD03-May-202410.3 KiB376270

git_llvm_rev_test.pyD03-May-20246.6 KiB177107

llvm_bisection.pyD03-May-202415.7 KiB463285

llvm_bisection_unittest.pyD03-May-202420.4 KiB600368

llvm_patch_management.pyD03-May-20249 KiB279167

llvm_patch_management_unittest.pyD03-May-202411.5 KiB307169

modify_a_tryjob.pyD03-May-20249.9 KiB289179

modify_a_tryjob_unittest.pyD03-May-202413.7 KiB402265

patch_manager.pyD03-May-202426.8 KiB751412

patch_manager_unittest.pyD03-May-202433.9 KiB912539

subprocess_helpers.pyD03-May-20241.5 KiB5929

test_helpers.pyD03-May-20242.2 KiB9054

update_all_tryjobs_with_auto.pyD03-May-20242.4 KiB8247

update_chromeos_llvm_next_hash.pyD03-May-202422.6 KiB716437

update_chromeos_llvm_next_hash_unittest.pyD03-May-202436.3 KiB942563

update_packages_and_run_tryjobs.pyD03-May-20249.6 KiB315199

update_packages_and_run_tryjobs_unittest.pyD03-May-202410.1 KiB293185

update_tryjob_status.pyD03-May-202410.6 KiB324200

update_tryjob_status_unittest.pyD03-May-202421.1 KiB618389

README.md

1# LLVM Tools
2
3## Overview
4
5These scripts helps automate tasks such as updating the LLVM next hash,
6determing whether a new patch applies correctly, and patch management.
7
8In addition, there are scripts that automate the process of retrieving the
9git hash of LLVM from either google3, top of trunk, or for a specific SVN
10version.
11
12**NOTE: All scripts must must be run outside the chroot**
13
14**NOTE: sudo must be permissive (i.e. **`cros_sdk`** should NOT prompt for a
15password)**
16
17## `update_packages_and_run_tryjobs.py`
18
19### Usage
20
21This script is used for updating a package's `LLVM_NEXT_HASH` (sys-devel/llvm,
22sys-libs/compiler-rt, sys-libs/libcxx, sys-libs/libcxxabi, and
23sys-libs/llvm-libunwind) and then run tryjobs after updating the git hash.
24
25An example when this script should be run is when certain boards would like
26to be tested with the updated `LLVM_NEXT_HASH`.
27
28For example:
29
30```
31$ ./update_packages_and_run_tryjobs.py \
32  --llvm_version tot \
33  --options nochromesdk latest-toolchain \
34  --builders kevin-release-tryjob nocturne-release-tryjob
35```
36
37The above example would update the packages' `LLVM_NEXT_HASH` to the top of
38trunk's git hash and would submit tryjobs for kevin and nocturne boards, passing
39in 'nochromesdk' and 'latest-toolchain' for each tryjob.
40
41For help with the command line arguments of the script, run:
42
43```
44$ ./update_packages_and_run_tryjobs.py --help
45```
46
47Similarly as the previous example, but for updating `LLVM_NEXT_HASH` to
48google3:
49
50```
51$ ./update_packages_and_run_tryjobs.py \
52  --llvm_version google3 \
53  --options nochromesdk latest-toolchain \
54  --builders kevin-release-tryjob nocturne-release-tryjob
55```
56
57Similarly as the previous example, but for updating `LLVM_NEXT_HASH` to
58the git hash of revision 367622:
59
60```
61$ ./update_packages_and_run_tryjobs.py \
62  --llvm_version 367622 \
63  --options nochromesdk latest-toolchain \
64  --builders kevin-release-tryjob nocturne-release-tryjob
65```
66
67## `update_chromeos_llvm_next_hash.py`
68
69### Usage
70
71This script is used for updating a package's/packages' `LLVM_NEXT_HASH` and
72creating a change list of those changes which will uploaded for review. For
73example, some changes that would be included in the change list are
74the updated ebuilds, changes made to the patches of the updated packages such
75as being removed or an updated patch metadata file. These changes are determined
76by the `--failure_mode` option.
77
78An example where this script would be used is when multiple packages need to
79have their `LLVM_NEXT_HASH` updated.
80
81For example:
82
83```
84$ ./update_chromeos_llvm_next_hash.py \
85  --update_packages sys-devel/llvm sys-libs/compiler-rt \
86  --llvm_version google3 \
87  --failure_mode disable_patches
88```
89
90The example above would update sys-devel/llvm and sys-libs/compiler-rt
91`LLVM_NEXT_HASH` to the latest google3's git hash of LLVM. And the change list
92may include patches that were disabled for either sys-devel/llvm or
93sys-libs/compiler-rt.
94
95For help with the command line arguments of the script, run:
96
97```
98$ ./update_chromeos_llvm_next.py --help
99```
100
101For example, to update `LLVM_NEXT_HASH` to top of trunk of LLVM:
102
103```
104$ ./update_chromeos_llvm_next_hash.py \
105  --update_packages sys-devel/llvm sys-libs/compiler-rt \
106  --llvm_version tot \
107  --failure_mode disable_patches
108```
109
110For example, to update `LLVM_NEXT_HASH` to the git hash of revision 367622:
111
112```
113$ ./update_chromeos_llvm_next_hash.py \
114  --update_packages sys-devel/llvm sys-libs/compiler-rt \
115  --llvm_version 367622 \
116  --failure_mode disable_patches
117```
118
119## `llvm_patch_management.py`
120
121### Usage
122
123This script is used to test whether a newly added patch in a package's patch
124metadata file would apply successfully. The script is also used to make sure
125the patches of a package applied successfully, failed, etc., depending on the
126failure mode specified.
127
128An example of using this script is when multiple packages would like to be
129tested when a new patch was added to their patch metadata file.
130
131For example:
132
133```
134$ ./llvm_patch_management.py \
135  --packages sys-devel/llvm sys-libs/compiler-rt \
136  --failure_mode continue
137```
138
139The above example tests sys-devel/llvm and sys-libs/compiler-rt patch metadata
140file with the failure mode `continue`.
141
142For help with the command line arguments of the script, run:
143
144```
145$ ./llvm_patch_management.py --help
146```
147
148## `patch_manager.py`
149
150### Usage
151
152This script is used when when all the command line arguments are known such as
153testing a specific metadata file or a specific source tree.
154
155For help with the command line arguments of the script, run:
156
157```
158$ ./patch_manager.py --help
159```
160
161For example, to see all the failed (if any) patches:
162
163```
164$ ./patch_manager.py \
165  --svn_version 367622 \
166  --patch_metadata_file /abs/path/to/patch/file \
167  --filesdir_path /abs/path/to/$FILESDIR \
168  --src_path /abs/path/to/src/tree \
169  --failure_mode continue
170```
171
172For example, to disable all patches that failed to apply:
173
174```
175$ ./patch_manager.py \
176  --svn_version 367622 \
177  --patch_metadata_file /abs/path/to/patch/file \
178  --filesdir_path /abs/path/to/$FILESDIR \
179  --src_path /abs/path/to/src/tree \
180  --failure_mode disable_patches
181```
182
183For example, to remove all patches that no longer apply:
184
185```
186$ ./patch_manager.py \
187  --svn_version 367622 \
188  --patch_metadata_file /abs/path/to/patch/file \
189  --filesdir_path /abs/path/to/$FILESDIR \
190  --src_path /abs/path/to/src/tree \
191  --failure_mode remove_patches
192```
193
194For example, to bisect a failing patch and stop at the first bisected patch:
195
196```
197$ ./patch_manager.py \
198  --svn_version 367622 \
199  --patch_metadata_file /abs/path/to/patch/file \
200  --filesdir_path /abs/path/to/$FILESDIR \
201  --src_path /abs/path/to/src/tree \
202  --failure_mode bisect_patches \
203  --good_svn_version 365631
204```
205
206For example, to bisect a failing patch and then continue bisecting the rest of
207the failed patches:
208
209```
210$ ./patch_manager.py \
211  --svn_version 367622 \
212  --patch_metadata_file /abs/path/to/patch/file \
213  --filesdir_path /abs/path/to/$FILESDIR \
214  --src_path /abs/path/to/src/tree \
215  --failure_mode bisect_patches \
216  --good_svn_version 365631 \
217  --continue_bisection True
218```
219
220## LLVM Bisection
221
222### `llvm_bisection.py`
223
224#### Usage
225
226This script is used to bisect a bad revision of LLVM. After the script finishes,
227the user requires to run the script again to continue the bisection. Intially,
228the script creates a JSON file that does not exist which then continues
229bisection (after invoking the script again) based off of the JSON file.
230
231For example, assuming the revision 369420 is the bad revision:
232
233```
234$ ./llvm_bisection.py \
235  --parallel 3 \
236  --start_rev 369410 \
237  --end_rev 369420 \
238  --last_tested /abs/path/to/tryjob/file/ \
239  --extra_change_lists 513590 \
240  --builder eve-release-tryjob \
241  --options latest-toolchain
242```
243
244The above example bisects the bad revision (369420), starting from the good
245revision 369410 and launching 3 tryjobs in between if possible (`--parallel`).
246Here, the `--last_tested` path is a path to a JSON file that does not exist. The
247tryjobs are tested on the eve board. `--extra_change_lists` and `--options`
248indicate what parameters to pass into launching a tryjob.
249
250For help with the command line arguments of the script, run:
251
252```
253$ ./llvm_bisection.py --help
254```
255
256### `auto_llvm_bisection.py`
257
258#### Usage
259
260This script automates the LLVM bisection process by using `cros buildresult` to
261update the status of each tryjob.
262
263An example when this script would be used to do LLVM bisection overnight
264because tryjobs take very long to finish.
265
266For example, assuming the good revision is 369410 and the bad revision is
267369420, then:
268
269```
270$ ./auto_llvm_bisection.py --start_rev 369410 --end_rev 369420 \
271  --last_tested /abs/path/to/last_tested_file.json \
272  --extra_change_lists 513590 1394249 \
273  --options latest-toolchain nochromesdk \
274  --builder eve-release-tryjob
275```
276
277The example above bisects LLVM between revision 369410 and 369420. If the file
278exists, the script resumes bisection. Otherwise, the script creates the file
279provided by `--last_tested`. `--extra_change_lists` and `--options` are used for
280each tryjob when being submitted. Lastly, the tryjobs are launched for the board
281provided by `--builder` (in this example, for the eve board).
282
283For help with the command line arguments of the script, run:
284
285```
286$ ./auto_llvm_bisection.py --help
287```
288
289### `update_tryjob_status.py`
290
291#### Usage
292
293This script updates a tryjob's 'status' value when bisecting LLVM. This script
294can use the file that was created by `llvm_bisection.py`.
295
296An example when this script would be used is when the result of tryjob that was
297launched was 'fail' (due to flaky infra) but it should really have been
298'success'.
299
300For example, to update a tryjob's 'status' to 'good':
301
302```
303$ ./update_tryjob_status.py \
304  --set_status good \
305  --revision 369412 \
306  --status_file /abs/path/to/tryjob/file
307```
308
309The above example uses the file in `--status_file` to update a tryjob in that
310file that tested the revision 369412 and sets its 'status' value to 'good'.
311
312For help with the command line arguments of the script, run:
313
314```
315$ ./update_tryjob_status.py --help
316```
317
318For example, to update a tryjob's 'status' to 'bad':
319
320```
321$ ./update_tryjob_status.py \
322  --set_status bad \
323  --revision 369412 \
324  --status_file /abs/path/to/tryjob/file
325```
326
327For example, to update a tryjob's 'status' to 'pending':
328
329```
330$ ./update_tryjob_status.py \
331  --set_status pending \
332  --revision 369412 \
333  --status_file /abs/path/to/tryjob/file
334```
335
336For example, to update a tryjob's 'status' to 'skip':
337
338```
339$ ./update_tryjob_status.py \
340  --set_status skip \
341  --revision 369412 \
342  --status_file /abs/path/to/tryjob/file
343```
344
345For example, to update a tryjob's 'status' based off a custom script exit code:
346
347```
348$ ./update_tryjob_status.py \
349  --set_status custom_script \
350  --revision 369412 \
351  --status_file /abs/path/to/tryjob/file \
352  --custom_script /abs/path/to/script.py
353```
354
355### `update_all_tryjobs_with_auto.py`
356
357#### Usage
358
359This script updates all tryjobs that are 'pending' to the result provided by
360`cros buildresult`.
361
362For example:
363
364```
365$ ./update_all_tryjobs_with_auto.py \
366  --last_tested /abs/path/to/last_tested_file.json \
367  --chroot_path /abs/path/to/chroot
368```
369
370The above example will update all tryjobs whose 'status' is 'pending' in the
371file provided by `--last_tested`.
372
373For help with the command line arguments of the script, run:
374
375```
376$ ./update_all_tryjobs_with_auto.py --help
377```
378
379### `modify_a_tryjob.py`
380
381#### Usage
382
383This script modifies a tryjob directly given an already created tryjob file when
384bisecting LLVM. The file created by `llvm_bisection.py` can be used in this
385script.
386
387An example when this script would be used is when a tryjob needs to be manually
388added.
389
390For example:
391
392```
393$ ./modify_a_tryjob.py \
394  --modify_a_tryjob add \
395  --revision 369416 \
396  --extra_change_lists 513590 \
397  --options latest-toolchain \
398  --builder eve-release-tryjob \
399  --status_file /abs/path/to/tryjob/file
400```
401
402The above example creates a tryjob that tests revision 369416 on the eve board,
403passing in the extra arguments (`--extra_change_lists` and `--options`). The
404tryjob is then inserted into the file passed in via `--status_file`.
405
406For help with the command line arguments of the script, run:
407
408```
409$ ./modify_a_tryjob.py --help
410```
411
412For example, to remove a tryjob that tested revision 369412:
413
414```
415$ ./modify_a_tryjob.py \
416  --modify_a_tryjob remove \
417  --revision 369412 \
418  --status_file /abs/path/to/tryjob/file
419```
420
421For example, to relaunch a tryjob that tested revision 369418:
422
423```
424$ ./modify_a_tryjob.py \
425  --modify_a_tryjob relaunch \
426  --revision 369418 \
427  --status_file /abs/path/to/tryjob/file
428```
429
430## Other Helpful Scripts
431
432### `get_llvm_hash.py`
433
434#### Usage
435
436The script has a class that deals with retrieving either the top of trunk git
437hash of LLVM, the git hash of google3, or a specific git hash of a SVN version.
438It also has other functions when dealing with a git hash of LLVM.
439
440In addition, it has a function to retrieve the latest google3 LLVM version.
441
442For example, to retrieve the top of trunk git hash of LLVM:
443
444```
445from get_llvm_hash import LLVMHash
446
447LLVMHash().GetTopOfTrunkGitHash()
448```
449
450For example, to retrieve the git hash of google3:
451
452```
453from get_llvm_hash import LLVMHash
454
455LLVMHash().GetGoogle3LLVMHash()
456```
457
458For example, to retrieve the git hash of a specific SVN version:
459
460```
461from get_llvm_hash import LLVMHash
462
463LLVMHash().GetLLVMHash(<svn_version>)
464```
465
466For example, to retrieve the latest google3 LLVM version:
467
468```
469from get_llvm_hash import GetGoogle3LLVMVersion
470
471GetGoogle3LLVMVersion(stable=True)
472```
473