#!/usr/bin/env python
# Copyright (c) 2019 The Khronos Group Inc.
# Use of this source code is governed by an MIT-style license that can be
# found in the LICENSE.txt file.
"""
Generator for fboinvalidate* tests.
This file needs to be run in its folder.
"""
import sys
_DO_NOT_EDIT_WARNING = """
"""
_HTML_TEMPLATE = """
WebGL FBO Invalidate Conformance Tests
"""
_GROUPS = [
'default',
'whole',
'sub',
'format',
'target',
]
_GROUP_TEST_COUNTS = [
1,
1,
1,
3,
1
]
def GenerateFilename(group, count, index):
"""Generate test filename."""
filename = group
assert index >= 0 and index < count
if count > 1:
index_str = str(index)
if index < 10:
index_str = "0" + index_str
filename += "_" + index_str
filename += ".html"
return filename
def WriteTest(filename, start, end):
"""Write one test."""
file = open(filename, "wb")
file.write(_DO_NOT_EDIT_WARNING)
file.write(_HTML_TEMPLATE % {
'start': start,
'end': end
})
file.close
def GenerateTests():
"""Generate all tests."""
assert len(_GROUPS) == len(_GROUP_TEST_COUNTS)
test_index = 0
filelist = []
for ii in range(len(_GROUPS)):
group = _GROUPS[ii]
count = _GROUP_TEST_COUNTS[ii]
for index in range(count):
filename = GenerateFilename(group, count, index)
filelist.append(filename)
WriteTest(filename, test_index, test_index + 1)
test_index += 1
return filelist
def GenerateTestList(filelist):
file = open("00_test_list.txt", "wb")
file.write('\n'.join(filelist))
file.close
def main(argv):
"""This is the main function."""
filelist = GenerateTests()
GenerateTestList(filelist)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))