blob: a1e72ec275925496284526ea3263170afe77fe15 [file] [log] [blame]
Tobin Ehlisd22e3ff2015-03-27 11:47:10 -06001#!/usr/bin/env python3
2#
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06003# VK
Tobin Ehlisd22e3ff2015-03-27 11:47:10 -06004#
Courtney Goeltzenleuchterfcbe16f2015-10-29 13:50:34 -06005# Copyright (C) 2015 Valve Corporation
Tobin Ehlisd22e3ff2015-03-27 11:47:10 -06006#
7# Permission is hereby granted, free of charge, to any person obtaining a
8# copy of this software and associated documentation files (the "Software"),
9# to deal in the Software without restriction, including without limitation
10# the rights to use, copy, modify, merge, publish, distribute, sublicense,
11# and/or sell copies of the Software, and to permit persons to whom the
12# Software is furnished to do so, subject to the following conditions:
13#
14# The above copyright notice and this permission notice shall be included
15# in all copies or substantial portions of the Software.
16#
17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23# DEALINGS IN THE SOFTWARE.
Courtney Goeltzenleuchter05559522015-10-30 11:14:30 -060024#
25# Author: Tobin Ehlis <tobin@lunarg.com>
26
Tobin Ehlisd22e3ff2015-03-27 11:47:10 -060027import argparse
28import subprocess
29import sys
30
31# layer_test_suite.py overview
32# This script runs tests and verifies results
33# It's intended to wrap tests run with layers and verify the following:
34# 1. Any expected layers are inserted
35# 2. Any expected layer errors are output
36# 3. No unexpected errors are output
37
38def handle_args():
39 parser = argparse.ArgumentParser(description='Run Vulkan test suite and report errors.')
40 parser.add_argument('--script_name', required=False, default='./run_all_tests_with_layers.sh', help='The script file to be executed and have its output checked.')
41 return parser.parse_args()
42
Mark Lobodzinski0d054fe2015-12-30 08:16:12 -070043expected_layers = ['draw_state', 'mem_tracker', 'param_checker', 'object_tracker']
Tobin Ehlisd22e3ff2015-03-27 11:47:10 -060044
45# Format of this dict is <testname> key points to a list of expected error text
46# The start of each line of output for any given test is compared against the expected error txt
47expected_errors = {'XglRenderTest.CubeWithVertexFetchAndMVP' : ['{OBJTRACK}ERROR : OBJ ERROR : DEPTH_STENCIL_VIEW',
48 '{OBJTRACK}ERROR : OBJ ERROR : GPU_MEMORY',
49 '{OBJTRACK}ERROR : OBJ ERROR : IMAGE'],
Chia-I Wu3432a0c2015-10-27 18:04:07 +080050 'XglRenderTest.CubeWithVertexFetchAndMVPAndTexture' : ['{OBJTRACK}ERROR : OBJ ERROR : COMMAND_BUFFER',
Tobin Ehlisd22e3ff2015-03-27 11:47:10 -060051 '{OBJTRACK}ERROR : OBJ ERROR : DEPTH_STENCIL_VIEW',
52 '{OBJTRACK}ERROR : OBJ ERROR : GPU_MEMORY',
53 '{OBJTRACK}ERROR : OBJ ERROR : IMAGE'],
54 'XglTest.Fence' : ['{OBJTRACK}ERROR : OBJECT VALIDATION WARNING: FENCE'],
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060055 #'XglRenderTest.VKTriangle_OutputLocation' : ['{OBJTRACK}ERROR : vkQueueSubmit Memory reference count'],
Chia-I Wu3432a0c2015-10-27 18:04:07 +080056 'XglRenderTest.TriangleWithVertexFetch' : ['{OBJTRACK}ERROR : OBJ ERROR : COMMAND_BUFFER'],
57 'XglRenderTest.TriangleMRT' : ['{OBJTRACK}ERROR : OBJ ERROR : COMMAND_BUFFER'],
58 'XglRenderTest.QuadWithIndexedVertexFetch' : ['{OBJTRACK}ERROR : OBJ ERROR : COMMAND_BUFFER', '{OBJTRACK}ERROR : OBJ ERROR : COMMAND_BUFFER'],
59 'XglRenderTest.GreyandRedCirclesonBlue' : ['{OBJTRACK}ERROR : OBJ ERROR : COMMAND_BUFFER'],
60 'XglRenderTest.RedCirclesonBlue' : ['{OBJTRACK}ERROR : OBJ ERROR : COMMAND_BUFFER'],
61 'XglRenderTest.GreyCirclesonBlueFade' : ['{OBJTRACK}ERROR : OBJ ERROR : COMMAND_BUFFER'],
62 'XglRenderTest.GreyCirclesonBlueDiscard' : ['{OBJTRACK}ERROR : OBJ ERROR : COMMAND_BUFFER'],
63 'XglRenderTest.TriVertFetchAndVertID' : ['{OBJTRACK}ERROR : OBJ ERROR : COMMAND_BUFFER'],
64 'XglRenderTest.TriVertFetchDeadAttr' : ['{OBJTRACK}ERROR : OBJ ERROR : COMMAND_BUFFER'],}
Tobin Ehlisd22e3ff2015-03-27 11:47:10 -060065
66# Verify that expected errors are hit
67# Return True if all expected errors for any matched tests are found and no unexpected errors are found
68# Return False if a test with expected errors doesn't have all expected errors and/or any unexpected errors occur
69def verify_errors(out_lines):
70 print "Verifying expected errors and making sure no unexpected errors occur."
71 result = True
72 # If we hit a testname line, then catch test name
73 # If testname is in dict, then get expected errors
74 # Pop expected errors off of the list
75 # for any expected errors remaining, flag an issue
76 testname = ''
77 ee_list = []
78 errors_found = 0
79 check_expected_errors = False
80 for line in out_lines:
81 if '[ RUN ]' in line:
82 testname = line[line.find(']')+1:].split()[0].strip()
83 #print "Found testname %s" % testname
84 if testname in expected_errors:
85 ee_list = expected_errors[testname];
86 #print "testname %s has %i expected errors in ee_list %s" % (testname, len(ee_list), ", ".join(ee_list))
87 check_expected_errors = True
88 elif '[ OK ]' in line:
89 if len(ee_list) > 0:
90 print "ERROR : Failed to find expected error(s) for %s: %s" % (testname, ", ".join(ee_list))
91 result = False
92 check_expected_errors = False
93 ee_list = []
94 errors_found = 0
95 elif check_expected_errors:
96 if True in [line.startswith(ex_err) for ex_err in ee_list]:
97 for ee in ee_list:
98 if line.startswith(ee):
99 #print "Found expected error %s in line %s" % (ee, line)
100 errors_found += 1
101 ee_list.remove(ee)
102 if len(ee_list) == 0:
103 print "Found all %i expected errors for testname %s" % (errors_found, testname)
104 elif 'ERROR' in line:
105 print "ERROR : Found unexpected error %s for test %s" % (line, testname)
106 result = False
107 return result
108
109def verify_layers(out_lines):
110 for line in out_lines:
111 if line.startswith("Inserting layer "):
112 layer_name = line.split()[2]
113 #print "Found layer %s" % (layer_name)
114 if layer_name in expected_layers:
115 expected_layers.remove(layer_name)
116 if 0 == len(expected_layers):
117 print "Found all expected layers"
118 return True
119 print "Failed to find layers: %s" % ", ".join(expected_layers)
120 return False
121
122def main(argv=None):
123 # parse args
124 opts = handle_args()
125 # run test and capture output
126 print "Running test script %s" % (opts.script_name)
127 test_result = subprocess.check_output(opts.script_name, stderr=subprocess.STDOUT) #, shell=True)
128 result_lines = test_result.split("\n")
129 if verify_layers(result_lines):
130 if verify_errors(result_lines):
131 print "Verify errors completed successfully"
132 else:
133 print "Verify errors FAILED! See ERROR messages above"
134 else:
135 print "Verify errors FAILED! See ERROR messages above"
136 print "Done running test suite"
137 # verify output
138
139
140if __name__ == "__main__":
141 sys.exit(main())