oconfig.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. import placeholder
  15. import expect
  16. import re
  17. from spirv_test_framework import inside_spirv_testsuite
  18. def empty_main_assembly():
  19. return """
  20. OpCapability Shader
  21. OpMemoryModel Logical GLSL450
  22. OpEntryPoint Vertex %4 "main"
  23. OpName %4 "main"
  24. %2 = OpTypeVoid
  25. %3 = OpTypeFunction %2
  26. %4 = OpFunction %2 None %3
  27. %5 = OpLabel
  28. OpReturn
  29. OpFunctionEnd"""
  30. @inside_spirv_testsuite('SpirvOptConfigFile')
  31. class TestOconfigEmpty(expect.SuccessfulReturn):
  32. """Tests empty config files are accepted."""
  33. shader = placeholder.FileSPIRVShader(empty_main_assembly(), '.spvasm')
  34. config = placeholder.ConfigFlagsFile('', '.cfg')
  35. spirv_args = [shader, '-o', placeholder.TempFileName('output.spv'), config]
  36. @inside_spirv_testsuite('SpirvOptConfigFile')
  37. class TestOconfigComments(expect.SuccessfulReturn):
  38. """Tests empty config files are accepted.
  39. https://github.com/KhronosGroup/SPIRV-Tools/issues/1778
  40. """
  41. shader = placeholder.FileSPIRVShader(empty_main_assembly(), '.spvasm')
  42. config = placeholder.ConfigFlagsFile("""
  43. # This is a comment.
  44. -O
  45. --loop-unroll
  46. """, '.cfg')
  47. spirv_args = [shader, '-o', placeholder.TempFileName('output.spv'), config]
  48. @inside_spirv_testsuite('SpirvOptConfigFile')
  49. class TestOconfigComments(expect.SuccessfulReturn):
  50. """Tests empty config files are accepted.
  51. https://github.com/KhronosGroup/SPIRV-Tools/issues/1778
  52. """
  53. shader = placeholder.FileSPIRVShader(empty_main_assembly(), '.spvasm')
  54. config = placeholder.ConfigFlagsFile("""
  55. # This is a comment.
  56. -O
  57. --relax-struct-store
  58. """, '.cfg')
  59. spirv_args = [shader, '-o', placeholder.TempFileName('output.spv'), config]