1e5c31af7Sopenharmony_ciOpenGL and OpenGL ES 2.0/3.X Conformance Test Contribution Guide 2e5c31af7Sopenharmony_ci================= 3e5c31af7Sopenharmony_ci 4e5c31af7Sopenharmony_ciThis document describes how to add new tests to the OpenGL and OpenGL ES 5e5c31af7Sopenharmony_ci2.0/3.X conformance test suites. 6e5c31af7Sopenharmony_ci 7e5c31af7Sopenharmony_ciContents 8e5c31af7Sopenharmony_ci------------------------ 9e5c31af7Sopenharmony_ci- [Tips for developing new tests](#tips-for-developing-new-tests) 10e5c31af7Sopenharmony_ci - [Test framework overview](#test-framework-overview) 11e5c31af7Sopenharmony_ci - [Data Files](#data-files) 12e5c31af7Sopenharmony_ci - [Adding tests to dEQP Framework](#adding-tests-to-deqp-framework) 13e5c31af7Sopenharmony_ci - [Adding tests to GTF](#adding-tests-to-gtf) 14e5c31af7Sopenharmony_ci- [Coding conventions](#coding-conventions) 15e5c31af7Sopenharmony_ci- [Submitting changes](#submitting-changes) 16e5c31af7Sopenharmony_ci 17e5c31af7Sopenharmony_ciTips for developing new tests 18e5c31af7Sopenharmony_ci------------------------ 19e5c31af7Sopenharmony_ciIn general all new test cases should be written in the new framework residing 20e5c31af7Sopenharmony_ciin the `framework` directory. Those tests should be added to the 21e5c31af7Sopenharmony_ci`external/openglcts/modules` directory in the appropriate place. 22e5c31af7Sopenharmony_ci 23e5c31af7Sopenharmony_ciSee instructions below. 24e5c31af7Sopenharmony_ci 25e5c31af7Sopenharmony_ci### Test framework overview 26e5c31af7Sopenharmony_ci 27e5c31af7Sopenharmony_ciTests are organized as a conceptual tree consisting of groups and, as leaves of 28e5c31af7Sopenharmony_cithe tree, atomic test cases. Each node in the hierarchy has three major 29e5c31af7Sopenharmony_cifunctions that are called from test executor (`tcu::TestExecutor`): 30e5c31af7Sopenharmony_ci1. `init()` - called when executor enters test node 31e5c31af7Sopenharmony_ci2. `iterate()` - called for test cases until `iterate()` returns `STOP` 32e5c31af7Sopenharmony_ci3. `deinit()` - called when leaving node 33e5c31af7Sopenharmony_ci 34e5c31af7Sopenharmony_ciEach node can access a shared test context (`tcu::TestContext`). The test 35e5c31af7Sopenharmony_cicontext provides for example logging and resource access functionality. 36e5c31af7Sopenharmony_ciTest case results are also passed to executor using the test context 37e5c31af7Sopenharmony_ci(`setTestResult()`). 38e5c31af7Sopenharmony_ci 39e5c31af7Sopenharmony_ciThe root nodes are called test packages: They provide some package-specific 40e5c31af7Sopenharmony_cibehavior for the TestExecutor, and often provide package-specific context for 41e5c31af7Sopenharmony_citest cases. CTS packages (except `CTS-Configs.*`) create a rendering context 42e5c31af7Sopenharmony_ciin `init()` and tear it down in `deinit()`. The rendering context is passed 43e5c31af7Sopenharmony_cidown in hierarchy in a package-specific `glcts::Context` object. 44e5c31af7Sopenharmony_ci 45e5c31af7Sopenharmony_ciTest groups do not contain any test code. They usually create child nodes in 46e5c31af7Sopenharmony_ci`init()`. Default `deinit()` for group nodes will destroy any created child 47e5c31af7Sopenharmony_cinodes, thus saving memory during execution. 48e5c31af7Sopenharmony_ci 49e5c31af7Sopenharmony_ciSome test groups use a pre-defined list of children, while some may populate 50e5c31af7Sopenharmony_cithe list dynamically, parsing the test script. 51e5c31af7Sopenharmony_ci 52e5c31af7Sopenharmony_ci### Data Files 53e5c31af7Sopenharmony_ci 54e5c31af7Sopenharmony_ciData files are copied from source directory to build directory as a post-build 55e5c31af7Sopenharmony_cistep for `glcts` target. Compiled binaries read data files 56e5c31af7Sopenharmony_cifrom `<workdir>/gl_cts` directory 57e5c31af7Sopenharmony_ci(for example: `<workdir>/gl_cts/data/gles3/arrays.test`). 58e5c31af7Sopenharmony_ci 59e5c31af7Sopenharmony_ciThe data file copy step means that `glcts` target must be built in order to see 60e5c31af7Sopenharmony_cichanges made to the data files in the source directories. On Linux this means 61e5c31af7Sopenharmony_ciinvoking `make` in `<builddir>`. 62e5c31af7Sopenharmony_ci 63e5c31af7Sopenharmony_ciThe data files can be included in the built binaries. See section on build 64e5c31af7Sopenharmony_ciconfiguration for details. Android build always builds a complete APK package 65e5c31af7Sopenharmony_ciwith all the required files. 66e5c31af7Sopenharmony_ci 67e5c31af7Sopenharmony_ci### Adding tests to dEQP Framework 68e5c31af7Sopenharmony_ci 69e5c31af7Sopenharmony_ciTests can be added to new or existing source files in `external/openglcts/modules` directory. 70e5c31af7Sopenharmony_ciTo register a test case into the hierarchy, the test case must be added as a 71e5c31af7Sopenharmony_cichild in a test group that is already connected to the hierarchy. 72e5c31af7Sopenharmony_ci 73e5c31af7Sopenharmony_ciThere is a mini shader test framework (`glcts::ShaderLibrary`) that can create 74e5c31af7Sopenharmony_cishader cases from `*.test` files. See file `es3cTestPackage.cpp` for details on, 75e5c31af7Sopenharmony_cihow to add new `*.test` files, and the existing test files in `external/openglcts/modules/gles3` 76e5c31af7Sopenharmony_cifor format reference. 77e5c31af7Sopenharmony_ci 78e5c31af7Sopenharmony_ci### Adding tests to GTF 79e5c31af7Sopenharmony_ci 80e5c31af7Sopenharmony_ciThis module is essentially frozen and should no longer be extended. 81e5c31af7Sopenharmony_ci 82e5c31af7Sopenharmony_ciCoding conventions 83e5c31af7Sopenharmony_ci------------------------ 84e5c31af7Sopenharmony_ciThe OpenGL CTS source is formatted using [`clang-format` v4.0](http://clang.llvm.org/docs/ClangFormat.html). 85e5c31af7Sopenharmony_ciBefore submitting your changes make sure that the changes are formatted properly. 86e5c31af7Sopenharmony_ciA recommended way to do that is to run [`clang-format-diff.py`](https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/clang-format-diff.py) 87e5c31af7Sopenharmony_ciscript on the changes, e.g.: 88e5c31af7Sopenharmony_ci 89e5c31af7Sopenharmony_ci cd external/openglcts && git diff -U0 HEAD^ . | python clang-format-diff.py -style=file -i -p3 -binary clang-format-4.0 90e5c31af7Sopenharmony_ci 91e5c31af7Sopenharmony_ciSubmitting changes 92e5c31af7Sopenharmony_ci------------------------ 93e5c31af7Sopenharmony_ciPlease refer to the [Pull Requests](https://github.com/KhronosGroup/Vulkan-CTS/wiki/Contributing#pull-requests) 94e5c31af7Sopenharmony_cisection of the Open GL CTS Public Wiki. 95