diff --git a/Makefile-tests.am b/Makefile-tests.am index c46b77fe..4045e0c3 100644 --- a/Makefile-tests.am +++ b/Makefile-tests.am @@ -17,68 +17,68 @@ # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. +include $(top_srcdir)/buildutil/glib-tap.mk -if BUILDOPT_INSTALL_TESTS +# We should probably consider flipping the default for DEBUG. Also, +# include the builddir in $PATH so we find our just-built ostree +# binary. +TESTS_ENVIRONMENT += OT_TESTS_DEBUG=1 \ + PATH=$$(cd $(top_builddir) && pwd):$${PATH} -insttestdir=$(pkglibexecdir)/installed-tests -testfiles = test-basic \ - test-pull-subpath \ - test-archivez \ - test-remote-add \ - test-remote-gpg-import \ - test-commit-sign \ - test-export \ - test-help \ - test-libarchive \ - test-pull-archive-z \ - test-pull-commit-only \ - test-pull-corruption \ - test-pull-depth \ - test-pull-mirror-summary \ - test-pull-large-metadata \ - test-pull-metalink \ - test-pull-summary-sigs \ - test-pull-resume \ - test-local-pull-depth \ - test-gpg-signed-commit \ - test-admin-upgrade-unconfigured \ - test-admin-deploy-syslinux \ - test-admin-deploy-2 \ - test-admin-deploy-karg \ - test-admin-deploy-switch \ - test-admin-deploy-etcmerge-cornercases \ - test-admin-deploy-uboot \ - test-admin-instutil-set-kargs \ - test-admin-upgrade-not-backwards \ - test-admin-pull-deploy-commit \ - test-admin-locking \ - test-admin-deploy-clean \ - test-repo-checkout-subpath \ - test-reset-nonlinear \ - test-oldstyle-partial \ - test-setuid \ - test-delta \ - test-xattrs \ - test-auto-summary \ - test-prune \ - test-refs \ +test_scripts = \ + tests/test-basic.sh \ + tests/test-pull-subpath.sh \ + tests/test-archivez.sh \ + tests/test-remote-add.sh \ + tests/test-remote-gpg-import.sh \ + tests/test-commit-sign.sh \ + tests/test-export.sh \ + tests/test-help.sh \ + tests/test-libarchive.sh \ + tests/test-pull-archive-z.sh \ + tests/test-pull-commit-only.sh \ + tests/test-pull-corruption.sh \ + tests/test-pull-depth.sh \ + tests/test-pull-mirror-summary.sh \ + tests/test-pull-large-metadata.sh \ + tests/test-pull-metalink.sh \ + tests/test-pull-summary-sigs.sh \ + tests/test-pull-resume.sh \ + tests/test-local-pull-depth.sh \ + tests/test-gpg-signed-commit.sh \ + tests/test-admin-upgrade-unconfigured.sh \ + tests/test-admin-deploy-syslinux.sh \ + tests/test-admin-deploy-2.sh \ + tests/test-admin-deploy-karg.sh \ + tests/test-admin-deploy-switch.sh \ + tests/test-admin-deploy-etcmerge-cornercases.sh \ + tests/test-admin-deploy-uboot.sh \ + tests/test-admin-instutil-set-kargs.sh \ + tests/test-admin-upgrade-not-backwards.sh \ + tests/test-admin-pull-deploy-commit.sh \ + tests/test-admin-locking.sh \ + tests/test-admin-deploy-clean.sh \ + tests/test-repo-checkout-subpath.sh \ + tests/test-reset-nonlinear.sh \ + tests/test-oldstyle-partial.sh \ + tests/test-setuid.sh \ + tests/test-delta.sh \ + tests/test-xattrs.sh \ + tests/test-auto-summary.sh \ + tests/test-prune.sh \ + tests/test-refs.sh \ $(NULL) if BUILDOPT_FUSE -testfiles += test-rofiles-fuse +test_scripts += tests/test-rofiles-fuse.sh endif -insttest_SCRIPTS = $(addprefix tests/,$(testfiles:=.sh)) - # This one uses corrupt-repo-ref.js if BUILDOPT_GJS -testfiles += test-corruption +test_scripts += tests/test-corruption.sh endif -testmetadir = $(datadir)/installed-tests/$(PACKAGE) -testmeta_DATA = $(testfiles:=.test) - -insttest_DATA = tests/archive-test.sh \ +installed_test_data = tests/archive-test.sh \ tests/pull-test.sh \ tests/libtest.sh \ tests/admin-test.sh \ @@ -90,67 +90,46 @@ insttest_DATA = tests/archive-test.sh \ tests/pre-endian-deltas-repo-little.tar.xz \ $(NULL) -insttest_SCRIPTS += \ - tests/syslinux-entries-crosscheck.py \ - $(NULL) +test_extra_scripts = tests/syslinux-entries-crosscheck.py -gpginsttestdir = $(pkglibexecdir)/installed-tests/gpghome +gpginsttestdir = $(installed_testdir)/gpghome gpginsttest_DATA = tests/gpghome/secring.gpg \ + tests/gpghome/pubring.gpg \ tests/gpghome/trustdb.gpg \ tests/gpghome/key1.asc \ tests/gpghome/key2.asc \ tests/gpghome/key3.asc -gpginsttest_trusteddir = $(pkglibexecdir)/installed-tests/gpghome/trusted +gpginsttest_trusteddir = $(installed_testdir)/gpghome/trusted gpginsttest_trusted_DATA = tests/gpghome/trusted/pubring.gpg -install-gpg-data-hook: - ln -sf trusted/pubring.gpg $(DESTDIR)$(gpginsttestdir)/pubring.gpg -INSTALL_DATA_HOOKS += install-gpg-data-hook - -%.test: tests/%.sh Makefile - $(AM_V_GEN) (echo '[Test]' > $@.tmp; \ - echo 'Exec=$(pkglibexecdir)/installed-tests/$(notdir $<)' >> $@.tmp; \ - echo 'Type=session' >> $@.tmp; \ - echo 'Output=TAP' >> $@.tmp; \ - mv $@.tmp $@) - -%.test: tests/%.js Makefile - $(AM_V_GEN) (echo '[Test]' > $@.tmp; \ - echo 'Exec=env TESTDATADIR=$(pkglibexecdir)/installed-tests $(pkglibexecdir)/installed-tests/$(notdir $<)' >> $@.tmp; \ - echo 'Type=session' >> $@.tmp; \ - mv $@.tmp $@) +gpgvinsttestdir = $(installed_testdir)/gpg-verify-data +gpgvinsttest_DATA = $(addprefix tests/gpg-verify-data/, \ + gpg.conf lgpl2 lgpl2.sig pubring.gpg secring.gpg trustdb.gpg) if BUILDOPT_GJS -insttest_SCRIPTS += tests/test-core.js \ +installed_test_scripts = tests/test-core.js \ tests/test-sizes.js \ tests/test-sysroot.js \ $(NULL) -testmeta_DATA += test-core.test test-sizes.test test-sysroot.test endif -insttest_LTLIBRARIES = libreaddir-rand.la +test_ltlibraries = libreaddir-rand.la libreaddir_rand_la_SOURCES = tests/readdir-rand.c libreaddir_rand_la_CFLAGS = $(OT_INTERNAL_GIO_UNIX_CFLAGS) libreaddir_rand_la_LIBADD = $(OT_INTERNAL_GIO_UNIX_LIBS) libreaddir_rand_la_LDFLAGS = -avoid-version -endif - -# "make check" do not depend from --enable-installed-tests -noinst_PROGRAMS += tests/test-rollsum-cli - -TESTS = tests/test-varint tests/test-ot-unix-utils tests/test-bsdiff tests/test-mutable-tree \ +test_programs = tests/test-varint tests/test-ot-unix-utils tests/test-bsdiff tests/test-mutable-tree \ tests/test-keyfile-utils tests/test-ot-opt-utils tests/test-ot-tool-util \ tests/test-gpg-verify-result tests/test-checksum tests/test-lzma tests/test-rollsum +# An interactive tool +noinst_PROGRAMS += tests/test-rollsum-cli + if USE_LIBARCHIVE -TESTS += tests/test-libarchive-import +test_programs += tests/test-libarchive-import endif -check_PROGRAMS = $(TESTS) -TESTS_ENVIRONMENT = \ - G_TEST_SRCDIR=$(abs_srcdir)/tests \ - G_TEST_BUILDDIR=$(abs_builddir)/tests TESTS_CFLAGS = $(ostree_bin_shared_cflags) $(OT_INTERNAL_GIO_UNIX_CFLAGS) -I$(srcdir)/libglnx TESTS_LDADD = $(ostree_bin_shared_ldadd) $(OT_INTERNAL_GIO_UNIX_LIBS) @@ -211,3 +190,13 @@ EXTRA_DIST += \ tests/gpg-verify-data/secring.gpg \ tests/gpg-verify-data/trustdb.gpg \ tests/gpg-verify-data/gpg.conf + +# Unfortunately the glib test data APIs don't actually handle +# non-recursive Automake, so we change our code to canonically look +# for tests/ which is just a symlink when installed. +install-test-data-file-path-hack: + if test -L $(DESTDIR)$(installed_testdir)/tests; then \ + rm $(DESTDIR)$(installed_testdir)/tests; \ + fi + ln -s . $(DESTDIR)$(installed_testdir)/tests +INSTALL_DATA_HOOKS += install-test-data-file-path-hack diff --git a/Makefile.am b/Makefile.am index 1625419b..a485cc75 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,7 +19,7 @@ include Makefile-decls.am shortened_sysconfdir = $$(echo "$(sysconfdir)" | sed -e 's|^$(prefix)||' -e 's|^/||') -ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} +ACLOCAL_AMFLAGS = -I buildutil ${ACLOCAL_FLAGS} AM_CPPFLAGS += -DDATADIR='"$(datadir)"' -DLIBEXECDIR='"$(libexecdir)"' \ -DLOCALEDIR=\"$(datadir)/locale\" -DSYSCONFDIR=\"$(sysconfdir)\" \ -DSHORTENED_SYSCONFDIR=\"$(shortened_sysconfdir)\" \ @@ -100,12 +100,3 @@ release-tarball-embedded: $(embed_dependency) embedded-dependencies/libsoup; \ mv ostree-embeddeps-$${GITVERSION}.tar{.tmp,}; \ gzip -f ostree-embeddeps-$${GITVERSION}.tar - -check-local: - @echo " *** NOTE ***" - @echo " *** NOTE ***" - @echo " \"make check\" only runs a subset of OSTree's tests." - @echo " The other tests use: use https://live.gnome.org/GnomeGoals/InstalledTests" - @echo " To run them, ostree must be configured with --enable-installed-tests and installed" - @echo " *** NOTE ***" - @echo " *** NOTE ***" diff --git a/buildutil/glib-tap.mk b/buildutil/glib-tap.mk new file mode 100644 index 00000000..ac4329bf --- /dev/null +++ b/buildutil/glib-tap.mk @@ -0,0 +1,125 @@ +# GLIB - Library of useful C routines + +TESTS_ENVIRONMENT= \ + G_TEST_SRCDIR="$(abs_srcdir)" \ + G_TEST_BUILDDIR="$(abs_builddir)" \ + UNINSTALLEDTESTS=1 \ + G_DEBUG=gc-friendly \ + MALLOC_CHECK_=2 \ + MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256)) +LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/buildutil/tap-driver.sh +LOG_COMPILER = $(top_srcdir)/buildutil/tap-test + +TESTS = + +installed_test_LTLIBRARIES = +installed_test_PROGRAMS = +installed_test_SCRIPTS = +installed_test_DATA = +nobase_installed_test_DATA = + +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) +installed_test_DATA += $(test_data) $(installed_test_data) +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=env G_TEST_SRCDIR=$(installed_testdir) G_TEST_BUILDDIR=$(installed_testdir) $(installed_testdir)/$(notdir $<)' >> $@.tmp; \ + mv $@.tmp $@) + +CLEANFILES += $(installed_test_meta_DATA) +endif diff --git a/buildutil/glibtests.m4 b/buildutil/glibtests.m4 new file mode 100644 index 00000000..27e90246 --- /dev/null +++ b/buildutil/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/buildutil/tap-driver.sh b/buildutil/tap-driver.sh new file mode 100755 index 00000000..19aa531d --- /dev/null +++ b/buildutil/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/buildutil/tap-test b/buildutil/tap-test new file mode 100755 index 00000000..970b1c33 --- /dev/null +++ b/buildutil/tap-test @@ -0,0 +1,13 @@ +#! /bin/bash + +# run a GTest in tap mode. The test binary is passed as $1 + +srcd=$(cd $(dirname $1) && pwd) +bn=$(basename $1) +tempdir=$(mktemp -d) +function cleanup () { + rm "${tempdir}" -rf +} +trap cleanup EXIT +cd ${tempdir} +${srcd}/${bn} -k --tap diff --git a/cfg.mk b/cfg.mk index a0ce8fa3..5c3f0b40 100644 --- a/cfg.mk +++ b/cfg.mk @@ -1,4 +1,4 @@ -export VC_LIST_EXCEPT_DEFAULT=^(lib/.*|m4/.*|md5/.*|build-aux/.*|src/gettext\.h|.*ChangeLog)$$ +export VC_LIST_EXCEPT_DEFAULT=^(lib/.*|m4/.*|md5/.*|build-aux/.*|src/gettext\.h|.*ChangeLog|buildutil/.*)$$ local-checks-to-skip = \ sc_const_long_option \ diff --git a/configure.ac b/configure.ac index 0687ecdb..5dfc0b2b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ AC_PREREQ([2.63]) AC_INIT([ostree], [2016.3], [walters@verbum.org]) AC_CONFIG_HEADER([config.h]) -AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_MACRO_DIR([buildutil]) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([1.13 -Wno-portability foreign no-define tar-ustar no-dist-gzip dist-xz - color-tests parallel-tests subdir-objects]) + color-tests subdir-objects]) AM_MAINTAINER_MODE([enable]) AM_SILENT_RULES([yes]) AC_USE_SYSTEM_EXTENSIONS @@ -34,11 +34,7 @@ LT_INIT([disable-static]) OSTREE_FEATURES="" AC_SUBST([OSTREE_FEATURES]) -AC_ARG_ENABLE(installed_tests, - AS_HELP_STRING([--enable-installed-tests], - [Install test programs (default: no)]),, - [enable_installed_tests=no]) -AM_CONDITIONAL(BUILDOPT_INSTALL_TESTS, test x$enable_installed_tests = xyes) +GLIB_TESTS AC_CHECK_HEADER([sys/xattr.h],,[AC_MSG_ERROR([You must have sys/xattr.h from glibc])]) diff --git a/tests/admin-test.sh b/tests/admin-test.sh index c4644d3a..c60962b1 100755 --- a/tests/admin-test.sh +++ b/tests/admin-test.sh @@ -18,7 +18,7 @@ set -euo pipefail -echo "1..10" +echo "1..16" function validate_bootloader() { (cd ${test_tmpdir}; diff --git a/tests/basic-test.sh b/tests/basic-test.sh index df901e23..5e8ac5ed 100755 --- a/tests/basic-test.sh +++ b/tests/basic-test.sh @@ -19,7 +19,7 @@ set -euo pipefail -echo "1..48" +echo "1..49" $OSTREE checkout test2 checkout-test2 echo "ok checkout" diff --git a/tests/gpghome/pubring.gpg b/tests/gpghome/pubring.gpg new file mode 120000 index 00000000..3ada1d42 --- /dev/null +++ b/tests/gpghome/pubring.gpg @@ -0,0 +1 @@ +trusted/pubring.gpg \ No newline at end of file diff --git a/tests/libtest.sh b/tests/libtest.sh old mode 100644 new mode 100755 index 8cc4345f..4efbabbe --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -18,10 +18,35 @@ # Boston, MA 02111-1307, USA. SRCDIR=$(dirname $0) +_cleanup_tmpdir () { + if test -n "${LIBTEST_SKIP_CLEANUP:-}"; then + echo "Skipping cleanup of ${test_tmpdir}" + else if test -f ${test_tmpdir}/.test; then + rm ${test_tmpdir} -rf + fi + fi +} + +# If we're running as a local test (i.e. through `make check`), then +# UNINSTALLEDTESTS=1. Otherwise (i.e. as an installed test), it's undefined, in +# which case we're already in a tmpdir. +if test -n "${UNINSTALLEDTESTS:-}"; then + test_tmpdir=$(mktemp -d /var/tmp/test.XXXXXX) + touch ${test_tmpdir}/.test + trap _cleanup_tmpdir EXIT + cd ${test_tmpdir} + export PATH=${G_TEST_BUILDDIR}:${PATH} +fi + test_tmpdir=$(pwd) export G_DEBUG=fatal-warnings +# Also, unbreak `tar` inside `make check`...Automake will inject +# TAR_OPTIONS: --owner=0 --group=0 --numeric-owner presumably so that +# tarballs are predictable, except we don't want this in our tests. +unset TAR_OPTIONS + # Don't flag deployments as immutable so that test harnesses can # easily clean up. export OSTREE_SYSROOT_DEBUG=mutable-deployments @@ -33,6 +58,7 @@ export TEST_GPG_KEYID_3="DF444D67" # GPG when creating signatures demands a writable # homedir in order to create lockfiles. Work around # this by copying locally. +echo "Copying gpghome to ${test_tmpdir}" cp -a ${SRCDIR}/gpghome ${test_tmpdir} export TEST_GPG_KEYHOME=${test_tmpdir}/gpghome export OSTREE_GPG_HOME=${test_tmpdir}/gpghome/trusted diff --git a/tests/pull-test.sh b/tests/pull-test.sh index 74d4a73b..8e8a6934 100755 --- a/tests/pull-test.sh +++ b/tests/pull-test.sh @@ -35,6 +35,8 @@ function verify_initial_contents() { assert_file_has_content baz/cow '^moo$' } +echo "1..11" + # Try both syntaxes repo_init ${CMD_PREFIX} ostree --repo=repo pull origin main diff --git a/tests/test-admin-deploy-2.sh b/tests/test-admin-deploy-2.sh index ef6b5953..79e253bb 100755 --- a/tests/test-admin-deploy-2.sh +++ b/tests/test-admin-deploy-2.sh @@ -21,14 +21,10 @@ set -euo pipefail . $(dirname $0)/libtest.sh -echo "1..1" - # Exports OSTREE_SYSROOT so --sysroot not needed. setup_os_repository "archive-z2" "syslinux" -echo "ok setup" - -echo "1..2" +echo "1..3" ${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime) diff --git a/tests/test-admin-deploy-clean.sh b/tests/test-admin-deploy-clean.sh old mode 100644 new mode 100755 diff --git a/tests/test-admin-deploy-etcmerge-cornercases.sh b/tests/test-admin-deploy-etcmerge-cornercases.sh old mode 100644 new mode 100755 index 4b0d781b..10e7a438 --- a/tests/test-admin-deploy-etcmerge-cornercases.sh +++ b/tests/test-admin-deploy-etcmerge-cornercases.sh @@ -21,13 +21,9 @@ set -euo pipefail . $(dirname $0)/libtest.sh -echo "1..1" - # Exports OSTREE_SYSROOT so --sysroot not needed. setup_os_repository "archive-z2" "syslinux" -echo "ok setup" - echo "1..2" ${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime diff --git a/tests/test-admin-deploy-karg.sh b/tests/test-admin-deploy-karg.sh old mode 100644 new mode 100755 index a8c1e594..2ce88627 --- a/tests/test-admin-deploy-karg.sh +++ b/tests/test-admin-deploy-karg.sh @@ -21,14 +21,10 @@ set -euo pipefail . $(dirname $0)/libtest.sh -echo "1..1" - # Exports OSTREE_SYSROOT so --sysroot not needed. setup_os_repository "archive-z2" "syslinux" -echo "ok setup" - -echo "1..1" +echo "1..3" ${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime) diff --git a/tests/test-admin-deploy-switch.sh b/tests/test-admin-deploy-switch.sh index 4a52000c..0157e27b 100755 --- a/tests/test-admin-deploy-switch.sh +++ b/tests/test-admin-deploy-switch.sh @@ -21,14 +21,10 @@ set -euo pipefail . $(dirname $0)/libtest.sh -echo "1..1" - # Exports OSTREE_SYSROOT so --sysroot not needed. setup_os_repository "archive-z2" "syslinux" -echo "ok setup" - -echo "1..3" +echo "1..4" ${CMD_PREFIX} ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false testos file://$(pwd)/testos-repo ${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull testos testos/buildmaster/x86_64-runtime diff --git a/tests/test-admin-deploy-syslinux.sh b/tests/test-admin-deploy-syslinux.sh index 5883f76d..419df2ba 100755 --- a/tests/test-admin-deploy-syslinux.sh +++ b/tests/test-admin-deploy-syslinux.sh @@ -21,11 +21,7 @@ set -euo pipefail . $(dirname $0)/libtest.sh -echo "1..1" - # Exports OSTREE_SYSROOT so --sysroot not needed. setup_os_repository "archive-z2" "syslinux" -echo "ok setup" - . $(dirname $0)/admin-test.sh diff --git a/tests/test-admin-deploy-uboot.sh b/tests/test-admin-deploy-uboot.sh index c22af6f3..b998e082 100755 --- a/tests/test-admin-deploy-uboot.sh +++ b/tests/test-admin-deploy-uboot.sh @@ -22,11 +22,7 @@ set -euo pipefail . $(dirname $0)/libtest.sh -echo "1..1" - # Exports OSTREE_SYSROOT so --sysroot not needed. setup_os_repository "archive-z2" "uboot" -echo "ok setup" - . $(dirname $0)/admin-test.sh diff --git a/tests/test-admin-instutil-set-kargs.sh b/tests/test-admin-instutil-set-kargs.sh old mode 100644 new mode 100755 index 33b2b74e..0af940ff --- a/tests/test-admin-instutil-set-kargs.sh +++ b/tests/test-admin-instutil-set-kargs.sh @@ -22,13 +22,9 @@ set -euo pipefail . $(dirname $0)/libtest.sh -echo "1..1" - # Exports OSTREE_SYSROOT so --sysroot not needed. setup_os_repository "archive-z2" "syslinux" -echo "ok setup" - echo "1..5" ${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime diff --git a/tests/test-admin-locking.sh b/tests/test-admin-locking.sh old mode 100644 new mode 100755 index 5f00f571..564295d2 --- a/tests/test-admin-locking.sh +++ b/tests/test-admin-locking.sh @@ -21,12 +21,14 @@ set -euo pipefail . $(dirname $0)/libtest.sh -echo "1..1" - # Exports OSTREE_SYSROOT so --sysroot not needed. setup_os_repository "archive-z2" "syslinux" -echo "ok setup" +# If parallel is not installed, skip the test +if ! parallel --help >/dev/null 2>&1; then + echo "1..0 # SKIP no /usr/bin/parallel" + exit 0 +fi echo "1..1" @@ -40,9 +42,6 @@ echo "rev=${rev}" ${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime assert_has_dir sysroot/boot/ostree/testos-${bootcsum} -# If parallel is not installed, skip the test -parallel --help >/dev/null 2>&1 || exit 77 - parallel_cmd=parallel if parallel --help | grep -q -e --no-notice; then parallel_cmd="${parallel_cmd} --no-notice" diff --git a/tests/test-admin-pull-deploy-commit.sh b/tests/test-admin-pull-deploy-commit.sh old mode 100644 new mode 100755 diff --git a/tests/test-admin-upgrade-not-backwards.sh b/tests/test-admin-upgrade-not-backwards.sh old mode 100644 new mode 100755 index 1b99e25d..fd1e1108 --- a/tests/test-admin-upgrade-not-backwards.sh +++ b/tests/test-admin-upgrade-not-backwards.sh @@ -21,13 +21,9 @@ set -euo pipefail . $(dirname $0)/libtest.sh -echo "1..1" - # Exports OSTREE_SYSROOT so --sysroot not needed. setup_os_repository "archive-z2" "syslinux" -echo "ok setup" - echo "1..2" cd ${test_tmpdir} diff --git a/tests/test-admin-upgrade-unconfigured.sh b/tests/test-admin-upgrade-unconfigured.sh old mode 100644 new mode 100755 index 38df710d..c952356e --- a/tests/test-admin-upgrade-unconfigured.sh +++ b/tests/test-admin-upgrade-unconfigured.sh @@ -21,13 +21,9 @@ set -euo pipefail . $(dirname $0)/libtest.sh -echo "1..1" - # Exports OSTREE_SYSROOT so --sysroot not needed. setup_os_repository "archive-z2" "syslinux" -echo "ok setup" - echo "1..2" ${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime diff --git a/tests/test-archivez.sh b/tests/test-archivez.sh index 5db973ff..999157de 100755 --- a/tests/test-archivez.sh +++ b/tests/test-archivez.sh @@ -24,7 +24,6 @@ set -euo pipefail echo '1..11' setup_test_repository "archive-z2" -echo "ok setup" . ${SRCDIR}/archive-test.sh diff --git a/tests/test-auto-summary.sh b/tests/test-auto-summary.sh index 6cb52e8c..6039f526 100755 --- a/tests/test-auto-summary.sh +++ b/tests/test-auto-summary.sh @@ -20,7 +20,7 @@ set -euo pipefail -echo "1..1" +echo "1..4" . $(dirname $0)/libtest.sh diff --git a/tests/test-basic.sh b/tests/test-basic.sh index ae55aab2..d1afe75f 100755 --- a/tests/test-basic.sh +++ b/tests/test-basic.sh @@ -19,11 +19,8 @@ set -euo pipefail -echo "1..1" - . $(dirname $0)/libtest.sh setup_test_repository "bare" -echo "ok setup" . $(dirname $0)/basic-test.sh diff --git a/tests/test-commit-sign.sh b/tests/test-commit-sign.sh index 2db671ee..8d52bcaf 100755 --- a/tests/test-commit-sign.sh +++ b/tests/test-commit-sign.sh @@ -20,11 +20,14 @@ set -euo pipefail if ! ostree --version | grep -q -e '\+gpgme'; then - exit 77 + echo "1..0 #SKIP no gpg support compiled in" + exit 0 fi . $(dirname $0)/libtest.sh +echo "1..1" + keyid="472CDAFA" oldpwd=`pwd` mkdir ostree-srv @@ -122,10 +125,12 @@ assert_file_has_content show 'Found 1 signature' # Delete the signature from the commit so the detached metadata is empty, # then pull and verify the signature is also deleted on the client side. -${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo gpg-sign --gpg-homedir=${SRCDIR}/gpghome --delete main $keyid +${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo gpg-sign --gpg-homedir=${test_tmpdir}/gpghome --delete main $keyid ${CMD_PREFIX} ostree --repo=repo pull origin main if ${CMD_PREFIX} ostree --repo=repo show main | grep -o 'Found [[:digit:]] signature'; then assert_not_reached fi rm -rf repo gnomerepo-files + +echo "ok" diff --git a/tests/test-delta.sh b/tests/test-delta.sh index ebe35571..12f54c7d 100755 --- a/tests/test-delta.sh +++ b/tests/test-delta.sh @@ -24,7 +24,7 @@ set -euo pipefail bindatafiles="bash true ostree" morebindatafiles="false ls" -echo '1..3' +echo '1..7' mkdir repo ${CMD_PREFIX} ostree --repo=repo init --mode=archive-z2 diff --git a/tests/test-gpg-signed-commit.sh b/tests/test-gpg-signed-commit.sh old mode 100644 new mode 100755 index b713da2d..a0bf9832 --- a/tests/test-gpg-signed-commit.sh +++ b/tests/test-gpg-signed-commit.sh @@ -21,11 +21,14 @@ set -euo pipefail if ! ostree --version | grep -q -e '\+gpgme'; then - exit 77 + echo "1..0 #SKIP no gpgme support compiled in" + exit 0 fi . $(dirname $0)/libtest.sh +echo "1..1" + setup_test_repository "archive-z2" export OSTREE_GPG_SIGN="${OSTREE} gpg-sign --gpg-homedir=${TEST_GPG_KEYHOME}" @@ -74,3 +77,5 @@ assert_file_has_content test2-delete 'Signatures deleted: 2' if ${OSTREE} show test2 | grep -o 'Found [[:digit:]] signature'; then assert_not_reached fi + +echo "ok" diff --git a/tests/test-gpg-verify-result.c b/tests/test-gpg-verify-result.c index fe22dc30..e2cb48a7 100644 --- a/tests/test-gpg-verify-result.c +++ b/tests/test-gpg-verify-result.c @@ -66,7 +66,7 @@ test_fixture_setup (TestFixture *fixture, * taken into account, which contains additional data like revocation * certificates for certain test cases. */ - homedir = g_test_build_filename (G_TEST_DIST, "gpg-verify-data", NULL); + homedir = g_test_build_filename (G_TEST_DIST, "tests/gpg-verify-data", NULL); g_setenv ("GNUPGHOME", homedir, TRUE); result = g_initable_new (OSTREE_TYPE_GPG_VERIFY_RESULT, diff --git a/tests/test-libarchive.sh b/tests/test-libarchive.sh index 92e24083..7309ffd2 100755 --- a/tests/test-libarchive.sh +++ b/tests/test-libarchive.sh @@ -20,13 +20,14 @@ set -euo pipefail if ! ostree --version | grep -q -e '\+libarchive'; then - exit 77 + echo "1..0 #SKIP no libarchive support compiled in" + exit 0 fi -echo "1..7" - . $(dirname $0)/libtest.sh +echo "1..7" + setup_test_repository "bare" cd ${test_tmpdir} mkdir foo diff --git a/tests/test-oldstyle-partial.sh b/tests/test-oldstyle-partial.sh old mode 100644 new mode 100755 index 220b0831..a578e7d2 --- a/tests/test-oldstyle-partial.sh +++ b/tests/test-oldstyle-partial.sh @@ -35,3 +35,5 @@ ${CMD_PREFIX} ostree --repo=repo pull origin main --subpath /baz ${CMD_PREFIX} ostree fsck --repo=repo >fsck.out assert_file_has_content fsck.out 'Verifying content integrity of 0 commit objects' assert_file_has_content fsck.out '1 partial commits not verified' + +echo "ok" diff --git a/tests/test-prune.sh b/tests/test-prune.sh old mode 100644 new mode 100755 diff --git a/tests/test-pull-archive-z.sh b/tests/test-pull-archive-z.sh index 6482f6f9..2ea23871 100755 --- a/tests/test-pull-archive-z.sh +++ b/tests/test-pull-archive-z.sh @@ -23,6 +23,4 @@ set -euo pipefail setup_fake_remote_repo1 "archive-z2" -echo '1..2' - . ${SRCDIR}/pull-test.sh diff --git a/tests/test-pull-depth.sh b/tests/test-pull-depth.sh old mode 100644 new mode 100755 diff --git a/tests/test-pull-large-metadata.sh b/tests/test-pull-large-metadata.sh old mode 100644 new mode 100755 index c50d7943..0fe02031 --- a/tests/test-pull-large-metadata.sh +++ b/tests/test-pull-large-metadata.sh @@ -39,3 +39,5 @@ if ${CMD_PREFIX} ostree --repo=repo pull origin main 2>pulllog.txt 1>&2; then assert_not_reached "pull unexpectedly succeeded!" fi assert_file_has_content pulllog.txt "exceeded maximum" + +echo "ok" diff --git a/tests/test-pull-metalink.sh b/tests/test-pull-metalink.sh index 52d2d503..2a1a73e7 100755 --- a/tests/test-pull-metalink.sh +++ b/tests/test-pull-metalink.sh @@ -23,6 +23,8 @@ set -euo pipefail setup_fake_remote_repo1 "archive-z2" +echo '1..9' + # And another web server acting as the metalink server cd ${test_tmpdir} mkdir metalink-data @@ -37,7 +39,6 @@ summary_path=${test_tmpdir}/ostree-srv/gnomerepo/summary echo -n broken > ${summary_path}.bad -echo '1..1' cd ${test_tmpdir} cat > metalink-valid-summary.xml </dev/null 2>&1; then assert_not_reached "(key3/R2) GPG verification unexpectedly succeeded" fi ${OSTREE} pull R3:main >/dev/null + +echo "ok" diff --git a/tests/test-repo-checkout-subpath.sh b/tests/test-repo-checkout-subpath.sh index bf792184..2da5adc2 100755 --- a/tests/test-repo-checkout-subpath.sh +++ b/tests/test-repo-checkout-subpath.sh @@ -23,12 +23,13 @@ set -euo pipefail . $(dirname $0)/libtest.sh setup_test_repository "bare" -echo "ok setup" -echo '1..2' +echo '1..1' repopath=${test_tmpdir}/ostree-srv/gnomerepo ${CMD_PREFIX} ostree --repo=repo checkout -U --subpath=/ test2 checkedout ${CMD_PREFIX} ostree --repo=repo checkout -U --subpath=/firstfile test2 checkedout2 + +echo "ok" diff --git a/tests/test-setuid.sh b/tests/test-setuid.sh index 5354d1f3..edf707df 100755 --- a/tests/test-setuid.sh +++ b/tests/test-setuid.sh @@ -36,3 +36,5 @@ chmod a+x test2-checkout/abinary rm -rf test2-checkout $OSTREE checkout test2 test2-checkout test -u test2-checkout/abinary + +echo "ok" diff --git a/tests/test-sysroot.js b/tests/test-sysroot.js index fc8e91fd..9468d2fb 100644 --- a/tests/test-sysroot.js +++ b/tests/test-sysroot.js @@ -34,7 +34,7 @@ function assertNotEquals(a, b) { } function libtestExec(shellCode) { - let testdatadir = GLib.getenv("TESTDATADIR"); + let testdatadir = GLib.getenv("G_TEST_SRCDIR"); let libtestPath = GLib.build_filenamev([testdatadir, 'libtest.sh']) let proc = GSystem.Subprocess.new_simple_argv(['bash', '-c', '. ' + GLib.shell_quote(libtestPath) + '; ' + shellCode],