From cda7de7891c744fe96a3d4e5f70ce4e9b600c0dc Mon Sep 17 00:00:00 2001
From: Luis Araujo <luis.araujo@collabora.co.uk>
Date: Tue, 4 Apr 2017 01:29:37 +0800
Subject: [PATCH] Add webkit2gtk javascript core test

This commit adds the webkit2gtk javascript core LAVA test definition
and the test script to execute the tests.

Signed-off-by: Luis Araujo <luis.araujo@collabora.co.uk>
Reviewed-by: Emanuele Aina <emanuele.aina@collabora.com>
Differential Revision: https://phabricator.apertis.org/D6476
---
 webkit/run-webkit2gtk-jsc-tests | 44 +++++++++++++++++++++++++++++++++
 webkit/webkit2gtk-jsc.yaml      | 28 +++++++++++++++++++++
 2 files changed, 72 insertions(+)
 create mode 100755 webkit/run-webkit2gtk-jsc-tests
 create mode 100644 webkit/webkit2gtk-jsc.yaml

diff --git a/webkit/run-webkit2gtk-jsc-tests b/webkit/run-webkit2gtk-jsc-tests
new file mode 100755
index 00000000..04667bdb
--- /dev/null
+++ b/webkit/run-webkit2gtk-jsc-tests
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+# run-webkit2gtk-jsc-tests — run WebKit2GTK JavaScriptCore tests
+#
+# Copyright © 2017 Collabora Ltd.
+#
+# SPDX-License-Identifier: MPL-2.0
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+set -e
+
+JSC_BIN="/usr/bin/jsc/jsc"
+
+# Run tests in a temporary directory.
+TEST_DIR=$(mktemp --directory --tmpdir webkit2gtk-tests.XXXXXXXXXX)
+echo "Test directory: '${TEST_DIR}'"
+
+TEST_BIN_DIR="${TEST_DIR}/bin"
+TEST_SOURCES="/usr/share/webkit2gtk/testing"
+TEST_COMMAND="${TEST_SOURCES}/Tools/Scripts/run-javascriptcore-tests --gtk --no-build"
+RESULTS_FILE="${TEST_BIN_DIR}/jsc-stress-results/results"
+
+# Setup test environment
+mkdir -p "${TEST_BIN_DIR}"
+ln -s "${JSC_BIN}" "${TEST_BIN_DIR}/jsc"
+
+# Run tests using the 'run-javascriptcore-tests' command
+# Ignore failed exit code as this command exits with an
+# error if a test fails.
+${TEST_COMMAND} --root="${TEST_DIR}"         \
+	        --sources="${TEST_SOURCES}"  \
+	        --jsc-driver-args='-v' || echo "tests exit code: $?"
+
+# Show all results at the end
+if [ ! -r "${RESULTS_FILE}" ]
+then
+  echo "No results file available: ${RESULTS_FILE}"
+  echo "showing-tests-results: FAIL"
+  exit 1
+fi
+
+cat "${RESULTS_FILE}"
diff --git a/webkit/webkit2gtk-jsc.yaml b/webkit/webkit2gtk-jsc.yaml
new file mode 100644
index 00000000..4130c723
--- /dev/null
+++ b/webkit/webkit2gtk-jsc.yaml
@@ -0,0 +1,28 @@
+metadata:
+  name: webkit2gtk-jsc
+  format: "Lava-Test-Shell Test Definition 1.0"
+  description: "Run WebKit2GTK javascriptcore tests"
+  maintainer: "luis.araujo@collabora.co.uk"
+  scope:
+  - functional
+  environment:
+  - lava-test-shell
+
+install:
+  deps:
+  - make
+  - perl-doc
+  - ruby
+  - webkit2gtk-testing
+
+run:
+  steps:
+  - common/run-test-in-systemd --name=run-webkit2gtk-jsc-tests --timeout=18000 --user=user --
+    webkit/run-webkit2gtk-jsc-tests
+
+parse:
+  fixupdict:
+    FAIL: fail
+    PASS: pass
+  pattern: '^.*/(?P<test_case_id>[a-zA-Z0-9_\-\.]+):\s(?P<result>PASS|FAIL)'
+
-- 
GitLab