xref: /aosp_15_r20/external/deqp/scripts/verify/package.py (revision 35238bce31c2a825756842865a792f8cf7f89930)
1# -*- coding: utf-8 -*-
2
3#-------------------------------------------------------------------------
4# Vulkan CTS
5# ----------
6#
7# Copyright (c) 2016 Google Inc.
8#
9# Licensed under the Apache License, Version 2.0 (the "License");
10# you may not use this file except in compliance with the License.
11# You may obtain a copy of the License at
12#
13#      http://www.apache.org/licenses/LICENSE-2.0
14#
15# Unless required by applicable law or agreed to in writing, software
16# distributed under the License is distributed on an "AS IS" BASIS,
17# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18# See the License for the specific language governing permissions and
19# limitations under the License.
20#
21#-------------------------------------------------------------------------
22
23import os
24from fnmatch import fnmatch
25
26STATEMENT_PATTERN = "STATEMENT-*"
27TEST_LOG_PATTERN = "*.qpa"
28GIT_STATUS_PATTERN = "*git-status.txt"
29GIT_LOG_PATTERN = "*git-log.txt"
30PATCH_PATTERN = "*.patch"
31SUMMARY_PATTERN = "cts-run-summary.xml"
32
33class PackageDescription:
34    def __init__ (self, basePath, statement, testLogs, gitStatus, gitLog, patches, summary, conformVersion, conformOs, otherItems):
35        self.basePath = basePath
36        self.statement = statement
37        self.testLogs = testLogs
38        self.gitStatus = gitStatus
39        self.gitLog = gitLog
40        self.patches = patches
41        self.summary = summary
42        self.otherItems = otherItems
43        self.conformVersion = conformVersion
44        self.conformOs = conformOs
45
46def getPackageDescription (packagePath):
47    allItems = os.listdir(packagePath)
48    statement = None
49    testLogs = []
50    gitStatus = []
51    gitLog = []
52    patches = []
53    summary = None
54    otherItems = []
55    conformVersion = None
56    conformOs = None
57
58    for item in allItems:
59        if fnmatch(item, STATEMENT_PATTERN):
60            assert statement == None
61            statement = item
62        elif fnmatch(item, TEST_LOG_PATTERN):
63            testLogs.append(item)
64        elif fnmatch(item, GIT_STATUS_PATTERN):
65            gitStatus.append(item)
66        elif fnmatch(item, GIT_LOG_PATTERN):
67            gitLog.append((item, '.'))
68        elif fnmatch(item, PATCH_PATTERN):
69            patches.append(item)
70        elif fnmatch(item, SUMMARY_PATTERN):
71            assert summary == None
72            summary = item
73        else:
74            otherItems.append(item)
75
76    return PackageDescription(packagePath, statement, testLogs, gitStatus, gitLog, patches, summary, conformVersion, conformOs, otherItems)
77