1#! /bin/sh 2# Copyright (C) 2011-2021 Free Software Foundation, Inc. 3# 4# This program is free software; you can redistribute it and/or modify 5# it under the terms of the GNU General Public License as published by 6# the Free Software Foundation; either version 2, or (at your option) 7# any later version. 8# 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with this program. If not, see <https://www.gnu.org/licenses/>. 16 17# Check that an example given in the documentation really works. 18# See section "Simple Tests" subsection "Script-based Testsuites". 19 20. test-init.sh 21 22fetch_tap_driver 23 24cat >> configure.ac <<END 25AC_PROG_CC 26AC_OUTPUT 27END 28 29cat > Makefile.am << 'END' 30TESTS = foo.sh zardoz.tap bar.sh mu.tap 31TEST_EXTENSIONS = .sh .tap 32TAP_LOG_DRIVER = $(srcdir)/tap-driver 33## Ensure the test scripts are run in the correct order. 34mu.log: bar.log 35bar.log: zardoz.log 36zardoz.log: foo.log 37END 38 39cat > foo.sh <<'END' 40#!/bin/sh 41exit 0 42END 43 44cat > bar.sh <<'END' 45#!/bin/sh 46exit 77 47END 48 49cat > zardoz.tap << 'END' 50#!/bin/sh 51echo 1..4 52echo 'ok 1 - Daemon started' 53echo 'ok 2 - Daemon responding' 54echo 'ok 3 - Daemon uses /proc # SKIP /proc is not mounted' 55echo 'ok 4 - Daemon stopped' 56END 57 58cat > mu.tap << 'END' 59#!/bin/sh 60echo 1..2 61echo 'ok' 62echo 'not ok # TODO frobnication not yet implemented' 63END 64 65chmod a+x *.sh *.tap 66 67$ACLOCAL 68$AUTOCONF 69$AUTOMAKE -a 70 71./configure 72 73run_make -O check 74 75cat > exp <<'END' 76PASS: foo.sh 77PASS: zardoz.tap 1 - Daemon started 78PASS: zardoz.tap 2 - Daemon responding 79SKIP: zardoz.tap 3 - Daemon uses /proc # SKIP /proc is not mounted 80PASS: zardoz.tap 4 - Daemon stopped 81SKIP: bar.sh 82PASS: mu.tap 1 83XFAIL: mu.tap 2 # TODO frobnication not yet implemented 84END 85 86sed -n '/^PASS: foo\.sh/,/^XFAIL: mu\.tap/p' stdout > t 87cat t 88# Strip extra "informative" lines that could be printed by Solaris 89# Distributed Make. 90LC_ALL=C $EGREP -v ' --> ([0-9][0-9]* job|[Jj]ob output)' t > got 91 92cat exp 93cat got 94diff exp got 95 96: 97