xref: /aosp_15_r20/external/autotest/client/site_tests/graphics_parallel_dEQP/generate_controlfiles.py (revision 9c5db1993ded3edbeafc8092d69fe5de2ee02df7)
1#!/usr/bin/env python
2"""
3This script generates autotest control files for dEQP. It supports
41) Generate control files for tests with Passing expectations.
52) Generate control files to run tests that are not passing.
63) Decomposing a test into shards. Ideally shard_count is chosen such that
7   each shard will run less than 1 minute. It mostly makes sense in
8   combination with "hasty".
9"""
10import os
11from collections import namedtuple
12# Use 'sudo pip install enum34' to install.
13from enum import Enum
14# Use 'sudo pip install jinja2' to install.
15from jinja2 import Template
16
17Test = namedtuple(
18        'Test',
19        'filter, suite, shards, time, tag, api, caselist, perf_failure_description'
20)
21
22ATTRIBUTES_PVS = ('suite:deqp, suite:graphics_per-day, suite:graphics_system, '
23                  'suite:pvs-graphics')
24ATTRIBUTES_DAILY = 'suite:deqp, suite:graphics_per-day, suite:graphics_system'
25
26
27class Suite(Enum):
28    none = 1
29    daily = 2
30    pvs = 3
31
32
33deqp_dir = '/usr/local/deqp'
34caselists = 'caselists'
35GLES2_FILE = os.path.join(deqp_dir, caselists, 'gles2.txt')
36GLES3_FILE = os.path.join(deqp_dir, caselists, 'gles3.txt')
37GLES31_FILE = os.path.join(deqp_dir, caselists, 'gles31.txt')
38VK_FILE = os.path.join(deqp_dir, caselists, 'vk.txt')
39
40tests = [
41        Test('dEQP-GLES2',
42             Suite.pvs,
43             shards=1,
44             time='MEDIUM',
45             tag='gles2',
46             api='gles2',
47             caselist=GLES2_FILE,
48             perf_failure_description='Failures_GLES2'),
49        Test('dEQP-GLES3',
50             Suite.pvs,
51             shards=1,
52             time='LONG',
53             tag='gles3',
54             api='gles3',
55             caselist=GLES3_FILE,
56             perf_failure_description='Failures_GLES3'),
57        Test('dEQP-GLES31',
58             Suite.pvs,
59             shards=1,
60             time='LONG',
61             tag='gles31',
62             api='gles31',
63             caselist=GLES31_FILE,
64             perf_failure_description='Failures_GLES31'),
65        Test('dEQP-VK',
66             Suite.daily,
67             shards=4,
68             time='LONG',
69             tag='vk',
70             api='vk',
71             caselist=VK_FILE,
72             perf_failure_description='Failures_VK'),
73]
74
75CONTROLFILE_TEMPLATE = Template("""\
76# Copyright 2015-2021 The Chromium OS Authors. All rights reserved.
77# Use of this source code is governed by a BSD-style license that can be
78# found in the LICENSE file.
79
80# Please do not edit this file! It has been created by generate_controlfiles.py.
81
82PY_VERSION = 3
83NAME = '{{testname}}'
84AUTHOR = 'chromeos-gfx'
85PURPOSE = 'Run the drawElements Quality Program test suite with deqp-runner.'
86CRITERIA = 'All of the individual tests must pass unless marked as known failures.'
87ATTRIBUTES = '{{attributes}}'
88TIME = '{{time}}'
89TEST_CATEGORY = 'Functional'
90TEST_CLASS = 'graphics'
91TEST_TYPE = 'client'
92MAX_RESULT_SIZE_KB = 131072
93EXTENDED_TIMEOUT = 86400
94DOC = \"\"\"
95This test runs the drawElements Quality Program test suite.
96\"\"\"
97job.run_test('graphics_parallel_dEQP',{% if tag != None %}
98             tag = '{{tag}}',{% endif %}
99             opts = args + [
100                 'api={{api}}',
101                 'caselist={{caselist}}',
102                 {% if perf_failure_description %}'perf_failure_description={{perf_failure_description}}',{% endif %}
103                 'shard_number={{shard}}',
104                 'shard_count={{shards}}'
105             ])""")
106
107
108def get_controlfilename(test, shard=0):
109    return 'control.%s' % get_name(test, shard)
110
111
112def get_attributes(test):
113    if test.suite == Suite.pvs:
114        return ATTRIBUTES_PVS
115    if test.suite == Suite.daily:
116        return ATTRIBUTES_DAILY
117    return ''
118
119
120def get_time(test):
121    return test.time
122
123
124def get_name(test, shard):
125    name = test.filter.replace('dEQP-', '', 1).lower()
126    if test.shards > 1:
127        name = '%s.%d' % (name, shard)
128    return name
129
130
131def get_testname(test, shard=0):
132    return 'graphics_parallel_dEQP.%s' % get_name(test, shard)
133
134
135def write_controlfile(filename, content):
136    print(('Writing %s.' % filename))
137    with open(filename, 'w+') as f:
138        f.write(content)
139
140
141def write_controlfiles(test):
142    attributes = get_attributes(test)
143    time = get_time(test)
144
145    for shard in range(0, test.shards):
146        testname = get_testname(test, shard)
147        filename = get_controlfilename(test, shard)
148        content = CONTROLFILE_TEMPLATE.render(
149                testname=testname,
150                attributes=attributes,
151                time=time,
152                subset='Pass',
153                shard=shard,
154                shards=test.shards,
155                api=test.api,
156                caselist=test.caselist,
157                tag=test.tag,
158                perf_failure_description=test.perf_failure_description)
159        write_controlfile(filename, content)
160
161
162def main():
163    for test in tests:
164        write_controlfiles(test)
165
166
167if __name__ == "__main__":
168    main()
169