Skip to content

Commit 8114554

Browse files
SeawardTchromeos-ci-prod
authored andcommitted
[RTS] Add back in RTS support to GNI
- Add use_rts bool flag to ensure that a .filter file exists or creates a dummy file while waiting for the file to be written. RTS = Regression Test Selection Re-land of https://crrev.com/c/4859614 Bug: 375000947 Change-Id: I425e0891ac895ae043855e0372be8a0e43a96f0f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5954865 Reviewed-by: Dirk Pranke <dpranke@google.com> Reviewed-by: Struan Shrimpton <sshrimp@google.com> Commit-Queue: Tony Seaward <seawardt@google.com> Cr-Commit-Position: refs/heads/main@{#1374746} CrOS-Libchrome-Original-Commit: 37c51bc8d9cbbd11ef6cb8d872b82080dab839df
1 parent 229060e commit 8114554

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

build/add_rts_filters.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env python3
2+
# Copyright 2024 The Chromium Authors
3+
# Use of this source code is governed by a BSD-style license that can be
4+
# found in the LICENSE file.
5+
"""Creates a dummy RTS filter file if a real ones do not exist yet.
6+
Real filter files are generated for suites with skippable tests.
7+
Not every test suite will have filter data to use and therefore
8+
no filter file will be created. This ensures that a file exists
9+
to avoid file not found errors. The files will contain no skippable
10+
tests, so there is no effect.
11+
12+
Implementation uses try / except because the filter files are written
13+
relatively close to when this code creates the dummy files.
14+
15+
The following type of implementation would have a race condition:
16+
if not os.path.isfile(filter_file):
17+
open(filter_file, 'w') as fp:
18+
fp.write('*')
19+
"""
20+
import errno
21+
import os
22+
import sys
23+
24+
25+
def main():
26+
filter_file = sys.argv[1]
27+
# '*' is a dummy that means run everything
28+
write_filter_file(filter_file, '*')
29+
30+
31+
def write_filter_file(filter_file, filter_string):
32+
directory = os.path.dirname(filter_file)
33+
try:
34+
os.makedirs(directory)
35+
except OSError as err:
36+
if err.errno == errno.EEXIST:
37+
pass
38+
else:
39+
raise
40+
try:
41+
fp = os.open(filter_file, os.O_CREAT | os.O_EXCL | os.O_WRONLY)
42+
except OSError as err:
43+
if err.errno == errno.EEXIST:
44+
pass
45+
else:
46+
raise
47+
else:
48+
with os.fdopen(fp, 'w') as file_obj:
49+
file_obj.write(filter_string)
50+
51+
52+
if __name__ == '__main__':
53+
sys.exit(main())

0 commit comments

Comments
 (0)