• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2018 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import placeholder
16import expect
17import re
18
19from spirv_test_framework import inside_spirv_testsuite
20
21
22def empty_main_assembly():
23  return """
24         OpCapability Shader
25         OpMemoryModel Logical GLSL450
26         OpEntryPoint Vertex %4 "main"
27         OpName %4 "main"
28    %2 = OpTypeVoid
29    %3 = OpTypeFunction %2
30    %4 = OpFunction %2 None %3
31    %5 = OpLabel
32         OpReturn
33         OpFunctionEnd"""
34
35
36@inside_spirv_testsuite('SpirvOptConfigFile')
37class TestOconfigEmpty(expect.SuccessfulReturn):
38  """Tests empty config files are accepted."""
39
40  shader = placeholder.FileSPIRVShader(empty_main_assembly(), '.spvasm')
41  config = placeholder.ConfigFlagsFile('', '.cfg')
42  spirv_args = [shader, '-o', placeholder.TempFileName('output.spv'), config]
43
44
45@inside_spirv_testsuite('SpirvOptConfigFile')
46class TestOconfigComments(expect.SuccessfulReturn):
47  """Tests empty config files are accepted.
48
49  https://github.com/KhronosGroup/SPIRV-Tools/issues/1778
50  """
51
52  shader = placeholder.FileSPIRVShader(empty_main_assembly(), '.spvasm')
53  config = placeholder.ConfigFlagsFile("""
54# This is a comment.
55-O
56--loop-unroll
57""", '.cfg')
58  spirv_args = [shader, '-o', placeholder.TempFileName('output.spv'), config]
59