Move Khronos WebGL tests to /_webgl/

This commit is contained in:
Anthony Ramine 2018-08-25 00:46:42 +02:00
parent d827370804
commit 4852f7d616
7200 changed files with 53650 additions and 228616 deletions

View file

@ -0,0 +1,158 @@
#!/usr/bin/env python
import os
import subprocess
import sys
import tempfile
import shutil
import bisect
import argparse
KHRONOS_REPO_URL = "https://github.com/KhronosGroup/WebGL.git"
# Patches for conformance tests 1.0.x
PATCHES_1X = [
("js-test-pre.patch", "resources/js-test-pre.js"),
("unit.patch", "conformance/more/unit.js"),
("unit2.patch", "conformance/more/unit.js"),
("timeout.patch", None)
]
# Patches for conformance tests 2.0.x
PATCHES_2X = [
("js-test-pre2.patch", "js/js-test-pre.js"),
("unit.patch", "conformance/more/unit.js"),
("unit2.patch", "conformance/more/unit.js")
]
# Fix for 'UnicodeDecodeError: 'ascii' codec can't decode byte'
reload(sys)
sys.setdefaultencoding('utf8')
def usage():
print("Usage: {} version destination [existing_webgl_repo]".format(sys.argv[0]))
sys.exit(1)
def get_tests(base_dir, file_name, tests_list):
list_file = os.path.join(base_dir, file_name)
if not os.path.isfile(list_file):
print("Test list ({}) not found".format(list_file))
sys.exit(1)
print("Processing: {}".format(list_file))
with open(list_file, "r") as f:
for line in f:
line = line.strip()
if not line or line.startswith("#") or line.startswith("//"):
continue # It's an empty line or a comment
# Lines often are in the form:
# --min-version x.x.x abc.html
#
# We only care about the last part
line = line.split(" ")[-1]
if line.endswith(".html"):
tests_list.append(os.path.join(base_dir, line))
if line.endswith(".txt"):
(next_dir, file_name) = os.path.split(os.path.join(base_dir, line))
get_tests(next_dir, file_name, tests_list)
# Insert the test harness scripts before any other script
def process_test(test):
(new, new_path) = tempfile.mkstemp()
script_tag_found = False
with open(test, "r") as test_file:
for line in test_file:
if not script_tag_found and "<script" in line:
indent = ' ' * line.index('<')
script_tag_found = True
os.write(new, "{}<script src=/resources/testharness.js></script>\n".format(indent))
os.write(new, "{}<script src=/resources/testharnessreport.js></script>\n".format(indent))
os.write(new, line)
os.close(new)
shutil.move(new_path, test)
def update_conformance(version, destination, existing_repo, patches_dir):
print("Trying to import WebGL conformance test suite {} into {}".format(version, destination))
if existing_repo:
directory = existing_repo
print("Using existing WebGL repository: {}".format(directory))
else:
directory = tempfile.mkdtemp()
print("Cloning WebGL repository into temporary directory {}".format(directory))
subprocess.check_call(["git", "clone", KHRONOS_REPO_URL, directory, "--depth", "1"])
suite_dir = os.path.join(directory, "conformance-suites", version)
print("Test suite directory: {}".format(suite_dir))
if not os.path.isdir(suite_dir):
print("Test suite directory ({}) not found, aborting...".format(suite_dir))
sys.exit(1)
# We recursively copy all the test suite to `destination`
shutil.copytree(suite_dir, destination)
# Get all the tests, remove any html file which is not in the list, and
# later process them.
tests = []
get_tests(destination, "00_test_list.txt", tests)
test_count = len(tests)
print("Found {} tests.".format(test_count))
print("Removing non-test html files")
# To use binary search, which speeds things up a little
# instead of f in tests
tests.sort()
# Remove html files that are not tests
for dirpath, dirnames, filenames in os.walk(destination):
if '/resources' in dirpath:
continue # Most of the files under resources directories are used
for f in filenames:
if not f.endswith('.html'):
continue
f = os.path.join(dirpath, f)
pos = bisect.bisect_left(tests, f)
if pos == test_count or tests[pos] != f:
print("Removing: {}".format(f))
os.remove(f)
# Insert our harness into the tests
for test in tests:
process_test(test)
# Try to apply the patches to the required files
if not patches_dir:
patches_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
patches = PATCHES_2X if version.startswith('2') else PATCHES_1X
for patch, file_name in patches:
try:
patch = os.path.join(patches_dir, patch)
if file_name is None:
subprocess.check_call(["patch", "-d", destination, "-p", "1"], stdin=open(patch))
else:
subprocess.check_call(["patch", "-x", "3", "-d", destination, file_name, patch])
except subprocess.CalledProcessError:
print("Automatic patch failed for {}".format(file_name))
print("Please review the WPT integration and update {} accordingly".format(os.path.basename(patch)))
def main():
parser = argparse.ArgumentParser()
parser.add_argument("version", help="WebGL test suite version (e.g.: 1.0.3)")
parser.add_argument("destination", help="Test suite destination")
parser.add_argument("-e", "--existing-repo", help="Path to an existing clone of the khronos WebGL repository")
args = parser.parse_args()
update_conformance(args.version, args.destination, args.existing_repo, None)
if __name__ == '__main__':
main()

View file

@ -0,0 +1,98 @@
diff --git a/conformance-suites/1.0.3/resources/js-test-pre.js b/conformance-suites/1.0.3/resources/js-test-pre.js
index 2a03001..c4bb653 100644
--- a/conformance-suites/1.0.3/resources/js-test-pre.js
+++ b/conformance-suites/1.0.3/resources/js-test-pre.js
@@ -71,11 +71,25 @@ function nonKhronosFrameworkNotifyDone() {
}
}
-function reportTestResultsToHarness(success, msg) {
- if (window.parent.webglTestHarness) {
- window.parent.webglTestHarness.reportResults(window.location.pathname, success, msg);
+(function() {
+ var WPT_TEST_ID = 0;
+
+ // Store the current WPT test harness `test` function
+ // if found, since it's overriden by some tests.
+ var wpt_test = window.test;
+ var wpt_assert_true = window.assert_true;
+ var wt_async_test = window.async_test;
+
+ window.reportTestResultsToHarness = function reportTestResultsToHarness(success, msg) {
+ if (window.parent.webglTestHarness) {
+ window.parent.webglTestHarness.reportResults(window.location.pathname, success, msg);
+ } else if (wpt_test) { // WPT test harness
+ wpt_test(function () {
+ wpt_assert_true(success, msg);
+ }, "WebGL test #" + (WPT_TEST_ID++) + ": " + msg);
+ }
}
-}
+}())
function notifyFinishedToHarness() {
if (window.parent.webglTestHarness) {
@@ -86,13 +100,19 @@ function notifyFinishedToHarness() {
}
}
+(function() {
+ var oldNotify = notifyFinishedToHarness;
+ var t = async_test("Overall test");
+ window.notifyFinishedToHarness = t.step_func_done(oldNotify);
+}())
+
function _logToConsole(msg)
{
if (window.console)
window.console.log(msg);
}
-var _jsTestPreVerboseLogging = false;
+var _jsTestPreVerboseLogging = true;
function enableJSTestPreVerboseLogging()
{
@@ -105,31 +125,18 @@ function description(msg)
if (msg === undefined) {
msg = document.title;
}
- // For MSIE 6 compatibility
- var span = document.createElement("span");
- span.innerHTML = '<p>' + msg + '</p><p>On success, you will see a series of "<span class="pass">PASS</span>" messages, followed by "<span class="pass">TEST COMPLETE</span>".</p>';
- var description = document.getElementById("description");
- if (description.firstChild)
- description.replaceChild(span, description.firstChild);
- else
- description.appendChild(span);
- if (_jsTestPreVerboseLogging) {
- _logToConsole(msg);
- }
+ _logToConsole("DESCRIPTION: " + msg);
}
function _addSpan(contents)
{
- var span = document.createElement("span");
- document.getElementById("console").appendChild(span); // insert it first so XHTML knows the namespace
- span.innerHTML = contents + '<br />';
}
function debug(msg)
{
_addSpan(msg);
if (_jsTestPreVerboseLogging) {
- _logToConsole(msg);
+ _logToConsole(msg);
}
}
@@ -143,7 +150,7 @@ function testPassed(msg)
reportTestResultsToHarness(true, msg);
_addSpan('<span><span class="pass">PASS</span> ' + escapeHTML(msg) + '</span>');
if (_jsTestPreVerboseLogging) {
- _logToConsole('PASS ' + msg);
+ _logToConsole('PASS ' + msg);
}
}

View file

@ -0,0 +1,84 @@
diff --git a/conformance-suites/2.0.0/js/js-test-pre.js b/conformance-suites/2.0.0/js/js-test-pre.js
index df30a6f..7ca8559 100644
--- a/conformance-suites/2.0.0/js/js-test-pre.js
+++ b/conformance-suites/2.0.0/js/js-test-pre.js
@@ -111,11 +111,25 @@ function nonKhronosFrameworkNotifyDone() {
}
}
-function reportTestResultsToHarness(success, msg) {
- if (window.parent.webglTestHarness) {
- window.parent.webglTestHarness.reportResults(window.location.pathname, success, msg);
- }
-}
+(function() {
+ var WPT_TEST_ID = 0;
+
+ // Store the current WPT test harness `test` function
+ // if found, since it's overriden by some tests.
+ var wpt_test = window.test;
+ var wpt_assert_true = window.assert_true;
+ var wt_async_test = window.async_test;
+
+ window.reportTestResultsToHarness = function reportTestResultsToHarness(success, msg) {
+ if (window.parent.webglTestHarness) {
+ window.parent.webglTestHarness.reportResults(window.location.pathname, success, msg);
+ } else if (wpt_test) { // WPT test harness
+ wpt_test(function () {
+ wpt_assert_true(success, msg);
+ }, "WebGL test #" + (WPT_TEST_ID++) + ": " + msg);
+ }
+ }
+ }())
function reportSkippedTestResultsToHarness(success, msg) {
if (window.parent.webglTestHarness) {
@@ -132,6 +146,12 @@ function notifyFinishedToHarness() {
}
}
+(function() {
+ var oldNotify = notifyFinishedToHarness;
+ var t = async_test("Overall test");
+ window.notifyFinishedToHarness = t.step_func_done(oldNotify);
+}())
+
var _bufferedConsoleLogs = [];
function _bufferedLogToConsole(msg)
@@ -162,7 +182,7 @@ function _flushBufferedLogsToConsole()
}
}
-var _jsTestPreVerboseLogging = false;
+var _jsTestPreVerboseLogging = true;
function enableJSTestPreVerboseLogging()
{
@@ -175,24 +195,12 @@ function description(msg)
if (msg === undefined) {
msg = document.title;
}
- // For MSIE 6 compatibility
- var span = document.createElement("span");
- span.innerHTML = '<p>' + msg + '</p><p>On success, you will see a series of "<span class="pass">PASS</span>" messages, followed by "<span class="pass">TEST COMPLETE</span>".</p>';
- var description = document.getElementById("description");
- if (description.firstChild)
- description.replaceChild(span, description.firstChild);
- else
- description.appendChild(span);
- if (_jsTestPreVerboseLogging) {
- _bufferedLogToConsole(msg);
- }
+
+ _bufferedLogToConsole("DESCRIPTION: " +msg);
}
function _addSpan(contents)
{
- var span = document.createElement("span");
- document.getElementById("console").appendChild(span); // insert it first so XHTML knows the namespace
- span.innerHTML = contents + '<br />';
}
function debug(msg)

View file

@ -0,0 +1,120 @@
diff --git i/conformance/attribs/gl-vertex-attrib-zero-issues.html w/conformance/attribs/gl-vertex-attrib-zero-issues.html
index de45ce308c..11a83ac00a 100644
--- i/conformance/attribs/gl-vertex-attrib-zero-issues.html
+++ w/conformance/attribs/gl-vertex-attrib-zero-issues.html
@@ -29,6 +29,7 @@
<html>
<head>
<meta charset="utf-8">
+<meta name="timeout" content="long">
<title>WebGL Enable Vertex Attrib Zero Test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src=/resources/testharness.js></script>
diff --git i/conformance/canvas/rapid-resizing.html w/conformance/canvas/rapid-resizing.html
index 1faa737222..89f9e1e3c2 100644
--- i/conformance/canvas/rapid-resizing.html
+++ w/conformance/canvas/rapid-resizing.html
@@ -29,6 +29,7 @@
<html>
<head>
<meta charset="utf-8">
+<meta name="timeout" content="long">
<title>WebGL Rapid Resizing Test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src=/resources/testharness.js></script>
diff --git i/conformance/context/context-creation-and-destruction.html w/conformance/context/context-creation-and-destruction.html
index a02dd2d14c..47099e57bd 100644
--- i/conformance/context/context-creation-and-destruction.html
+++ w/conformance/context/context-creation-and-destruction.html
@@ -29,6 +29,7 @@
<html>
<head>
<meta charset="utf-8">
+<meta name="timeout" content="long">
<title>Test that contexts are freed and garbage collected reasonably</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src=/resources/testharness.js></script>
diff --git i/conformance/context/context-creation.html w/conformance/context/context-creation.html
index 04b138daf4..703bcfa8dc 100644
--- i/conformance/context/context-creation.html
+++ w/conformance/context/context-creation.html
@@ -29,6 +29,7 @@
<html>
<head>
<meta charset="utf-8">
+<meta name="timeout" content="long">
<title>Test that you can create large numbers of WebGL contexts.</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src=/resources/testharness.js></script>
diff --git i/conformance/context/context-eviction-with-garbage-collection.html w/conformance/context/context-eviction-with-garbage-collection.html
index 3989c7679a..b52e3a9e9f 100644
--- i/conformance/context/context-eviction-with-garbage-collection.html
+++ w/conformance/context/context-eviction-with-garbage-collection.html
@@ -29,6 +29,7 @@
<html>
<head>
<meta charset="utf-8">
+<meta name="timeout" content="long">
<title>Test that context eviction and garbage collection do not interfere with each other</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src=/resources/testharness.js></script>
diff --git i/conformance/ogles/GL/acos/acos_001_to_006.html w/conformance/ogles/GL/acos/acos_001_to_006.html
index 99de4e0a79..71c8990638 100644
--- i/conformance/ogles/GL/acos/acos_001_to_006.html
+++ w/conformance/ogles/GL/acos/acos_001_to_006.html
@@ -28,6 +28,7 @@
<html>
<head>
<meta charset="utf-8">
+<meta name="timeout" content="long">
<title>WebGL GLSL conformance test: acos_001_to_006.html</title>
<link rel="stylesheet" href="../../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../../resources/ogles-tests.css" />
diff --git i/conformance/ogles/GL/asin/asin_001_to_006.html w/conformance/ogles/GL/asin/asin_001_to_006.html
index 5af87433aa..79afd9f430 100644
--- i/conformance/ogles/GL/asin/asin_001_to_006.html
+++ w/conformance/ogles/GL/asin/asin_001_to_006.html
@@ -28,6 +28,7 @@
<html>
<head>
<meta charset="utf-8">
+<meta name="timeout" content="long">
<title>WebGL GLSL conformance test: asin_001_to_006.html</title>
<link rel="stylesheet" href="../../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../../resources/ogles-tests.css" />
diff --git i/conformance/ogles/GL/log2/log2_001_to_008.html w/conformance/ogles/GL/log2/log2_001_to_008.html
index 5552a4f82e..539cb33214 100644
--- i/conformance/ogles/GL/log2/log2_001_to_008.html
+++ w/conformance/ogles/GL/log2/log2_001_to_008.html
@@ -28,6 +28,7 @@
<html>
<head>
<meta charset="utf-8">
+<meta name="timeout" content="long">
<title>WebGL GLSL conformance test: log2_001_to_008.html</title>
<link rel="stylesheet" href="../../../../resources/js-test-style.css" />
<link rel="stylesheet" href="../../../resources/ogles-tests.css" />
diff --git i/conformance/uniforms/out-of-bounds-uniform-array-access.html w/conformance/uniforms/out-of-bounds-uniform-array-access.html
index 2758b320ff..4d85c3a53a 100644
--- i/conformance/uniforms/out-of-bounds-uniform-array-access.html
+++ w/conformance/uniforms/out-of-bounds-uniform-array-access.html
@@ -29,6 +29,7 @@
<html>
<head>
<meta charset="utf-8">
+<meta name="timeout" content="long">
<title>WebGL out of bounds uniform array access.</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src=/resources/testharness.js></script>
diff --git i/conformance/rendering/many-draw-calls.html w/conformance/rendering/many-draw-calls.html
index c1542f4fa9..b3ee786e0b 100644
--- i/conformance/rendering/many-draw-calls.html
+++ w/conformance/rendering/many-draw-calls.html
@@ -29,6 +29,7 @@
<html>
<head>
<meta charset="utf-8">
+<meta name="timeout" content="long">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>

View file

@ -0,0 +1,19 @@
diff --git a/conformance-suites/1.0.3/conformance/more/unit.js b/conformance-suites/1.0.3/conformance/more/unit.js
index 89f4e87..742f8d7 100644
--- a/conformance-suites/1.0.3/conformance/more/unit.js
+++ b/conformance-suites/1.0.3/conformance/more/unit.js
@@ -892,9 +892,14 @@ GLConstants = [
0x809D
];
+var WPT_TEST_ID = 0;
function reportTestResultsToHarness(success, msg) {
if (window.parent.webglTestHarness) {
window.parent.webglTestHarness.reportResults(window.location.pathname, success, msg);
+ } else if (window.test) { // WPT test harness
+ test(function () {
+ assert_true(success, msg);
+ }, "WebGL test #" + (WPT_TEST_ID++) + ": " + msg);
}
}

View file

@ -0,0 +1,25 @@
diff --git a/conformance-suites/1.0.3/conformance/more/unit.js b/conformance-suits/1.0.3/conformance/more/unit.js
index 742f8d7b9d..428c164699 100644
--- a/conformance-suites/1.0.3/conformance/more/unit.js
+++ b/conformance-suites/1.0.3/conformance/more/unit.js
@@ -53,6 +53,10 @@ if (window.internals) {
window.internals.settings.setWebGLErrorsToConsoleEnabled(false);
}
+if (window.async_test) {
+ var __overall_test = async_test('Overall test');
+}
+
/* -- end platform specific code --*/
Tests = {
autorun : true,
@@ -907,6 +911,9 @@ function notifyFinishedToHarness() {
if (window.parent.webglTestHarness) {
window.parent.webglTestHarness.notifyFinished(window.location.pathname);
}
+ if (window.__overall_test) {
+ window.__overall_test.done();
+ }
}
function initTests() {