tree: ecf58ab31fb52ff473511caeb239dc2f91e119cf
  1. API_test.cpp
  2. CollectVariables_test.cpp
  3. ConstructCompiler_test.cpp
  4. FloatLex_test.cpp
  5. GeometryShader_test.cpp
  6. GlFragDataNotModified_test.cpp
  7. HashNames_test.cpp
  8. ImmutableString_test.cpp
  9. ImmutableString_test_autogen.cpp
  10. IntermNode_test.cpp
  11. MSLOutput_test.cpp
  12. NV_draw_buffers_test.cpp
  13. Parse_test.cpp
  14. Precise_test.cpp
  15. PruneEmptyCases_test.cpp
  16. PruneEmptyDeclarations_test.cpp
  17. PruneNoOps_test.cpp
  18. PrunePureLiteralStatements_test.cpp
  19. PruneUnusedFunctions_test.cpp
  20. QualificationOrder_test.cpp
  21. QualificationOrderESSL31_test.cpp
  22. README.md
  23. RecordConstantPrecision_test.cpp
  24. RemoveUnreferencedVariables_test.cpp
  25. SamplerMultisample_test.cpp
  26. ShaderValidation_test.cpp
  27. ShaderVariable_test.cpp
  28. ShCompile_test.cpp
  29. SimplifyLoopConditions_test.cpp
  30. TextureFunction_test.cpp
  31. Type_test.cpp
  32. TypeTracking_test.cpp
  33. UnfoldShortCircuitAST_test.cpp
  34. UnrollFlatten_test.cpp
  35. VariablePacker_test.cpp
  36. WGSLOutput_test.cpp
  37. WorkGroupSize_test.cpp
src/tests/compiler_tests/README.md

Translator Unit Tests

This directory contains historical unit tests for the ANGLE translator. Barring a few cases, they should be considered deprecated. Do not add new tests to this directory.

The existing translator tests are severely limited in what they test. They often verify translation by asserting that a substring exists in the translated source or a node is found in the AST. However, neither is sufficient to ensure the transformations are done correctly. Often issues are discovered only when the shaders are used in a draw call and the translated source is given to the native driver.

Furthermore, with the built-in assumptions about the way the AST works, these tests are incompatible with the upcoming IR.

Instead, add end-to-end tests:

  • They can be easily tested on every backend
  • Functional testing with a draw call ensures the transformations are correct
  • Using the GL_ANGLE_translated_shader_source extension, we can still verify the output is as expected. This is a maintenance burden however and best avoided unless there is no functional way to verify the transformation is done correctly, e.g. if the transformation works around undefined behavior which can't be reliably tested.

To test translator validation, add new tests to GLSLValidationTest.cpp, which not only verifies that compilation fails, but also has facilities to ensure the failure reason is as expected (and not, for example, a typo in the test)

To test transformations, add new tests to GLSLTest.cpp that would fail if the transformation in question is not done. By using ANGLE features to control the translator flag in question, the transformation can be force-enabled in a test suite, e.g. by instantiating with ES3_OPENGL().enable(Feature::ScalarizeVecAndMatConstructorArgs)

To test that the output includes a specific text, if there is no better form of verification, add new tests to GLSLOutputTest.cpp.