xref: /dragonfly/bin/ed/test/ckscripts.sh (revision 0dace59e)
1#!/bin/sh -
2# This script runs the .ed scripts generated by mkscripts.sh
3# and compares their output against the .r files, which contain
4# the correct output
5#
6# $FreeBSD: src/bin/ed/test/ckscripts.sh,v 1.6 1999/08/27 23:14:18 peter Exp $
7# $DragonFly: src/bin/ed/test/ckscripts.sh,v 1.2 2003/06/17 04:22:50 dillon Exp $
8
9PATH="/bin:/usr/bin:/usr/local/bin/:."
10ED=$1
11[ ! -x $ED ] && { echo "$ED: cannot execute"; exit 1; }
12
13# Run the *.red scripts first, since these don't generate output;
14# they exit with non-zero status
15for i in *.red; do
16	echo $i
17	if $i; then
18		echo "*** The script $i exited abnormally  ***"
19	fi
20done >errs.o 2>&1
21
22# Run the remainding scripts; they exit with zero status
23for i in *.ed; do
24#	base=`expr $i : '\([^.]*\)'`
25#	base=`echo $i | sed 's/\..*//'`
26	base=`$ED - \!"echo $i" <<-EOF
27		s/\..*
28	EOF`
29	if $base.ed; then
30		if cmp -s $base.o $base.r; then :; else
31			echo "*** Output $base.o of script $i is incorrect ***"
32		fi
33	else
34		echo "*** The script $i exited abnormally ***"
35	fi
36done >scripts.o 2>&1
37
38grep -h '\*\*\*' errs.o scripts.o
39