diff --git a/Makefile.am b/Makefile.am index 1c37c564f..8743964dd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,11 +2,7 @@ include $(top_srcdir)/build/autotools/Makefile.am.silent NULL = -SUBDIRS = clutter doc po build - -if BUILD_TESTS -SUBDIRS += tests -endif +SUBDIRS = build clutter tests doc po if BUILD_EXAMPLES SUBDIRS += examples diff --git a/build/autotools/Makefile.am b/build/autotools/Makefile.am index 8446ea4b6..19dfd1c72 100644 --- a/build/autotools/Makefile.am +++ b/build/autotools/Makefile.am @@ -11,4 +11,8 @@ EXTRA_DIST = \ gtk-doc.m4 \ as-compiler-flag.m4 \ as-linguas.m4 \ + glibtests.m4 \ + glib-tap.mk \ + tap-driver.sh \ + tap-test \ $(NULL) diff --git a/build/autotools/glib-tap.mk b/build/autotools/glib-tap.mk new file mode 100644 index 000000000..7a634cd3e --- /dev/null +++ b/build/autotools/glib-tap.mk @@ -0,0 +1,134 @@ +# GLIB - Library of useful C routines + +TESTS_ENVIRONMENT= \ + G_TEST_SRCDIR="$(abs_srcdir)" \ + G_TEST_BUILDDIR="$(abs_builddir)" \ + G_DEBUG=gc-friendly \ + MALLOC_CHECK_=2 \ + MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256)) +LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/build/autotools/tap-driver.sh +LOG_COMPILER = $(top_srcdir)/build/autotools/tap-test + +NULL = + +# initialize variables for unconditional += appending +BUILT_SOURCES = +BUILT_EXTRA_DIST = +CLEANFILES = *.log *.trs +DISTCLEANFILES = +MAINTAINERCLEANFILES = +EXTRA_DIST = +TESTS = + +installed_test_LTLIBRARIES = +installed_test_PROGRAMS = +installed_test_SCRIPTS = +nobase_installed_test_DATA = + +noinst_LTLIBRARIES = +noinst_PROGRAMS = +noinst_SCRIPTS = +noinst_DATA = + +check_LTLIBRARIES = +check_PROGRAMS = +check_SCRIPTS = +check_DATA = + +# We support a fairly large range of possible variables. It is expected that all types of files in a test suite +# will belong in exactly one of the following variables. +# +# First, we support the usual automake suffixes, but in lowercase, with the customary meaning: +# +# test_programs, test_scripts, test_data, test_ltlibraries +# +# The above are used to list files that are involved in both uninstalled and installed testing. The +# test_programs and test_scripts are taken to be actual testcases and will be run as part of the test suite. +# Note that _data is always used with the nobase_ automake variable name to ensure that installed test data is +# installed in the same way as it appears in the package layout. +# +# In order to mark a particular file as being only for one type of testing, use 'installed' or 'uninstalled', +# like so: +# +# installed_test_programs, uninstalled_test_programs +# installed_test_scripts, uninstalled_test_scripts +# installed_test_data, uninstalled_test_data +# installed_test_ltlibraries, uninstalled_test_ltlibraries +# +# Additionally, we support 'extra' infixes for programs and scripts. This is used for support programs/scripts +# that should not themselves be run as testcases (but exist to be used from other testcases): +# +# test_extra_programs, installed_test_extra_programs, uninstalled_test_extra_programs +# test_extra_scripts, installed_test_extra_scripts, uninstalled_test_extra_scripts +# +# Additionally, for _scripts and _data, we support the customary dist_ prefix so that the named script or data +# file automatically end up in the tarball. +# +# dist_test_scripts, dist_test_data, dist_test_extra_scripts +# dist_installed_test_scripts, dist_installed_test_data, dist_installed_test_extra_scripts +# dist_uninstalled_test_scripts, dist_uninstalled_test_data, dist_uninstalled_test_extra_scripts +# +# Note that no file is automatically disted unless it appears in one of the dist_ variables. This follows the +# standard automake convention of not disting programs scripts or data by default. +# +# test_programs, test_scripts, uninstalled_test_programs and uninstalled_test_scripts (as well as their disted +# variants) will be run as part of the in-tree 'make check'. These are all assumed to be runnable under +# gtester. That's a bit strange for scripts, but it's possible. + +TESTS += $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \ + $(dist_test_scripts) $(dist_uninstalled_test_scripts) + +# Note: build even the installed-only targets during 'make check' to ensure that they still work. +# We need to do a bit of trickery here and manage disting via EXTRA_DIST instead of using dist_ prefixes to +# prevent automake from mistreating gmake functions like $(wildcard ...) and $(addprefix ...) as if they were +# filenames, including removing duplicate instances of the opening part before the space, eg. '$(addprefix'. +all_test_programs = $(test_programs) $(uninstalled_test_programs) $(installed_test_programs) \ + $(test_extra_programs) $(uninstalled_test_extra_programs) $(installed_test_extra_programs) +all_test_scripts = $(test_scripts) $(uninstalled_test_scripts) $(installed_test_scripts) \ + $(test_extra_scripts) $(uninstalled_test_extra_scripts) $(installed_test_extra_scripts) +all_dist_test_scripts = $(dist_test_scripts) $(dist_uninstalled_test_scripts) $(dist_installed_test_scripts) \ + $(dist_test_extra_scripts) $(dist_uninstalled_test_extra_scripts) $(dist_installed_test_extra_scripts) +all_test_scripts += $(all_dist_test_scripts) +EXTRA_DIST += $(all_dist_test_scripts) +all_test_data = $(test_data) $(uninstalled_test_data) $(installed_test_data) +all_dist_test_data = $(dist_test_data) $(dist_uninstalled_test_data) $(dist_installed_test_data) +all_test_data += $(all_dist_test_data) +EXTRA_DIST += $(all_dist_test_data) +all_test_ltlibs = $(test_ltlibraries) $(uninstalled_test_ltlibraries) $(installed_test_ltlibraries) + +if ENABLE_ALWAYS_BUILD_TESTS +noinst_LTLIBRARIES += $(all_test_ltlibs) +noinst_PROGRAMS += $(all_test_programs) +noinst_SCRIPTS += $(all_test_scripts) +noinst_DATA += $(all_test_data) +else +check_LTLIBRARIES += $(all_test_ltlibs) +check_PROGRAMS += $(all_test_programs) +check_SCRIPTS += $(all_test_scripts) +check_DATA += $(all_test_data) +endif + +if ENABLE_INSTALLED_TESTS +installed_test_PROGRAMS += $(test_programs) $(installed_test_programs) \ + $(test_extra_programs) $(installed_test_extra_programs) +installed_test_SCRIPTS += $(test_scripts) $(installed_test_scripts) \ + $(test_extra_scripts) $(test_installed_extra_scripts) +installed_test_SCRIPTS += $(dist_test_scripts) $(dist_test_extra_scripts) \ + $(dist_installed_test_scripts) $(dist_installed_test_extra_scripts) +nobase_installed_test_DATA += $(test_data) $(installed_test_data) +nobase_installed_test_DATA += $(dist_test_data) $(dist_installed_test_data) +installed_test_LTLIBRARIES += $(test_ltlibraries) $(installed_test_ltlibraries) +installed_testcases = $(test_programs) $(installed_test_programs) \ + $(test_scripts) $(installed_test_scripts) \ + $(dist_test_scripts) $(dist_installed_test_scripts) + +installed_test_meta_DATA = $(installed_testcases:=.test) + +%.test: %$(EXEEXT) Makefile + $(AM_V_GEN) (echo '[Test]' > $@.tmp; \ + echo 'Type=session' >> $@.tmp; \ + echo 'Exec=$(installed_testdir)/$<' >> $@.tmp; \ + mv $@.tmp $@) + +CLEANFILES += $(installed_test_meta_DATA) +endif diff --git a/build/autotools/glibtests.m4 b/build/autotools/glibtests.m4 new file mode 100644 index 000000000..7d5920a43 --- /dev/null +++ b/build/autotools/glibtests.m4 @@ -0,0 +1,28 @@ +dnl GLIB_TESTS +dnl + +AC_DEFUN([GLIB_TESTS], +[ + AC_ARG_ENABLE(installed-tests, + AS_HELP_STRING([--enable-installed-tests], + [Enable installation of some test cases]), + [case ${enableval} in + yes) ENABLE_INSTALLED_TESTS="1" ;; + no) ENABLE_INSTALLED_TESTS="" ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-installed-tests]) ;; + esac]) + AM_CONDITIONAL([ENABLE_INSTALLED_TESTS], test "$ENABLE_INSTALLED_TESTS" = "1") + AC_ARG_ENABLE(always-build-tests, + AS_HELP_STRING([--enable-always-build-tests], + [Enable always building tests during 'make all']), + [case ${enableval} in + yes) ENABLE_ALWAYS_BUILD_TESTS="1" ;; + no) ENABLE_ALWAYS_BUILD_TESTS="" ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-always-build-tests]) ;; + esac]) + AM_CONDITIONAL([ENABLE_ALWAYS_BUILD_TESTS], test "$ENABLE_ALWAYS_BUILD_TESTS" = "1") + if test "$ENABLE_INSTALLED_TESTS" = "1"; then + AC_SUBST(installed_test_metadir, [${datadir}/installed-tests/]AC_PACKAGE_NAME) + AC_SUBST(installed_testdir, [${libexecdir}/installed-tests/]AC_PACKAGE_NAME) + fi +]) diff --git a/build/autotools/tap-driver.sh b/build/autotools/tap-driver.sh new file mode 100755 index 000000000..19aa531de --- /dev/null +++ b/build/autotools/tap-driver.sh @@ -0,0 +1,652 @@ +#! /bin/sh +# Copyright (C) 2011-2013 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +scriptversion=2011-12-27.17; # UTC + +# Make unconditional expansion of undefined variables an error. This +# helps a lot in preventing typo-related bugs. +set -u + +me=tap-driver.sh + +fatal () +{ + echo "$me: fatal: $*" >&2 + exit 1 +} + +usage_error () +{ + echo "$me: $*" >&2 + print_usage >&2 + exit 2 +} + +print_usage () +{ + cat < + # + trap : 1 3 2 13 15 + if test $merge -gt 0; then + exec 2>&1 + else + exec 2>&3 + fi + "$@" + echo $? + ) | LC_ALL=C ${AM_TAP_AWK-awk} \ + -v me="$me" \ + -v test_script_name="$test_name" \ + -v log_file="$log_file" \ + -v trs_file="$trs_file" \ + -v expect_failure="$expect_failure" \ + -v merge="$merge" \ + -v ignore_exit="$ignore_exit" \ + -v comments="$comments" \ + -v diag_string="$diag_string" \ +' +# FIXME: the usages of "cat >&3" below could be optimized when using +# FIXME: GNU awk, and/on on systems that supports /dev/fd/. + +# Implementation note: in what follows, `result_obj` will be an +# associative array that (partly) simulates a TAP result object +# from the `TAP::Parser` perl module. + +## ----------- ## +## FUNCTIONS ## +## ----------- ## + +function fatal(msg) +{ + print me ": " msg | "cat >&2" + exit 1 +} + +function abort(where) +{ + fatal("internal error " where) +} + +# Convert a boolean to a "yes"/"no" string. +function yn(bool) +{ + return bool ? "yes" : "no"; +} + +function add_test_result(result) +{ + if (!test_results_index) + test_results_index = 0 + test_results_list[test_results_index] = result + test_results_index += 1 + test_results_seen[result] = 1; +} + +# Whether the test script should be re-run by "make recheck". +function must_recheck() +{ + for (k in test_results_seen) + if (k != "XFAIL" && k != "PASS" && k != "SKIP") + return 1 + return 0 +} + +# Whether the content of the log file associated to this test should +# be copied into the "global" test-suite.log. +function copy_in_global_log() +{ + for (k in test_results_seen) + if (k != "PASS") + return 1 + return 0 +} + +# FIXME: this can certainly be improved ... +function get_global_test_result() +{ + if ("ERROR" in test_results_seen) + return "ERROR" + if ("FAIL" in test_results_seen || "XPASS" in test_results_seen) + return "FAIL" + all_skipped = 1 + for (k in test_results_seen) + if (k != "SKIP") + all_skipped = 0 + if (all_skipped) + return "SKIP" + return "PASS"; +} + +function stringify_result_obj(result_obj) +{ + if (result_obj["is_unplanned"] || result_obj["number"] != testno) + return "ERROR" + + if (plan_seen == LATE_PLAN) + return "ERROR" + + if (result_obj["directive"] == "TODO") + return result_obj["is_ok"] ? "XPASS" : "XFAIL" + + if (result_obj["directive"] == "SKIP") + return result_obj["is_ok"] ? "SKIP" : COOKED_FAIL; + + if (length(result_obj["directive"])) + abort("in function stringify_result_obj()") + + return result_obj["is_ok"] ? COOKED_PASS : COOKED_FAIL +} + +function decorate_result(result) +{ + color_name = color_for_result[result] + if (color_name) + return color_map[color_name] "" result "" color_map["std"] + # If we are not using colorized output, or if we do not know how + # to colorize the given result, we should return it unchanged. + return result +} + +function report(result, details) +{ + if (result ~ /^(X?(PASS|FAIL)|SKIP|ERROR)/) + { + msg = ": " test_script_name + add_test_result(result) + } + else if (result == "#") + { + msg = " " test_script_name ":" + } + else + { + abort("in function report()") + } + if (length(details)) + msg = msg " " details + # Output on console might be colorized. + print decorate_result(result) msg + # Log the result in the log file too, to help debugging (this is + # especially true when said result is a TAP error or "Bail out!"). + print result msg | "cat >&3"; +} + +function testsuite_error(error_message) +{ + report("ERROR", "- " error_message) +} + +function handle_tap_result() +{ + details = result_obj["number"]; + if (length(result_obj["description"])) + details = details " " result_obj["description"] + + if (plan_seen == LATE_PLAN) + { + details = details " # AFTER LATE PLAN"; + } + else if (result_obj["is_unplanned"]) + { + details = details " # UNPLANNED"; + } + else if (result_obj["number"] != testno) + { + details = sprintf("%s # OUT-OF-ORDER (expecting %d)", + details, testno); + } + else if (result_obj["directive"]) + { + details = details " # " result_obj["directive"]; + if (length(result_obj["explanation"])) + details = details " " result_obj["explanation"] + } + + report(stringify_result_obj(result_obj), details) +} + +# `skip_reason` should be empty whenever planned > 0. +function handle_tap_plan(planned, skip_reason) +{ + planned += 0 # Avoid getting confused if, say, `planned` is "00" + if (length(skip_reason) && planned > 0) + abort("in function handle_tap_plan()") + if (plan_seen) + { + # Error, only one plan per stream is acceptable. + testsuite_error("multiple test plans") + return; + } + planned_tests = planned + # The TAP plan can come before or after *all* the TAP results; we speak + # respectively of an "early" or a "late" plan. If we see the plan line + # after at least one TAP result has been seen, assume we have a late + # plan; in this case, any further test result seen after the plan will + # be flagged as an error. + plan_seen = (testno >= 1 ? LATE_PLAN : EARLY_PLAN) + # If testno > 0, we have an error ("too many tests run") that will be + # automatically dealt with later, so do not worry about it here. If + # $plan_seen is true, we have an error due to a repeated plan, and that + # has already been dealt with above. Otherwise, we have a valid "plan + # with SKIP" specification, and should report it as a particular kind + # of SKIP result. + if (planned == 0 && testno == 0) + { + if (length(skip_reason)) + skip_reason = "- " skip_reason; + report("SKIP", skip_reason); + } +} + +function extract_tap_comment(line) +{ + if (index(line, diag_string) == 1) + { + # Strip leading `diag_string` from `line`. + line = substr(line, length(diag_string) + 1) + # And strip any leading and trailing whitespace left. + sub("^[ \t]*", "", line) + sub("[ \t]*$", "", line) + # Return what is left (if any). + return line; + } + return ""; +} + +# When this function is called, we know that line is a TAP result line, +# so that it matches the (perl) RE "^(not )?ok\b". +function setup_result_obj(line) +{ + # Get the result, and remove it from the line. + result_obj["is_ok"] = (substr(line, 1, 2) == "ok" ? 1 : 0) + sub("^(not )?ok[ \t]*", "", line) + + # If the result has an explicit number, get it and strip it; otherwise, + # automatically assing the next progresive number to it. + if (line ~ /^[0-9]+$/ || line ~ /^[0-9]+[^a-zA-Z0-9_]/) + { + match(line, "^[0-9]+") + # The final `+ 0` is to normalize numbers with leading zeros. + result_obj["number"] = substr(line, 1, RLENGTH) + 0 + line = substr(line, RLENGTH + 1) + } + else + { + result_obj["number"] = testno + } + + if (plan_seen == LATE_PLAN) + # No further test results are acceptable after a "late" TAP plan + # has been seen. + result_obj["is_unplanned"] = 1 + else if (plan_seen && testno > planned_tests) + result_obj["is_unplanned"] = 1 + else + result_obj["is_unplanned"] = 0 + + # Strip trailing and leading whitespace. + sub("^[ \t]*", "", line) + sub("[ \t]*$", "", line) + + # This will have to be corrected if we have a "TODO"/"SKIP" directive. + result_obj["description"] = line + result_obj["directive"] = "" + result_obj["explanation"] = "" + + if (index(line, "#") == 0) + return # No possible directive, nothing more to do. + + # Directives are case-insensitive. + rx = "[ \t]*#[ \t]*([tT][oO][dD][oO]|[sS][kK][iI][pP])[ \t]*" + + # See whether we have the directive, and if yes, where. + pos = match(line, rx "$") + if (!pos) + pos = match(line, rx "[^a-zA-Z0-9_]") + + # If there was no TAP directive, we have nothing more to do. + if (!pos) + return + + # Let`s now see if the TAP directive has been escaped. For example: + # escaped: ok \# SKIP + # not escaped: ok \\# SKIP + # escaped: ok \\\\\# SKIP + # not escaped: ok \ # SKIP + if (substr(line, pos, 1) == "#") + { + bslash_count = 0 + for (i = pos; i > 1 && substr(line, i - 1, 1) == "\\"; i--) + bslash_count += 1 + if (bslash_count % 2) + return # Directive was escaped. + } + + # Strip the directive and its explanation (if any) from the test + # description. + result_obj["description"] = substr(line, 1, pos - 1) + # Now remove the test description from the line, that has been dealt + # with already. + line = substr(line, pos) + # Strip the directive, and save its value (normalized to upper case). + sub("^[ \t]*#[ \t]*", "", line) + result_obj["directive"] = toupper(substr(line, 1, 4)) + line = substr(line, 5) + # Now get the explanation for the directive (if any), with leading + # and trailing whitespace removed. + sub("^[ \t]*", "", line) + sub("[ \t]*$", "", line) + result_obj["explanation"] = line +} + +function get_test_exit_message(status) +{ + if (status == 0) + return "" + if (status !~ /^[1-9][0-9]*$/) + abort("getting exit status") + if (status < 127) + exit_details = "" + else if (status == 127) + exit_details = " (command not found?)" + else if (status >= 128 && status <= 255) + exit_details = sprintf(" (terminated by signal %d?)", status - 128) + else if (status > 256 && status <= 384) + # We used to report an "abnormal termination" here, but some Korn + # shells, when a child process die due to signal number n, can leave + # in $? an exit status of 256+n instead of the more standard 128+n. + # Apparently, both behaviours are allowed by POSIX (2008), so be + # prepared to handle them both. See also Austing Group report ID + # 0000051 + exit_details = sprintf(" (terminated by signal %d?)", status - 256) + else + # Never seen in practice. + exit_details = " (abnormal termination)" + return sprintf("exited with status %d%s", status, exit_details) +} + +function write_test_results() +{ + print ":global-test-result: " get_global_test_result() > trs_file + print ":recheck: " yn(must_recheck()) > trs_file + print ":copy-in-global-log: " yn(copy_in_global_log()) > trs_file + for (i = 0; i < test_results_index; i += 1) + print ":test-result: " test_results_list[i] > trs_file + close(trs_file); +} + +BEGIN { + +## ------- ## +## SETUP ## +## ------- ## + +'"$init_colors"' + +# Properly initialized once the TAP plan is seen. +planned_tests = 0 + +COOKED_PASS = expect_failure ? "XPASS": "PASS"; +COOKED_FAIL = expect_failure ? "XFAIL": "FAIL"; + +# Enumeration-like constants to remember which kind of plan (if any) +# has been seen. It is important that NO_PLAN evaluates "false" as +# a boolean. +NO_PLAN = 0 +EARLY_PLAN = 1 +LATE_PLAN = 2 + +testno = 0 # Number of test results seen so far. +bailed_out = 0 # Whether a "Bail out!" directive has been seen. + +# Whether the TAP plan has been seen or not, and if yes, which kind +# it is ("early" is seen before any test result, "late" otherwise). +plan_seen = NO_PLAN + +## --------- ## +## PARSING ## +## --------- ## + +is_first_read = 1 + +while (1) + { + # Involutions required so that we are able to read the exit status + # from the last input line. + st = getline + if (st < 0) # I/O error. + fatal("I/O error while reading from input stream") + else if (st == 0) # End-of-input + { + if (is_first_read) + abort("in input loop: only one input line") + break + } + if (is_first_read) + { + is_first_read = 0 + nextline = $0 + continue + } + else + { + curline = nextline + nextline = $0 + $0 = curline + } + # Copy any input line verbatim into the log file. + print | "cat >&3" + # Parsing of TAP input should stop after a "Bail out!" directive. + if (bailed_out) + continue + + # TAP test result. + if ($0 ~ /^(not )?ok$/ || $0 ~ /^(not )?ok[^a-zA-Z0-9_]/) + { + testno += 1 + setup_result_obj($0) + handle_tap_result() + } + # TAP plan (normal or "SKIP" without explanation). + else if ($0 ~ /^1\.\.[0-9]+[ \t]*$/) + { + # The next two lines will put the number of planned tests in $0. + sub("^1\\.\\.", "") + sub("[^0-9]*$", "") + handle_tap_plan($0, "") + continue + } + # TAP "SKIP" plan, with an explanation. + else if ($0 ~ /^1\.\.0+[ \t]*#/) + { + # The next lines will put the skip explanation in $0, stripping + # any leading and trailing whitespace. This is a little more + # tricky in truth, since we want to also strip a potential leading + # "SKIP" string from the message. + sub("^[^#]*#[ \t]*(SKIP[: \t][ \t]*)?", "") + sub("[ \t]*$", ""); + handle_tap_plan(0, $0) + } + # "Bail out!" magic. + # Older versions of prove and TAP::Harness (e.g., 3.17) did not + # recognize a "Bail out!" directive when preceded by leading + # whitespace, but more modern versions (e.g., 3.23) do. So we + # emulate the latter, "more modern" behaviour. + else if ($0 ~ /^[ \t]*Bail out!/) + { + bailed_out = 1 + # Get the bailout message (if any), with leading and trailing + # whitespace stripped. The message remains stored in `$0`. + sub("^[ \t]*Bail out![ \t]*", ""); + sub("[ \t]*$", ""); + # Format the error message for the + bailout_message = "Bail out!" + if (length($0)) + bailout_message = bailout_message " " $0 + testsuite_error(bailout_message) + } + # Maybe we have too look for dianogtic comments too. + else if (comments != 0) + { + comment = extract_tap_comment($0); + if (length(comment)) + report("#", comment); + } + } + +## -------- ## +## FINISH ## +## -------- ## + +# A "Bail out!" directive should cause us to ignore any following TAP +# error, as well as a non-zero exit status from the TAP producer. +if (!bailed_out) + { + if (!plan_seen) + { + testsuite_error("missing test plan") + } + else if (planned_tests != testno) + { + bad_amount = testno > planned_tests ? "many" : "few" + testsuite_error(sprintf("too %s tests run (expected %d, got %d)", + bad_amount, planned_tests, testno)) + } + if (!ignore_exit) + { + # Fetch exit status from the last line. + exit_message = get_test_exit_message(nextline) + if (exit_message) + testsuite_error(exit_message) + } + } + +write_test_results() + +exit 0 + +} # End of "BEGIN" block. +' + +# TODO: document that we consume the file descriptor 3 :-( +} 3>"$log_file" + +test $? -eq 0 || fatal "I/O or internal error" + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/build/autotools/tap-test b/build/autotools/tap-test new file mode 100755 index 000000000..481e333ec --- /dev/null +++ b/build/autotools/tap-test @@ -0,0 +1,5 @@ +#! /bin/sh + +# run a GTest in tap mode. The test binary is passed as $1 + +$1 -k --tap diff --git a/clutter/Makefile.am b/clutter/Makefile.am index 21ea818a1..09f5fc6e5 100644 --- a/clutter/Makefile.am +++ b/clutter/Makefile.am @@ -116,6 +116,7 @@ source_h = \ $(srcdir)/clutter-stage.h \ $(srcdir)/clutter-stage-manager.h \ $(srcdir)/clutter-tap-action.h \ + $(srcdir)/clutter-test-utils.h \ $(srcdir)/clutter-texture.h \ $(srcdir)/clutter-text.h \ $(srcdir)/clutter-text-buffer.h \ @@ -199,6 +200,7 @@ source_c = \ $(srcdir)/clutter-stage-manager.c \ $(srcdir)/clutter-stage-window.c \ $(srcdir)/clutter-tap-action.c \ + $(srcdir)/clutter-test-utils.c \ $(srcdir)/clutter-text.c \ $(srcdir)/clutter-text-buffer.c \ $(srcdir)/clutter-transition-group.c \ diff --git a/clutter/clutter-test-utils.c b/clutter/clutter-test-utils.c new file mode 100644 index 000000000..65df093b5 --- /dev/null +++ b/clutter/clutter-test-utils.c @@ -0,0 +1,422 @@ +#include "config.h" + +#include "clutter-test-utils.h" + +#include +#include + +#include "clutter-actor.h" +#include "clutter-color.h" +#include "clutter-event.h" +#include "clutter-keysyms.h" +#include "clutter-main.h" +#include "clutter-stage.h" + +typedef struct { + ClutterActor *stage; +} ClutterTestEnvironment; + +static ClutterTestEnvironment *environ = NULL; + +/** + * clutter_test_init: + * @argc: + * @argv: + * + * Initializes the Clutter test environment. + * + * Since: 1.18 + */ +void +clutter_test_init (int *argc, + char ***argv) +{ + if (G_UNLIKELY (environ != NULL)) + g_error ("Attempting to initialize the test suite more than once, " + "aborting...\n"); + +#ifdef CLUTTER_WINDOWING_X11 + /* on X11 backends we need the DISPLAY environment set. + * + * check_windowing_backend() will pre-initialize the Clutter + * backend object. + */ + if (clutter_check_windowing_backend (CLUTTER_WINDOWING_X11)) + { + const char *display = g_getenv ("DISPLAY"); + + if (display == NULL || *display == '\0') + { + g_print ("No DISPLAY environment variable found, but we require a " + "DISPLAY set in order to run the conformance test suite."); + exit (0); + } + } +#endif + + /* by explicitly setting CLUTTER_VBLANK to "none" we disable the + * synchronisation, and run the master clock using a 60 fps timer + * instead. + */ + g_setenv ("CLUTTER_VBLANK", "none", FALSE); + + g_test_init (argc, argv, NULL); + g_test_bug_base ("https://bugzilla.gnome.org/show_bug.cgi?id=%s"); + + /* perform the actual initialization */ + g_assert (clutter_init (NULL, NULL) == CLUTTER_INIT_SUCCESS); + + /* our global state, accessible from each test unit */ + environ = g_new0 (ClutterTestEnvironment, 1); +} + +/** + * clutter_test_get_stage: + * + * Retrieves the #ClutterStage used for testing. + * + * Return value: (transfer none): the stage used for testing + * + * Since: 1.18 + */ +ClutterActor * +clutter_test_get_stage (void) +{ + g_assert (environ != NULL); + + if (environ->stage == NULL) + { + /* create a stage, and ensure that it goes away at the end */ + environ->stage = clutter_stage_new (); + clutter_actor_set_name (environ->stage, "Test Stage"); + g_object_add_weak_pointer (G_OBJECT (environ->stage), + (gpointer *) &environ->stage); + } + + return environ->stage; +} + +typedef struct { + gpointer test_func; + gpointer test_data; + GDestroyNotify test_notify; +} ClutterTestData; + +static void +clutter_test_func_wrapper (gconstpointer data_) +{ + const ClutterTestData *data = data_; + + /* ensure that the previous test state has been cleaned up */ + g_assert_null (environ->stage); + + if (data->test_data != NULL) + { + GTestDataFunc test_func = data->test_func; + + test_func (data->test_data); + } + else + { + GTestFunc test_func = data->test_func; + + test_func (); + } + + if (data->test_notify != NULL) + data->test_notify (data->test_data); + + if (environ->stage != NULL) + { + clutter_actor_destroy (environ->stage); + g_assert_null (environ->stage); + } +} + +/** + * clutter_test_add: (skip) + * @test_path: + * @test_func: + * + * Adds a test unit to the Clutter test environment. + * + * See also: g_test_add() + * + * Since: 1.18 + */ +void +clutter_test_add (const char *test_path, + GTestFunc test_func) +{ + clutter_test_add_data_full (test_path, (GTestDataFunc) test_func, NULL, NULL); +} + +/** + * clutter_test_add_data: (skip) + * @test_path: + * @test_func: + * @test_data: + * + * Adds a test unit to the Clutter test environment. + * + * See also: g_test_add_data_func() + * + * Since: 1.18 + */ +void +clutter_test_add_data (const char *test_path, + GTestDataFunc test_func, + gpointer test_data) +{ + clutter_test_add_data_full (test_path, test_func, test_data, NULL); +} + +/** + * clutter_test_add_data_full: + * @test_path: + * @test_func: (scope notified) + * @test_data: + * @test_notify: + * + * Adds a test unit to the Clutter test environment. + * + * See also: g_test_add_data_func_full() + * + * Since: 1.18 + */ +void +clutter_test_add_data_full (const char *test_path, + GTestDataFunc test_func, + gpointer test_data, + GDestroyNotify test_notify) +{ + ClutterTestData *data; + + g_return_if_fail (test_path != NULL); + g_return_if_fail (test_func != NULL); + + g_assert (environ != NULL); + + data = g_new (ClutterTestData, 1); + data->test_func = test_func; + data->test_data = test_data; + data->test_notify = test_notify; + + g_test_add_data_func_full (test_path, data, + clutter_test_func_wrapper, + g_free); +} + +/** + * clutter_test_run: + * + * Runs the test suite using the units added by calling + * clutter_test_add(). + * + * The typical test suite is composed of a list of functions + * called by clutter_test_run(), for instance: + * + * |[ + * static void unit_foo (void) { ... } + * + * static void unit_bar (void) { ... } + * + * static void unit_baz (void) { ... } + * + * int + * main (int argc, char *argv[]) + * { + * clutter_test_init (&argc, &argv); + * + * clutter_test_add ("/unit/foo", unit_foo); + * clutter_test_add ("/unit/bar", unit_bar); + * clutter_test_add ("/unit/baz", unit_baz); + * + * return clutter_test_run (); + * } + * ]| + * + * Return value: the exit code for the test suite + * + * Since: 1.18 + */ +int +clutter_test_run (void) +{ + int res; + + g_assert (environ != NULL); + + res = g_test_run (); + + g_free (environ); + + return res; +} + +typedef struct { + ClutterActor *stage; + + ClutterPoint point; + + gpointer result; + + guint check_actor : 1; + guint check_color : 1; + + guint was_painted : 1; +} ValidateData; + +static gboolean +validate_stage (gpointer data_) +{ + ValidateData *data = data_; + + if (data->check_actor) + { + data->result = + clutter_stage_get_actor_at_pos (CLUTTER_STAGE (data->stage), + CLUTTER_PICK_ALL, + data->point.x, + data->point.y); + } + + if (data->check_color) + { + data->result = + clutter_stage_read_pixels (CLUTTER_STAGE (data->stage), + data->point.x, + data->point.y, + 1, 1); + } + + if (!g_test_verbose ()) + { + clutter_actor_hide (data->stage); + data->was_painted = TRUE; + } + + return G_SOURCE_REMOVE; +} + +static gboolean +on_key_press_event (ClutterActor *stage, + ClutterEvent *event, + gpointer data_) +{ + ValidateData *data = data_; + + if (data->stage == stage && + clutter_event_get_key_symbol (event) == CLUTTER_KEY_Escape) + { + clutter_actor_hide (stage); + + data->was_painted = TRUE; + } + + return CLUTTER_EVENT_PROPAGATE; +} + +gboolean +clutter_test_check_actor_at_point (ClutterActor *stage, + const ClutterPoint *point, + ClutterActor *actor, + ClutterActor **result) +{ + ValidateData *data; + guint press_id = 0; + + g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE); + g_return_val_if_fail (point != NULL, FALSE); + g_return_val_if_fail (CLUTTER_IS_ACTOR (stage), FALSE); + g_return_val_if_fail (result != NULL, FALSE); + + data = g_new0 (ValidateData, 1); + data->stage = stage; + data->point = *point; + data->check_actor = TRUE; + + if (g_test_verbose ()) + { + g_printerr ("Press ESC to close the stage and resume the test\n"); + press_id = g_signal_connect (stage, "key-press-event", + G_CALLBACK (on_key_press_event), + data); + } + + clutter_actor_show (stage); + + clutter_threads_add_repaint_func_full (CLUTTER_REPAINT_FLAGS_POST_PAINT, + validate_stage, + data, + NULL); + + while (!data->was_painted) + g_main_context_iteration (NULL, TRUE); + + *result = data->result; + + if (press_id != 0) + g_signal_handler_disconnect (stage, press_id); + + g_free (data); + + return *result == actor; +} + +gboolean +clutter_test_check_color_at_point (ClutterActor *stage, + const ClutterPoint *point, + const ClutterColor *color, + ClutterColor *result) +{ + ValidateData *data; + gboolean retval; + guint8 *buffer; + guint press_id = 0; + + g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE); + g_return_val_if_fail (point != NULL, FALSE); + g_return_val_if_fail (color != NULL, FALSE); + g_return_val_if_fail (result != NULL, FALSE); + + data = g_new0 (ValidateData, 1); + data->stage = stage; + data->point = *point; + data->check_color = TRUE; + + if (g_test_verbose ()) + { + g_printerr ("Press ESC to close the stage and resume the test\n"); + press_id = g_signal_connect (stage, "key-press-event", + G_CALLBACK (on_key_press_event), + data); + } + + clutter_actor_show (stage); + + clutter_threads_add_repaint_func_full (CLUTTER_REPAINT_FLAGS_POST_PAINT, + validate_stage, + data, + NULL); + + while (!data->was_painted) + g_main_context_iteration (NULL, TRUE); + + if (press_id != 0) + g_signal_handler_disconnect (stage, press_id); + + buffer = data->result; + + clutter_color_init (result, buffer[0], buffer[1], buffer[2], 255); + + /* we only check the color channels, so we can't use clutter_color_equal() */ + retval = buffer[0] == color->red && + buffer[1] == color->green && + buffer[2] == color->blue; + + g_free (data->result); + g_free (data); + + return retval; +} diff --git a/clutter/clutter-test-utils.h b/clutter/clutter-test-utils.h new file mode 100644 index 000000000..d88727deb --- /dev/null +++ b/clutter/clutter-test-utils.h @@ -0,0 +1,164 @@ +/* + * Clutter. + * + * An OpenGL based 'interactive canvas' library. + * + * Copyright (C) 2013 Emmanuele Bassi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + +#ifndef __CLUTTER_TEST_UTILS_H__ +#define __CLUTTER_TEST_UTILS_H__ + +#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include + +G_BEGIN_DECLS + +/** + * CLUTTER_TEST_UNIT: + * @path: the GTest path for the test function + * @func: the GTestFunc function + * + * Adds @func at the given @path in the test suite. + * + * Since: 1.18 + */ +#define CLUTTER_TEST_UNIT(path,func) \ + clutter_test_add (path, func); + +/** + * CLUTTER_TEST_SUITE: + * @units: a list of %CLUTTER_TEST_UNIT definitions + * + * Defines the entry point and initializes a Clutter test unit, e.g.: + * + * |[ + * CLUTTER_TEST_SUITE ( + * CLUTTER_TEST_UNIT ("/foobarize", foobarize) + * CLUTTER_TEST_UNIT ("/bar-enabled", bar_enabled) + * ) + * ]| + * + * Expands to: + * + * |[ + * int + * main (int argc, + * char *argv[]) + * { + * clutter_test_init (&argc, &argv); + * + * clutter_test_add ("/foobarize", foobarize); + * clutter_test_add ("/bar-enabled", bar_enabled); + * + * return clutter_test_run (); + * } + * ]| + * + * Since: 1.18 + */ +#define CLUTTER_TEST_SUITE(units) \ +int \ +main (int argc, char *argv[]) \ +{ \ + clutter_test_init (&argc, &argv); \ +\ + { \ + units \ + } \ +\ + return clutter_test_run (); \ +} + +CLUTTER_AVAILABLE_IN_1_18 +void clutter_test_init (int *argc, + char ***argv); +CLUTTER_AVAILABLE_IN_1_18 +int clutter_test_run (void); + +CLUTTER_AVAILABLE_IN_1_18 +void clutter_test_add (const char *test_path, + GTestFunc test_func); +CLUTTER_AVAILABLE_IN_1_18 +void clutter_test_add_data (const char *test_path, + GTestDataFunc test_func, + gpointer test_data); +CLUTTER_AVAILABLE_IN_1_18 +void clutter_test_add_data_full (const char *test_path, + GTestDataFunc test_func, + gpointer test_data, + GDestroyNotify test_notify); + +CLUTTER_AVAILABLE_IN_1_18 +ClutterActor * clutter_test_get_stage (void); + +#define clutter_test_assert_actor_at_point(stage,point,actor) \ +G_STMT_START { \ + const ClutterPoint *__p = (point); \ + ClutterActor *__actor = (actor); \ + ClutterActor *__stage = (stage); \ + ClutterActor *__res; \ + if (clutter_test_check_actor_at_point (__stage, __p, actor, &__res)) ; else { \ + const char *__str1 = clutter_actor_get_name (__actor) != NULL \ + ? clutter_actor_get_name (__actor) \ + : G_OBJECT_TYPE_NAME (__actor); \ + const char *__str2 = clutter_actor_get_name (__res) != NULL \ + ? clutter_actor_get_name (__res) \ + : G_OBJECT_TYPE_NAME (__res); \ + char *__msg = g_strdup_printf ("assertion failed (actor %s at %.2f,%.2f): found actor %s", \ + __str1, __p->x, __p->y, __str2); \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, __msg); \ + g_free (__msg); \ + } \ +} G_STMT_END + +#define clutter_test_assert_color_at_point(stage,point,color) \ +G_STMT_START { \ + const ClutterPoint *__p = (point); \ + const ClutterColor *__c = (color); \ + ClutterActor *__stage = (stage); \ + ClutterColor __res; \ + if (clutter_test_check_color_at_point (__stage, __p, __c, &__res)) ; else { \ + char *__str1 = clutter_color_to_string (__c); \ + char *__str2 = clutter_color_to_string (&__res); \ + char *__msg = g_strdup_printf ("assertion failed (color %s at %.2f,%.2f): found color %s", \ + __str1, __p->x, __p->y, __str2); \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, __msg); \ + g_free (__msg); \ + g_free (__str1); \ + g_free (__str2); \ + } \ +} G_STMT_END + +CLUTTER_AVAILABLE_IN_1_18 +gboolean clutter_test_check_actor_at_point (ClutterActor *stage, + const ClutterPoint *point, + ClutterActor *actor, + ClutterActor **result); +CLUTTER_AVAILABLE_IN_1_18 +gboolean clutter_test_check_color_at_point (ClutterActor *stage, + const ClutterPoint *point, + const ClutterColor *color, + ClutterColor *result); + +G_END_DECLS + +#endif /* __CLUTTER_TEST_UTILS_H__ */ diff --git a/clutter/clutter.h b/clutter/clutter.h index 0300099af..4a612b732 100644 --- a/clutter/clutter.h +++ b/clutter/clutter.h @@ -99,6 +99,7 @@ #include "clutter-stage.h" #include "clutter-stage-manager.h" #include "clutter-tap-action.h" +#include "clutter-test-utils.h" #include "clutter-texture.h" #include "clutter-text.h" #include "clutter-timeline.h" diff --git a/clutter/clutter.symbols b/clutter/clutter.symbols index 0c54a7b07..d34c94e29 100644 --- a/clutter/clutter.symbols +++ b/clutter/clutter.symbols @@ -1364,6 +1364,14 @@ clutter_table_layout_set_span clutter_table_layout_set_use_animations clutter_tap_action_get_type clutter_tap_action_new +clutter_test_add +clutter_test_add_data +clutter_test_add_data_full +clutter_test_check_actor_at_point +clutter_test_check_color_at_point +clutter_test_get_stage +clutter_test_init +clutter_test_run clutter_texture_get_base_size clutter_texture_get_cogl_texture clutter_texture_get_cogl_material diff --git a/configure.ac b/configure.ac index fe06bb57b..274fbf870 100644 --- a/configure.ac +++ b/configure.ac @@ -191,12 +191,6 @@ AC_ARG_ENABLE([Bsymbolic], AS_IF([test "x$enable_Bsymbolic" = "xyes"], [CLUTTER_LINK_FLAGS=-Wl[,]-Bsymbolic-functions]) AC_SUBST(CLUTTER_LINK_FLAGS) -AC_ARG_ENABLE(installed_tests, - AS_HELP_STRING([--enable-installed-tests], - [Install test programs (default: no)]),, - [enable_installed_tests=no]) -AM_CONDITIONAL(ENABLE_INSTALLED_TESTS, test x$enable_installed_tests = xyes) - AC_CACHE_SAVE dnl ======================================================================== @@ -1125,16 +1119,7 @@ dnl = Build optionals ========================================================= dnl === Conformance test suite ================================================ -AC_ARG_ENABLE([conformance], - [AS_HELP_STRING([--disable-conformance], [Whether the conformance tests should be built])], - [], - [enable_conformance=yes]) - -AC_ARG_ENABLE([tests], - [AS_HELP_STRING([--disable-tests], [Whether tests should be built])], - [], - [enable_tests=yes]) -AM_CONDITIONAL(BUILD_TESTS, [test "x$enable_tests" = "xyes" && test "x$enable_conformance" = "xyes"]) +GLIB_TESTS AC_ARG_ENABLE([examples], [AS_HELP_STRING([--disable-examples], [Whether examples should be built])], @@ -1168,8 +1153,6 @@ AC_CONFIG_FILES([ tests/Makefile tests/accessibility/Makefile tests/conform/Makefile - tests/conform/test-launcher.sh - tests/data/Makefile tests/interactive/Makefile tests/interactive/wrapper.sh tests/micro-bench/Makefile @@ -1224,9 +1207,10 @@ echo " Build Additional Documentation: ${enable_docs} (Generate PDF: ${en echo "" echo " • Extra:" echo " Build introspection data: ${enable_introspection}" -echo " Build test suites: ${enable_tests}" -if test "x$enable_tests" = "xyes"; then +if test "x$x11_tests" = "xyes"; then echo " Build X11-specific tests: ${x11_tests}" +fi +if test "x$pixbuf_tests" = "xyes"; then echo " Build tests using GDK-Pixbuf: ${pixbuf_tests}" fi echo " Install test suites: ${enable_installed_tests}" diff --git a/examples/Makefile.am b/examples/Makefile.am index 4b9b4492e..cb80c9ff3 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -31,7 +31,6 @@ LDADD = \ AM_CFLAGS = $(CLUTTER_CFLAGS) $(GDK_PIXBUF_CFLAGS) $(MAINTAINER_CFLAGS) AM_CPPFLAGS = \ - -DTESTS_DATADIR=\""$(abs_top_srcdir)/tests/data"\" \ -DG_DISABLE_SINGLE_INCLUDES \ -DGLIB_DISABLE_DEPRECATION_WARNINGS \ -I$(top_srcdir) \ @@ -41,4 +40,6 @@ AM_CPPFLAGS = \ noinst_PROGRAMS = $(all_examples) +EXTRA_DIST = redhand.png + -include $(top_srcdir)/build/autotools/Makefile.am.gitignore diff --git a/examples/bin-layout.c b/examples/bin-layout.c index 7dc9b967d..b6098d6fe 100644 --- a/examples/bin-layout.c +++ b/examples/bin-layout.c @@ -222,7 +222,7 @@ main (int argc, char *argv[]) canvas); /* we use GdkPixbuf to load an image from our data directory */ - pixbuf = gdk_pixbuf_new_from_file (TESTS_DATADIR G_DIR_SEPARATOR_S "redhand.png", NULL); + pixbuf = gdk_pixbuf_new_from_file ("redhand.png", NULL); image = clutter_image_new (); clutter_image_set_data (CLUTTER_IMAGE (image), gdk_pixbuf_get_pixels (pixbuf), diff --git a/examples/image-content.c b/examples/image-content.c index 62324508f..c9c01c6ec 100644 --- a/examples/image-content.c +++ b/examples/image-content.c @@ -69,7 +69,7 @@ main (int argc, char *argv[]) clutter_actor_set_margin_left (stage, 12); clutter_actor_show (stage); - pixbuf = gdk_pixbuf_new_from_file (TESTS_DATADIR G_DIR_SEPARATOR_S "redhand.png", NULL); + pixbuf = gdk_pixbuf_new_from_file ("redhand.png", NULL); image = clutter_image_new (); clutter_image_set_data (CLUTTER_IMAGE (image), gdk_pixbuf_get_pixels (pixbuf), diff --git a/examples/pan-action.c b/examples/pan-action.c index 71dcb24ae..e8733056b 100644 --- a/examples/pan-action.c +++ b/examples/pan-action.c @@ -15,7 +15,7 @@ create_content_actor (void) content = clutter_actor_new (); clutter_actor_set_size (content, 720, 720); - pixbuf = gdk_pixbuf_new_from_file (TESTS_DATADIR G_DIR_SEPARATOR_S "redhand.png", NULL); + pixbuf = gdk_pixbuf_new_from_file ("redhand.png", NULL); image = clutter_image_new (); clutter_image_set_data (CLUTTER_IMAGE (image), gdk_pixbuf_get_pixels (pixbuf), diff --git a/tests/data/redhand.png b/examples/redhand.png similarity index 100% rename from tests/data/redhand.png rename to examples/redhand.png diff --git a/tests/Makefile.am b/tests/Makefile.am index 8526b39fe..65b474a49 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,3 +1,3 @@ -SUBDIRS = accessibility data conform interactive micro-bench performance +SUBDIRS = accessibility conform interactive micro-bench performance -EXTRA_DIST = README +EXTRA_DIST = README clutter-1.0.suppressions diff --git a/tests/data/clutter-1.0.suppressions b/tests/clutter-1.0.suppressions similarity index 100% rename from tests/data/clutter-1.0.suppressions rename to tests/clutter-1.0.suppressions diff --git a/tests/conform/ADDING_NEW_TESTS b/tests/conform/ADDING_NEW_TESTS deleted file mode 100644 index 4a5a5dc5f..000000000 --- a/tests/conform/ADDING_NEW_TESTS +++ /dev/null @@ -1,65 +0,0 @@ -How to add new units to the Clutter Conformance test suite -------------------------------------------------------------------------------- - -If the new unit is not logically part of an existing file, you should create a -new source file and add it to the build. The built files are listed in the -Makefile.am template. Please, respect the sections already available there. - -When creating a new file, you should include "test-conform-common.h", as well -as and . - -Each new test unit should be contained in a function named following this -pattern: - - void -
_ (void) - { - } - -For instance: - - void - actor_allocation_changes (void) - { - /* test allocation changes */ - } - - void - rectangle_border (void) - { - /* test ClutterRectangle's border property */ - } - -After adding the test unit, edit test-conform-main.c and add the unit to the -list of tests, by using one of these three macros: - - • TEST_CONFORM_SIMPLE (path, function_name); - - @path is the unit path in the suite, and it's used to generate the - executable wrapper for running the unit as a stand-alone binary - and for the HTML report. - @function_name is the name of the function containing the newly added - test unit. - - This is the simple form of test unit, and it will always be run. - - • TEST_CONFORM_SKIP (condition, path, function_name); - - @condition is used to decide whether to run the unit or not. - - This macro will check @condition on start, and if it evaluates to TRUE - then the @function_name will be called and the unit executed; otherwise - the test will automatically succeed. - - • TEST_CONFORM_TODO (path, function_name); - - This macro will execute @function_name and will succeed if the unit - fails. This macro should be used for tests that are known to fail. - -Notes: - - • Do not call clutter_init() in your units; initialization is handled - by the conformance test suite itself. - - • All units are invoked in a new process, to prevent clobbering the - state. diff --git a/tests/conform/Makefile.am b/tests/conform/Makefile.am index 90f1f35b1..d0497d196 100644 --- a/tests/conform/Makefile.am +++ b/tests/conform/Makefile.am @@ -1,314 +1,43 @@ -include $(top_srcdir)/build/autotools/Makefile.am.silent +include $(top_srcdir)/build/autotools/glib-tap.mk -NULL = +AM_CFLAGS = -g $(CLUTTER_CFLAGS) $(MAINTAINER_CFLAGS) +LDADD = $(top_builddir)/clutter/libclutter-1.0.la $(CLUTTER_LIBS) -lm +AM_LDFLAGS = -export-dynamic +AM_CPPFLAGS = \ + -DG_LOG_DOMAIN=\"Clutter-Conform\" \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + -DCOGL_DISABLE_DEPRECATION_WARNINGS \ + $(CLUTTER_DEPRECATED_CFLAGS) \ + $(CLUTTER_DEBUG_CFLAGS) \ + $(CLUTTER_PROFILE_CFLAGS) -BUILT_SOURCES = - -TESTS = -check_PROGRAMS = -check_SCRIPTS = - -EXTRA_DIST = -DISTCLEANFILES = - -TEST_PROGS = - -# the common sources -common_sources = \ - test-conform-common.h \ - test-conform-common.c \ - test-conform-main.c \ +actor_tests = \ $(NULL) -# the unit-specific sources; please: keep all sections in alphabetical order! -units_sources = - -# animation tests -units_sources += \ - animator.c \ - behaviours.c \ - score.c \ - state.c \ - timeline.c \ - timeline-interpolate.c \ - timeline-progress.c \ - timeline-rewind.c \ +general_tests = \ $(NULL) -# actors tests -units_sources += \ - actor-anchors.c \ - actor-graph.c \ - actor-destroy.c \ - actor-invariants.c \ - actor-iter.c \ - actor-layout.c \ - actor-meta.c \ - actor-offscreen-redirect.c \ - actor-offscreen-limit-max-size.c\ - actor-paint-opacity.c \ - actor-pick.c \ - actor-shader-effect.c \ - actor-size.c \ - binding-pool.c \ - cairo-texture.c \ - group.c \ - interval.c \ - path.c \ - rectangle.c \ - texture-fbo.c \ - texture.c \ - text-cache.c \ - text.c \ +deprecated_tests = \ $(NULL) -# objects tests -units_sources += \ - color.c \ - model.c \ - script-parser.c \ - units.c \ - $(NULL) +test_programs = $(actor_tests) $(general_tests) $(deprecated_tests) -# cally tests -units_sources += \ - cally-text.c \ - $(NULL) - -# events tests -units_sources += \ - events-touch.c \ - $(NULL) - -if OS_WIN32 -SHEXT = -else -SHEXT = $(EXEEXT) -endif - -EXTRA_DIST += ADDING_NEW_TESTS test-launcher.sh.in run-tests.sh -DISTCLEANFILES += test-launcher.sh .gitignore - -# For convenience, this provides a way to easily run individual unit tests: -.PHONY: wrappers clean-wrappers - -#UNIT_TESTS = `./test-conformance -l -m thorough | $(GREP) '^/'` - -wrappers: stamp-test-conformance - @true -stamp-test-conformance: Makefile $(srcdir)/test-conform-main.c - @mkdir -p wrappers - @sed -n \ - -e 's/^ \{1,\}TEST_CONFORM_SIMPLE *(.*"\([^",]\{1,\}\)", *\([a-zA-Z0-9_]\{1,\}\).*/\/conform\1\/\2/p' \ - -e 's/^ \{1,\}TEST_CONFORM_SKIP *(.*"\([^",]\{1,\}\)", *\([a-zA-Z0-9_]\{1,\}\).*/\/conform\1\/\2/p' \ - -e 's/^ \{1,\}TEST_CONFORM_TODO *(.*"\([^",]\{1,\}\)", *\([a-zA-Z0-9_]\{1,\}\).*/\/conform\1\/\2/p' \ - $(srcdir)/test-conform-main.c > unit-tests - @chmod +x test-launcher.sh - @( echo "/stamp-test-conformance" ; \ - echo "/test-conformance" ; \ - echo "*.o" ; \ - echo "*.xml" ; \ - echo "*.html" ; \ - echo "*.test" ; \ - echo ".gitignore" ; \ - echo "test-suite.log" ; \ - echo "unit-tests" ; \ - echo "/wrappers/" ) > .gitignore - @for i in `cat unit-tests`; \ - do \ - unit=`basename $$i | sed -e s/_/-/g`; \ - echo " GEN $$unit"; \ - ( echo "#!/bin/sh" ; echo "$(abs_builddir)/test-launcher.sh '$$i' \"\$$@\"" ) > $$unit$(SHEXT) ; \ - ( echo "#!/bin/sh" ; echo "exec $(abs_builddir)/test-conformance$(EXEEXT) -p $$i \"\$$@\"" ) > wrappers/$$unit$(SHEXT) ; \ - ( echo "test-conformance-clutter$(EXEEXT) -p $$i" ) > $(top_builddir)/build/win32/$$unit-clutter.bat ; \ - ( echo "test-conformance-clutter$(EXEEXT) -p $$i" ) >> $(top_builddir)/build/win32/test-conformance-clutter.bat ; \ - chmod +x $$unit$(SHEXT); \ - chmod +x wrappers/$$unit$(SHEXT); \ - echo "/$$unit$(SHEXT)" >> .gitignore; \ - done \ - && echo timestamp > $(@F) - -clean-wrappers: - @if test -f "unit-tests"; then \ - for i in `cat unit-tests`; \ - do \ - unit=`basename $$i | sed -e s/_/-/g`; \ - echo " RM $$unit"; \ - rm -f $$unit$(SHEXT) ; \ - rm -f wrappers/$$unit$(SHEXT) ; \ - done \ - fi \ - && rm -rf wrappers \ - && rm -f unit-tests \ - && rm -f $(top_builddir)/build/win32/*.bat \ - && rm -f stamp-test-conformance - -test_conformance_CPPFLAGS = \ - -DG_DISABLE_SINGLE_INCLUDES \ - -DCOGL_ENABLE_EXPERIMENTAL_API \ - -DG_DISABLE_DEPRECATION_WARNINGS \ - -DCOGL_DISABLE_DEPRECATION_WARNINGS \ - -DCLUTTER_DISABLE_DEPRECATION_WARNINGS \ - -DTESTS_DATADIR=\""$(top_srcdir)/tests/data"\" \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - -I$(top_srcdir)/clutter \ - -I$(top_builddir)/clutter - -test_conformance_CFLAGS = -g $(CLUTTER_CFLAGS) -test_conformance_LDADD = $(top_builddir)/clutter/libclutter-@CLUTTER_API_VERSION@.la $(CLUTTER_LIBS) -lm -test_conformance_LDFLAGS = -export-dynamic -test_conformance_SOURCES = $(common_sources) $(units_sources) - -if OS_WIN32 -TESTS += test-conformance -endif - -TEST_PROGS += test-conformance -check_PROGRAMS += test-conformance -check_SCRIPTS += wrappers - -test: wrappers - @export G_TEST_SRCDIR="$(abs_srcdir)" ; \ - export G_TEST_BUILDDIR="$(abs_builddir)" ; \ - $(top_srcdir)/tests/conform/run-tests.sh \ - ./test-conformance$(EXEEXT) -o test-report.xml - -test-verbose: wrappers - @export G_TEST_SRCDIR="$(abs_srcdir)" ; \ - export G_TEST_BUILDDIR="$(abs_builddir)" ; \ - $(top_srcdir)/tests/conform/run-tests.sh \ - ./test-conformance$(EXEEXT) -o test-report.xml --verbose - -.PHONY: test -.PHONY: test-report perf-report full-report - -check-local: test - -GTESTER = gtester -GTESTER_REPORT = gtester-report - -# test-report: run tests and generate report -# perf-report: run tests with -m perf and generate report -# full-report: like test-report: with -m perf and -m slow -test-report perf-report full-report: ${TEST_PROGS} - @test -z "${TEST_PROGS}" || { \ - export GTESTER_LOGDIR=`mktemp -d "$(srcdir)/.testlogs-XXXXXX"` ; \ - if test -d "$(top_srcdir)/.git"; then \ - export REVISION="`git describe`" ; \ - else \ - export REVISION="$(VERSION) $(CLUTTER_RELEASE_STATUS)" ; \ - fi ; \ - export TIMESTAMP=`date +%Y-%m-%dT%H:%M:%S%z` ; \ - case $@ in \ - test-report) test_options="-k";; \ - perf-report) test_options="-k -m=perf";; \ - full-report) test_options="-k -m=perf -m=slow";; \ - esac ; \ - export G_TEST_SRCDIR="$(abs_srcdir)" ; \ - export G_TEST_BUILDDIR="$(abs_builddir)" ; \ - $(top_srcdir)/tests/conform/run-tests.sh \ - ./test-conformance$(EXEEXT) \ - --verbose \ - $$test_options \ - -o `mktemp "$$GTESTER_LOGDIR/log-XXXXXX"` ; \ - echo '' > $@.xml ; \ - echo '' >> $@.xml ; \ - echo '' >> $@.xml ; \ - echo ' $(PACKAGE)' >> $@.xml ; \ - echo ' $(VERSION)' >> $@.xml ; \ - echo " $$REVISION" >> $@.xml ; \ - echo " $$TIMESTAMP" >> $@.xml ; \ - echo '' >> $@.xml ; \ - for lf in `ls -L "$$GTESTER_LOGDIR"/.` ; do \ - sed '1,1s/^?]*?>//' <"$$GTESTER_LOGDIR"/"$$lf" >> $@.xml ; \ - done ; \ - echo >> $@.xml ; \ - echo '' >> $@.xml ; \ - ${GTESTER_REPORT} --version 2>/dev/null 1>&2 ; test "$$?" != 0 || ${GTESTER_REPORT} $@.xml >$@.html ; \ - rm -rf "$$GTESTER_LOGDIR" ; \ - } - -XML_REPORTS = \ - test-report.xml \ - perf-report.xml \ - full-report.xml \ - test-report-npot.xml \ - perf-report-npot.xml \ - full-report-npot.xml - -HTML_REPORTS = \ - test-report.html \ - perf-report.html \ - full-report.html \ - test-report-npot.html \ - perf-report-npot.html \ - full-report-npot.html - -dist-hook: $(top_builddir)/build/win32/vs9/test-conformance-clutter.vcproj $(top_builddir)/build/win32/vs10/test-conformance-clutter.vcxproj $(top_builddir)/build/win32/vs10/test-conformance-clutter.vcxproj.filters - -$(top_builddir)/build/win32/vs9/test-conformance-clutter.vcproj: $(top_srcdir)/build/win32/vs9/test-conformance-clutter.vcprojin - @for F in $(test_conformance_SOURCES); do \ - case $$F in \ - *.c) echo ' ' \ - ;; \ - esac; \ - done > testconformance.sourcefiles - $(CPP) -P - <$(top_srcdir)/build/win32/vs9/test-conformance-clutter.vcprojin >$@ - rm -f testconformance.sourcefiles - -$(top_builddir)/build/win32/vs10/test-conformance-clutter.vcxproj: $(top_srcdir)/build/win32/vs10/test-conformance-clutter.vcxprojin - @for F in $(test_conformance_SOURCES); do \ - case $$F in \ - *.c) echo ' ' \ - ;; \ - esac; \ - done >testconformance.vs10.sourcefiles - $(CPP) -P - <$(top_srcdir)/build/win32/vs10/test-conformance-clutter.vcxprojin >$@ - rm -f testconformance.vs10.sourcefiles - -$(top_builddir)/build/win32/vs10/test-conformance-clutter.vcxproj.filters: $(top_srcdir)/build/win32/vs10/test-conformance-clutter.vcxproj.filtersin - @for F in $(test_conformance_SOURCES); do \ - case $$F in \ - *.c) echo ' Sources' \ - ;; \ - esac; \ - done > testconformance.vs10.sourcefiles.filters - $(CPP) -P - < $(top_srcdir)/build/win32/vs10/test-conformance-clutter.vcxproj.filtersin > $@ - rm -f testconformance.vs10.sourcefiles.filters - -# Let the VS9/VS10 Project files be cleared out before they are re-expanded... -DISTCLEANFILES += \ - $(top_builddir)/build/win32/vs9/test-conformance-clutter.vcproj \ - $(top_builddir)/build/win32/vs10/test-conformance-clutter.vcxproj \ - $(top_builddir)/build/win32/vs10/test-conformance-clutter.vcxproj.filters - -# we override the clean-generic target to clean up the wrappers so -# we cannot use CLEANFILES -clean-generic: clean-wrappers clean-tests - $(QUIET_RM)rm -f $(XML_REPORTS) $(HTML_REPORTS) - -if ENABLE_INSTALLED_TESTS -# installed tests -insttestdir = $(libexecdir)/installed-tests/$(PACKAGE)/conform -insttest_PROGRAMS = test-conformance - -testmetadir = $(datadir)/installed-tests/$(PACKAGE) -testmeta_DATA = $(wildcard *.test) - -BUILT_SOURCES += tests -endif - -.PHONY: tests clean-tests - -tests: stamp-test-conformance - @for i in `cat unit-tests`; do \ - unit=`basename $$i | sed -e s/_/-/g`; \ - echo " GEN $$unit"; \ - echo "[Test]" > $$unit.test; \ - echo "Type=session" >> $$unit.test; \ - echo "Exec=$(libexecdir)/installed-tests/$(PACKAGE)/conform/test-conformance -p $$i" >> $$unit.test; \ - done - -clean-tests: - $(QUIET_RM) rm -f *.test +dist_test_data = $(script_ui_files) +script_ui_files = $(addprefix scripts/,$(script_tests)) +script_tests = \ + test-animator-1.json \ + test-animator-2.json \ + test-animator-3.json \ + test-script-animation.json \ + test-script-child.json \ + test-script-implicit-alpha.json \ + test-script-interval.json \ + test-script-layout-property.json \ + test-script-margin.json \ + test-script-model.json \ + test-script-named-object.json \ + test-script-object-property.json \ + test-script-single.json \ + test-script-timeline-markers.json \ + test-state-1.json diff --git a/tests/conform/run-tests.sh b/tests/conform/run-tests.sh deleted file mode 100755 index 03f5a7af3..000000000 --- a/tests/conform/run-tests.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -BINARY=$1 -shift - -TMP=`./$BINARY -l -m thorough | grep '^/' | sed -e s/_/-/g` -for i in $TMP -do - TESTS="$TESTS wrappers/`basename $i`" -done - -G_DEBUG=gc-friendly MALLOC_CHECK_=2 MALLOC_PERTURB_=$((${RANDOM:-256} % 256)) gtester "$@" $TESTS diff --git a/tests/data/test-animator-1.json b/tests/conform/scripts/test-animator-1.json similarity index 100% rename from tests/data/test-animator-1.json rename to tests/conform/scripts/test-animator-1.json diff --git a/tests/data/test-animator-2.json b/tests/conform/scripts/test-animator-2.json similarity index 100% rename from tests/data/test-animator-2.json rename to tests/conform/scripts/test-animator-2.json diff --git a/tests/data/test-animator-3.json b/tests/conform/scripts/test-animator-3.json similarity index 100% rename from tests/data/test-animator-3.json rename to tests/conform/scripts/test-animator-3.json diff --git a/tests/data/test-script-animation.json b/tests/conform/scripts/test-script-animation.json similarity index 100% rename from tests/data/test-script-animation.json rename to tests/conform/scripts/test-script-animation.json diff --git a/tests/data/test-script-child.json b/tests/conform/scripts/test-script-child.json similarity index 100% rename from tests/data/test-script-child.json rename to tests/conform/scripts/test-script-child.json diff --git a/tests/data/test-script-implicit-alpha.json b/tests/conform/scripts/test-script-implicit-alpha.json similarity index 100% rename from tests/data/test-script-implicit-alpha.json rename to tests/conform/scripts/test-script-implicit-alpha.json diff --git a/tests/data/test-script-interval.json b/tests/conform/scripts/test-script-interval.json similarity index 100% rename from tests/data/test-script-interval.json rename to tests/conform/scripts/test-script-interval.json diff --git a/tests/data/test-script-layout-property.json b/tests/conform/scripts/test-script-layout-property.json similarity index 100% rename from tests/data/test-script-layout-property.json rename to tests/conform/scripts/test-script-layout-property.json diff --git a/tests/data/test-script-margin.json b/tests/conform/scripts/test-script-margin.json similarity index 100% rename from tests/data/test-script-margin.json rename to tests/conform/scripts/test-script-margin.json diff --git a/tests/data/test-script-model.json b/tests/conform/scripts/test-script-model.json similarity index 100% rename from tests/data/test-script-model.json rename to tests/conform/scripts/test-script-model.json diff --git a/tests/data/test-script-named-object.json b/tests/conform/scripts/test-script-named-object.json similarity index 100% rename from tests/data/test-script-named-object.json rename to tests/conform/scripts/test-script-named-object.json diff --git a/tests/data/test-script-object-property.json b/tests/conform/scripts/test-script-object-property.json similarity index 100% rename from tests/data/test-script-object-property.json rename to tests/conform/scripts/test-script-object-property.json diff --git a/tests/data/test-script-single.json b/tests/conform/scripts/test-script-single.json similarity index 100% rename from tests/data/test-script-single.json rename to tests/conform/scripts/test-script-single.json diff --git a/tests/data/test-script-timeline-markers.json b/tests/conform/scripts/test-script-timeline-markers.json similarity index 100% rename from tests/data/test-script-timeline-markers.json rename to tests/conform/scripts/test-script-timeline-markers.json diff --git a/tests/data/test-state-1.json b/tests/conform/scripts/test-state-1.json similarity index 100% rename from tests/data/test-state-1.json rename to tests/conform/scripts/test-state-1.json diff --git a/tests/conform/test-conform-common.c b/tests/conform/test-conform-common.c deleted file mode 100644 index 881a6b1cd..000000000 --- a/tests/conform/test-conform-common.c +++ /dev/null @@ -1,105 +0,0 @@ -#include "config.h" - -#include -#include - -#ifdef CLUTTER_WINDOWING_X11 -#include -#include -#endif - -#include "test-conform-common.h" - -/** - * test_conform_simple_fixture_setup: - * - * Initialise stuff before each test is run - */ -void -test_conform_simple_fixture_setup (TestConformSimpleFixture *fixture, - gconstpointer data) -{ - const TestConformSharedState *shared_state = data; - static int counter = 0; - - if (counter != 0) - g_critical ("We don't support running more than one test at a time\n" - "in a single test run due to the state leakage that often\n" - "causes subsequent tests to fail.\n" - "\n" - "If you want to run all the tests you should run\n" - "$ make test-report"); - counter++; - -#ifdef CLUTTER_WINDOWING_X11 - if (clutter_check_windowing_backend (CLUTTER_WINDOWING_X11)) - { - /* on X11 we need a display connection to run the test suite */ - const gchar *display = g_getenv ("DISPLAY"); - if (!display || *display == '\0') - { - g_print ("No DISPLAY found. Unable to run the conformance " - "test suite without a display.\n"); - - exit (EXIT_SUCCESS); - } - - /* enable XInput support */ - clutter_x11_enable_xinput (); - } -#endif - - g_assert (clutter_init (shared_state->argc_addr, shared_state->argv_addr) - == CLUTTER_INIT_SUCCESS); - -#ifdef CLUTTER_WINDOWING_X11 - /* A lot of the tests depend on a specific stage / framebuffer size - * when they read pixels back to verify the results of the test. - * - * Normally the asynchronous nature of X means that setting the - * clutter stage size may really happen an indefinite amount of time - * later but since the tests are so short lived and may only render - * a single frame this is not an acceptable semantic. - */ - if (clutter_check_windowing_backend (CLUTTER_WINDOWING_X11)) - XSynchronize (clutter_x11_get_default_display(), TRUE); -#endif -} - - -/** - * test_conform_simple_fixture_teardown: - * - * Cleanup stuff after each test has finished - */ -void -test_conform_simple_fixture_teardown (TestConformSimpleFixture *fixture, - gconstpointer data) -{ - /* const TestConformSharedState *shared_state = data; */ -} - -void -test_conform_get_gl_functions (TestConformGLFunctions *functions) -{ - functions->glGetString = (void *) cogl_get_proc_address ("glGetString"); - g_assert (functions->glGetString != NULL); - functions->glGetIntegerv = (void *) cogl_get_proc_address ("glGetIntegerv"); - g_assert (functions->glGetIntegerv != NULL); - functions->glPixelStorei = (void *) cogl_get_proc_address ("glPixelStorei"); - g_assert (functions->glPixelStorei != NULL); - functions->glBindTexture = (void *) cogl_get_proc_address ("glBindTexture"); - g_assert (functions->glBindTexture != NULL); - functions->glGenTextures = (void *) cogl_get_proc_address ("glGenTextures"); - g_assert (functions->glGenTextures != NULL); - functions->glGetError = (void *) cogl_get_proc_address ("glGetError"); - g_assert (functions->glGetError != NULL); - functions->glDeleteTextures = - (void *) cogl_get_proc_address ("glDeleteTextures"); - g_assert (functions->glDeleteTextures != NULL); - functions->glTexImage2D = (void *) cogl_get_proc_address ("glTexImage2D"); - g_assert (functions->glTexImage2D != NULL); - functions->glTexParameteri = - (void *) cogl_get_proc_address ("glTexParameteri"); - g_assert (functions->glTexParameteri != NULL); -} diff --git a/tests/conform/test-conform-common.h b/tests/conform/test-conform-common.h deleted file mode 100644 index f2d50dedd..000000000 --- a/tests/conform/test-conform-common.h +++ /dev/null @@ -1,52 +0,0 @@ - -/* Stuff you put in here is setup once in main() and gets passed around to - * all test functions and fixture setup/teardown functions in the data - * argument */ -typedef struct _TestConformSharedState -{ - int *argc_addr; - char ***argv_addr; -} TestConformSharedState; - - -/* This fixture structure is allocated by glib, and before running each test - * the test_conform_simple_fixture_setup func (see below) is called to - * initialise it, and test_conform_simple_fixture_teardown is called when - * the test is finished. */ -typedef struct _TestConformSimpleFixture -{ - /**/ - int dummy; -} TestConformSimpleFixture; - -typedef struct _TestConformTodo -{ - gchar *name; - void (* func) (TestConformSimpleFixture *, gconstpointer); -} TestConformTodo; - -typedef struct _TestConformGLFunctions -{ - const guint8 * (* glGetString) (guint name); - void (* glGetIntegerv) (guint pname, int *params); - void (* glPixelStorei) (guint pname, int param); - void (* glBindTexture) (guint target, guint texture); - void (* glGenTextures) (int n, guint *textures); - guint (* glGetError) (void); - void (* glDeleteTextures) (int n, const guint *textures); - void (* glTexImage2D) (guint target, int level, - int internalFormat, - int width, int height, - int border, guint format, guint type, - const void *pixels); - void (* glTexParameteri) (guint target, guint pname, int param); -} TestConformGLFunctions; - -void test_conform_get_gl_functions (TestConformGLFunctions *functions); - -void test_conform_simple_fixture_setup (TestConformSimpleFixture *fixture, - gconstpointer data); -void test_conform_simple_fixture_teardown (TestConformSimpleFixture *fixture, - gconstpointer data); - -gchar *clutter_test_get_data_file (const gchar *filename); diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c deleted file mode 100644 index 00cc1c628..000000000 --- a/tests/conform/test-conform-main.c +++ /dev/null @@ -1,217 +0,0 @@ -#include "config.h" - -#include - -#include -#include -#include - -#include "test-conform-common.h" - -static void -test_conform_skip_test (TestConformSimpleFixture *fixture, - gconstpointer data) -{ - /* void */ -} - -void -verify_failure (TestConformSimpleFixture *fixture, - gconstpointer data) -{ - g_assert (FALSE); -} - -static TestConformSharedState *shared_state = NULL; - -/* This is a bit of sugar for adding new conformance tests: - * - * - It adds an extern function definition just to save maintaining a header - * that lists test entry points. - * - It sets up callbacks for a fixture, which lets us share initialization - * *code* between tests. (see test-conform-common.c) - * - It passes in a shared *data* pointer that is initialised once in main(), - * that gets passed to the fixture setup and test functions. (See the - * definition in test-conform-common.h) - */ -#define TEST_CONFORM_SIMPLE(NAMESPACE, FUNC) G_STMT_START { \ - extern void FUNC (TestConformSimpleFixture *, gconstpointer); \ - g_test_add ("/conform" NAMESPACE "/" #FUNC, \ - TestConformSimpleFixture, \ - shared_state, /* data argument for test */ \ - test_conform_simple_fixture_setup, \ - FUNC, \ - test_conform_simple_fixture_teardown); } G_STMT_END - -/* this is a macro that conditionally executes a test if CONDITION - * evaluates to TRUE; otherwise, it will put the test under the - * "/skipped" namespace and execute a dummy function that will always - * pass. - */ -#define TEST_CONFORM_SKIP(CONDITION, NAMESPACE, FUNC) G_STMT_START { \ - if (CONDITION) { TEST_CONFORM_SIMPLE (NAMESPACE, FUNC); } \ - else { \ - g_test_add ("/skipped" NAMESPACE "/" #FUNC, \ - TestConformSimpleFixture, \ - shared_state, /* data argument for test */ \ - test_conform_simple_fixture_setup, \ - test_conform_skip_test, \ - test_conform_simple_fixture_teardown); \ - } } G_STMT_END - -gchar * -clutter_test_get_data_file (const gchar *filename) -{ - return g_test_build_filename (G_TEST_DIST, "..", "data", filename, NULL); -} - -static void -clutter_test_init (gint *argc, - gchar ***argv) -{ - /* Turning of sync-to-vblank removes a dependency on the specifics of the - * test environment. It also means that the timeline-only tests are - * throttled to a reasonable frame rate rather than running in tight - * infinite loop. - */ - g_setenv ("CLUTTER_VBLANK", "none", FALSE); - - g_test_init (argc, argv, NULL); - - g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=%s"); - - /* Initialise the state you need to share with everything. - */ - shared_state = g_new0 (TestConformSharedState, 1); - shared_state->argc_addr = argc; - shared_state->argv_addr = argv; -} - -int -main (int argc, char **argv) -{ - clutter_test_init (&argc, &argv); - - /* This file is run through a sed script during the make step so the - lines containing the tests need to be formatted on a single line - each. To comment out a test use the SKIP macro. Using - #if 0 would break the script. */ - - TEST_CONFORM_SIMPLE ("/actor", actor_add_child); - TEST_CONFORM_SIMPLE ("/actor", actor_insert_child); - TEST_CONFORM_SIMPLE ("/actor", actor_raise_child); - TEST_CONFORM_SIMPLE ("/actor", actor_lower_child); - TEST_CONFORM_SIMPLE ("/actor", actor_replace_child); - TEST_CONFORM_SIMPLE ("/actor", actor_remove_child); - TEST_CONFORM_SIMPLE ("/actor", actor_remove_all); - TEST_CONFORM_SIMPLE ("/actor", actor_container_signals); - TEST_CONFORM_SIMPLE ("/actor", actor_destruction); - TEST_CONFORM_SIMPLE ("/actor", actor_anchors); - TEST_CONFORM_SIMPLE ("/actor", actor_pick); - TEST_CONFORM_SIMPLE ("/actor", actor_fixed_size); - TEST_CONFORM_SIMPLE ("/actor", actor_preferred_size); - TEST_CONFORM_SIMPLE ("/actor", actor_basic_layout); - TEST_CONFORM_SIMPLE ("/actor", actor_margin_layout); - TEST_CONFORM_SIMPLE ("/actor", actor_offscreen_redirect); - TEST_CONFORM_SIMPLE ("/actor", actor_offscreen_limit_max_size); - TEST_CONFORM_SIMPLE ("/actor", actor_shader_effect); - - TEST_CONFORM_SIMPLE ("/actor/iter", actor_iter_traverse_children); - TEST_CONFORM_SIMPLE ("/actor/iter", actor_iter_traverse_remove); - TEST_CONFORM_SIMPLE ("/actor/iter", actor_iter_assignment); - - TEST_CONFORM_SIMPLE ("/actor/invariants", actor_initial_state); - TEST_CONFORM_SIMPLE ("/actor/invariants", actor_shown_not_parented); - TEST_CONFORM_SIMPLE ("/actor/invariants", actor_visibility_not_recursive); - TEST_CONFORM_SIMPLE ("/actor/invariants", actor_realized); - TEST_CONFORM_SIMPLE ("/actor/invariants", actor_realize_not_recursive); - TEST_CONFORM_SIMPLE ("/actor/invariants", actor_map_recursive); - TEST_CONFORM_SIMPLE ("/actor/invariants", actor_mapped); - TEST_CONFORM_SIMPLE ("/actor/invariants", actor_show_on_set_parent); - TEST_CONFORM_SIMPLE ("/actor/invariants", clone_no_map); - TEST_CONFORM_SIMPLE ("/actor/invariants", actor_contains); - TEST_CONFORM_SIMPLE ("/actor/invariants", default_stage); - TEST_CONFORM_SIMPLE ("/actor/invariants", actor_pivot_transformation); - - TEST_CONFORM_SIMPLE ("/actor/meta", actor_meta_clear); - - TEST_CONFORM_SIMPLE ("/actor/opacity", opacity_label); - TEST_CONFORM_SIMPLE ("/actor/opacity", opacity_rectangle); - TEST_CONFORM_SIMPLE ("/actor/opacity", opacity_paint); - - TEST_CONFORM_SIMPLE ("/text", text_utf8_validation); - TEST_CONFORM_SIMPLE ("/text", text_set_empty); - TEST_CONFORM_SIMPLE ("/text", text_set_text); - TEST_CONFORM_SIMPLE ("/text", text_append_some); - TEST_CONFORM_SIMPLE ("/text", text_prepend_some); - TEST_CONFORM_SIMPLE ("/text", text_insert); - TEST_CONFORM_SIMPLE ("/text", text_delete_chars); - TEST_CONFORM_SIMPLE ("/text", text_delete_text); - TEST_CONFORM_SIMPLE ("/text", text_cursor); - TEST_CONFORM_SIMPLE ("/text", text_event); - TEST_CONFORM_SIMPLE ("/text", text_get_chars); - TEST_CONFORM_SIMPLE ("/text", text_cache); - TEST_CONFORM_SIMPLE ("/text", text_password_char); - TEST_CONFORM_SIMPLE ("/text", text_idempotent_use_markup); - - TEST_CONFORM_SIMPLE ("/rectangle", rectangle_set_size); - TEST_CONFORM_SIMPLE ("/rectangle", rectangle_set_color); - - TEST_CONFORM_SKIP (g_test_slow (), "/texture", texture_pick_with_alpha); - TEST_CONFORM_SKIP (g_test_slow (), "/texture", texture_fbo); - TEST_CONFORM_SKIP (g_test_slow (), "/texture/cairo", texture_cairo); - - TEST_CONFORM_SIMPLE ("/interval", interval_initial_state); - TEST_CONFORM_SIMPLE ("/interval", interval_transform); - - TEST_CONFORM_SIMPLE ("/path", path_base); - - TEST_CONFORM_SIMPLE ("/binding-pool", binding_pool); - - TEST_CONFORM_SIMPLE ("/model", list_model_populate); - TEST_CONFORM_SIMPLE ("/model", list_model_iterate); - TEST_CONFORM_SIMPLE ("/model", list_model_filter); - TEST_CONFORM_SIMPLE ("/model", list_model_from_script); - TEST_CONFORM_SIMPLE ("/model", list_model_row_changed); - - TEST_CONFORM_SIMPLE ("/color", color_from_string_valid); - TEST_CONFORM_SIMPLE ("/color", color_from_string_invalid); - TEST_CONFORM_SIMPLE ("/color", color_to_string); - TEST_CONFORM_SIMPLE ("/color", color_hls_roundtrip); - TEST_CONFORM_SIMPLE ("/color", color_operators); - - TEST_CONFORM_SIMPLE ("/units", units_constructors); - TEST_CONFORM_SIMPLE ("/units", units_string); - TEST_CONFORM_SIMPLE ("/units", units_cache); - - TEST_CONFORM_SIMPLE ("/group", group_depth_sorting); - - TEST_CONFORM_SIMPLE ("/script", script_single); - TEST_CONFORM_SIMPLE ("/script", script_child); - TEST_CONFORM_SIMPLE ("/script", script_implicit_alpha); - TEST_CONFORM_SIMPLE ("/script", script_object_property); - TEST_CONFORM_SIMPLE ("/script", script_animation); - TEST_CONFORM_SIMPLE ("/script", script_named_object); - TEST_CONFORM_SIMPLE ("/script", script_layout_property); - TEST_CONFORM_SIMPLE ("/script", animator_base); - TEST_CONFORM_SIMPLE ("/script", animator_properties); - TEST_CONFORM_SIMPLE ("/script", animator_multi_properties); - TEST_CONFORM_SIMPLE ("/script", state_base); - TEST_CONFORM_SIMPLE ("/script", script_margin); - TEST_CONFORM_SIMPLE ("/script", script_interval); - - TEST_CONFORM_SKIP (g_test_slow (), "/timeline", timeline_base); - TEST_CONFORM_SIMPLE ("/timeline", timeline_markers_from_script); - TEST_CONFORM_SKIP (g_test_slow (), "/timeline", timeline_interpolation); - TEST_CONFORM_SKIP (g_test_slow (), "/timeline", timeline_rewind); - TEST_CONFORM_SIMPLE ("/timeline", timeline_progress_mode); - TEST_CONFORM_SIMPLE ("/timeline", timeline_progress_step); - - TEST_CONFORM_SIMPLE ("/score", score_base); - - TEST_CONFORM_SIMPLE ("/behaviours", behaviours_base); - - TEST_CONFORM_SIMPLE ("/events", events_touch); - - return g_test_run (); -} diff --git a/tests/conform/test-launcher.sh.in b/tests/conform/test-launcher.sh.in deleted file mode 100755 index 0be13bda5..000000000 --- a/tests/conform/test-launcher.sh.in +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -UNIT_TEST_PATH=$1 -shift - -test -z ${UNIT_TEST_PATH} && { - echo "Usage: $0 /path/to/unit_test" - exit 1 -} - -UNIT_TEST=`basename ${UNIT_TEST_PATH}` - -echo "Running: ./test-conformance -p ${UNIT_TEST_PATH} $@" -echo "" -@abs_builddir@/test-conformance -p ${UNIT_TEST_PATH} "$@" - -echo "" -echo "NOTE: For debugging purposes, you can run this single test as follows:" -echo "$ libtool --mode=execute \\" -echo " gdb --eval-command=\"b ${UNIT_TEST}\" \\" -echo " --args ./test-conformance -p ${UNIT_TEST_PATH}" -echo "or:" -echo "$ env G_SLICE=always-malloc \\" -echo " libtool --mode=execute \\" -echo " valgrind ./test-conformance -p ${UNIT_TEST_PATH}" diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am deleted file mode 100644 index 4e6878e88..000000000 --- a/tests/data/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -NULL = -EXTRA_DIST = - -json_files = \ - test-script-animation.json \ - test-script-child.json \ - test-script-layout-property.json \ - test-script-implicit-alpha.json \ - test-script.json \ - test-script-named-object.json \ - test-script-object-property.json \ - test-script-signals.json \ - test-script-single.json \ - test-script-model.json \ - test-animator-1.json \ - test-animator-2.json \ - test-animator-3.json \ - test-state-1.json \ - test-script-timeline-markers.json \ - test-script-margin.json \ - test-script-interval.json \ - $(NULL) - -EXTRA_DIST += $(json_files) - -png_files = \ - redhand.png \ - redhand_alpha.png \ - light0.png \ - $(NULL) - -EXTRA_DIST += $(png_files) - -if ENABLE_INSTALLED_TESTS -insttestdir = $(libexecdir)/installed-tests/$(PACKAGE)/data -insttest_DATA = $(json_files) $(png_files) -endif - -EXTRA_DIST += clutter-1.0.suppressions diff --git a/tests/data/light0.png b/tests/data/light0.png deleted file mode 100644 index 66871ddb3..000000000 Binary files a/tests/data/light0.png and /dev/null differ diff --git a/tests/data/redhand_alpha.png b/tests/data/redhand_alpha.png deleted file mode 100644 index 4270765ed..000000000 Binary files a/tests/data/redhand_alpha.png and /dev/null differ diff --git a/tests/interactive/Makefile.am b/tests/interactive/Makefile.am index 8e87edf44..8bea2bcad 100644 --- a/tests/interactive/Makefile.am +++ b/tests/interactive/Makefile.am @@ -148,7 +148,7 @@ test_interactive_SOURCES = test-main.c $(UNIT_TESTS) nodist_test_interactive_SOURCES = test-unit-names.h test_interactive_CFLAGS = $(CLUTTER_CFLAGS) $(GDK_PIXBUF_CFLAGS) test_interactive_CPPFLAGS = \ - -DTESTS_DATADIR=\""$(abs_top_srcdir)/tests/data"\" \ + -DTESTS_DATADIR=\""$(abs_srcdir)"\" \ -DG_DISABLE_SINGLE_INCLUDES \ -DGLIB_DISABLE_DEPRECATION_WARNINGS \ -DCOGL_DISABLE_DEPRECATION_WARNINGS \ @@ -161,8 +161,11 @@ test_interactive_LDFLAGS = -export-dynamic test_interactive_LDADD = $(CLUTTER_LIBS) $(GDK_PIXBUF_LIBS) $(common_ldadd) -lm EXTRA_DIST = \ - wrapper.sh.in \ - $(top_builddir)/build/win32/test-unit-names.h + wrapper.sh.in \ + $(top_builddir)/build/win32/test-unit-names.h \ + test-script.json \ + test-script-signals.json \ + redhand.png DISTCLEANFILES = wrapper.sh .gitignore test-unit-names.h diff --git a/tests/interactive/redhand.png b/tests/interactive/redhand.png new file mode 100644 index 000000000..c07d8acd3 Binary files /dev/null and b/tests/interactive/redhand.png differ diff --git a/tests/data/test-script-signals.json b/tests/interactive/test-script-signals.json similarity index 100% rename from tests/data/test-script-signals.json rename to tests/interactive/test-script-signals.json diff --git a/tests/data/test-script.json b/tests/interactive/test-script.json similarity index 100% rename from tests/data/test-script.json rename to tests/interactive/test-script.json diff --git a/tests/interactive/test-state-script.c b/tests/interactive/test-state-script.c index e777d89bc..34b1b8789 100644 --- a/tests/interactive/test-state-script.c +++ b/tests/interactive/test-state-script.c @@ -4,7 +4,7 @@ #include -#define TEST_STATE_SCRIPT_FILE TESTS_DATADIR G_DIR_SEPARATOR_S "test-script-signals.json" +#define TEST_STATE_SCRIPT_FILE "test-script-signals.json" gboolean on_button_press (ClutterActor *actor,