mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-26 21:30:07 +00:00
03000a3a38
This forks the testing harness from https://github.com/google/shaderc to allow testing CLI tools. New features needed for SPIRV-Tools include: 1- A new PlaceHolder subclass for spirv shaders. This place holder calls spirv-as to convert assembly input into SPIRV bytecode. This is required for most tools in SPIRV-Tools. 2- A minimal testing file for testing basic functionality of spirv-opt. Add tests for all flags in spirv-opt. 1. Adds tests to check that known flags match the names that each pass advertises. 2. Adds tests to check that -O, -Os and --legalize-hlsl schedule the expected passes. 3. Adds more functionality to Expect classes to support regular expression matching on stderr. 4. Add checks for integer arguments to optimization flags. 5. Fixes #1817 by modifying the parsing of integer arguments in flags that take them. 6. Fixes -Oconfig file parsing (#1778). It reads every line of the file into a string and then parses that string by tokenizing every group of characters between whitespaces (using the standard cin reading operator). This mimics shell command-line parsing, but it does not support quoting (and I'm not planning to).
156 lines
3.3 KiB
Python
Executable File
156 lines
3.3 KiB
Python
Executable File
# Copyright (c) 2018 Google LLC
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
from spirv_test_framework import get_all_test_methods, get_all_superclasses
|
|
from nose.tools import assert_equal, with_setup
|
|
|
|
|
|
# Classes to be used in testing get_all_{superclasses|test_methods}()
|
|
class Root:
|
|
|
|
def check_root(self):
|
|
pass
|
|
|
|
|
|
class A(Root):
|
|
|
|
def check_a(self):
|
|
pass
|
|
|
|
|
|
class B(Root):
|
|
|
|
def check_b(self):
|
|
pass
|
|
|
|
|
|
class C(Root):
|
|
|
|
def check_c(self):
|
|
pass
|
|
|
|
|
|
class D(Root):
|
|
|
|
def check_d(self):
|
|
pass
|
|
|
|
|
|
class E(Root):
|
|
|
|
def check_e(self):
|
|
pass
|
|
|
|
|
|
class H(B, C, D):
|
|
|
|
def check_h(self):
|
|
pass
|
|
|
|
|
|
class I(E):
|
|
|
|
def check_i(self):
|
|
pass
|
|
|
|
|
|
class O(H, I):
|
|
|
|
def check_o(self):
|
|
pass
|
|
|
|
|
|
class U(A, O):
|
|
|
|
def check_u(self):
|
|
pass
|
|
|
|
|
|
class X(U, A):
|
|
|
|
def check_x(self):
|
|
pass
|
|
|
|
|
|
class R1:
|
|
|
|
def check_r1(self):
|
|
pass
|
|
|
|
|
|
class R2:
|
|
|
|
def check_r2(self):
|
|
pass
|
|
|
|
|
|
class Multi(R1, R2):
|
|
|
|
def check_multi(self):
|
|
pass
|
|
|
|
|
|
def nosetest_get_all_superclasses():
|
|
"""Tests get_all_superclasses()."""
|
|
|
|
assert_equal(get_all_superclasses(A), [Root])
|
|
assert_equal(get_all_superclasses(B), [Root])
|
|
assert_equal(get_all_superclasses(C), [Root])
|
|
assert_equal(get_all_superclasses(D), [Root])
|
|
assert_equal(get_all_superclasses(E), [Root])
|
|
|
|
assert_equal(get_all_superclasses(H), [Root, B, C, D])
|
|
assert_equal(get_all_superclasses(I), [Root, E])
|
|
|
|
assert_equal(get_all_superclasses(O), [Root, B, C, D, E, H, I])
|
|
|
|
assert_equal(get_all_superclasses(U), [Root, B, C, D, E, H, I, A, O])
|
|
assert_equal(get_all_superclasses(X), [Root, B, C, D, E, H, I, A, O, U])
|
|
|
|
assert_equal(get_all_superclasses(Multi), [R1, R2])
|
|
|
|
|
|
def nosetest_get_all_methods():
|
|
"""Tests get_all_test_methods()."""
|
|
assert_equal(get_all_test_methods(A), ['check_root', 'check_a'])
|
|
assert_equal(get_all_test_methods(B), ['check_root', 'check_b'])
|
|
assert_equal(get_all_test_methods(C), ['check_root', 'check_c'])
|
|
assert_equal(get_all_test_methods(D), ['check_root', 'check_d'])
|
|
assert_equal(get_all_test_methods(E), ['check_root', 'check_e'])
|
|
|
|
assert_equal(
|
|
get_all_test_methods(H),
|
|
['check_root', 'check_b', 'check_c', 'check_d', 'check_h'])
|
|
assert_equal(get_all_test_methods(I), ['check_root', 'check_e', 'check_i'])
|
|
|
|
assert_equal(
|
|
get_all_test_methods(O), [
|
|
'check_root', 'check_b', 'check_c', 'check_d', 'check_e', 'check_h',
|
|
'check_i', 'check_o'
|
|
])
|
|
|
|
assert_equal(
|
|
get_all_test_methods(U), [
|
|
'check_root', 'check_b', 'check_c', 'check_d', 'check_e', 'check_h',
|
|
'check_i', 'check_a', 'check_o', 'check_u'
|
|
])
|
|
assert_equal(
|
|
get_all_test_methods(X), [
|
|
'check_root', 'check_b', 'check_c', 'check_d', 'check_e', 'check_h',
|
|
'check_i', 'check_a', 'check_o', 'check_u', 'check_x'
|
|
])
|
|
|
|
assert_equal(
|
|
get_all_test_methods(Multi), ['check_r1', 'check_r2', 'check_multi'])
|