From 18c730e7f67f1d8a5bd3ab96aeb0db9cba07b058 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Fri, 6 Nov 2015 16:10:04 +0100 Subject: [PATCH] build: use a custom test driver Use a custom test driver for running the tests: based on the test-driver provided by automake, it adds the running time of the test in each .trs file. --- .gitignore | 12 ++- build-aux/guestfs-test-driver | 141 ++++++++++++++++++++++++++++++++++ configure.ac | 1 + subdir-rules.mk | 2 + 4 files changed, 155 insertions(+), 1 deletion(-) create mode 100755 build-aux/guestfs-test-driver diff --git a/.gitignore b/.gitignore index ebccae78b..a43c24386 100644 --- a/.gitignore +++ b/.gitignore @@ -56,7 +56,17 @@ Makefile.in /bash/virt-ls /bash/virt-sysprep /bash/virt-sparsify -/build-aux +/build-aux/.gitignore +/build-aux/compile +/build-aux/config.guess +/build-aux/config.sub +/build-aux/depcomp +/build-aux/install-sh +/build-aux/ltmain.sh +/build-aux/missing +/build-aux/snippet/ +/build-aux/test-driver +/build-aux/ylwrap /builder/.depend /builder/index-parse.c /builder/index-parse.h diff --git a/build-aux/guestfs-test-driver b/build-aux/guestfs-test-driver new file mode 100755 index 000000000..8aeb837b6 --- /dev/null +++ b/build-aux/guestfs-test-driver @@ -0,0 +1,141 @@ +#! /bin/sh +# test-driver - basic testsuite driver script. + +scriptversion=2013-07-13.22; # UTC + +# Copyright (C) 2011-2015 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 +# . + +# Make unconditional expansion of undefined variables an error. This +# helps a lot in preventing typo-related bugs. +set -u + +usage_error () +{ + echo "$0: $*" >&2 + print_usage >&2 + exit 2 +} + +print_usage () +{ + cat <$log_file 2>&1 +estatus=$? +end_t="$(date +'%s')" + +if test $enable_hard_errors = no && test $estatus -eq 99; then + tweaked_estatus=1 +else + tweaked_estatus=$estatus +fi + +case $tweaked_estatus:$expect_failure in + 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; + 0:*) col=$grn res=PASS recheck=no gcopy=no;; + 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; + 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;; + *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;; + *:*) col=$red res=FAIL recheck=yes gcopy=yes;; +esac + +# Report the test outcome and exit status in the logs, so that one can +# know whether the test passed or failed simply by looking at the '.log' +# file, without the need of also peaking into the corresponding '.trs' +# file (automake bug#11814). +echo "$res $test_name (exit status: $estatus)" >>$log_file + +# Report outcome to console. +echo "${col}${res}${std}: $test_name" + +# Register the test result, and other relevant metadata. +echo ":test-result: $res" > $trs_file +echo ":global-test-result: $res" >> $trs_file +echo ":recheck: $recheck" >> $trs_file +echo ":copy-in-global-log: $gcopy" >> $trs_file +echo ":guestfs-time: $(($end_t - $start_t))" >> $trs_file diff --git a/configure.ac b/configure.ac index f1a31b373..fc8858e3b 100644 --- a/configure.ac +++ b/configure.ac @@ -29,6 +29,7 @@ dnl the website 'index.html' file. AC_SUBST([RELEASE_DATE], [2015-11-04]) AC_CONFIG_AUX_DIR([build-aux]) +AC_REQUIRE_AUX_FILE([guestfs-test-driver]) dnl Initialize automake. AM_INIT_AUTOMAKE(foreign subdir-objects) dnl NB: Do not [quote] this parameter. diff --git a/subdir-rules.mk b/subdir-rules.mk index 92d4bda7b..7582ec78b 100644 --- a/subdir-rules.mk +++ b/subdir-rules.mk @@ -40,3 +40,5 @@ $(top_builddir)/generator/generator: else \ echo "warning: Run 'make' at the top level to build $@"; \ fi + +LOG_DRIVER = env $(SHELL) $(top_srcdir)/build-aux/guestfs-test-driver