xref: /freebsd/bin/ed/test/ckscripts.sh (revision 7899f917b1c0ea178f1d2be0cfb452086d079d23)
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
7PATH="/bin:/usr/bin:/usr/local/bin/:."
8ED=$1
9[ ! -x $ED ] && { echo "$ED: cannot execute"; exit 1; }
10
11# Run the *.red scripts first, since these don't generate output;
12# they exit with non-zero status
13for i in *.red; do
14	echo $i
15	if $i; then
16		echo "*** The script $i exited abnormally  ***"
17	fi
18done >errs.o 2>&1
19
20# Run the remainding scripts; they exit with zero status
21for i in *.ed; do
22#	base=`expr $i : '\([^.]*\)'`
23#	base=`echo $i | sed 's/\..*//'`
24	base=`$ED - \!"echo $i" <<-EOF
25		s/\..*
26	EOF`
27	if $base.ed; then
28		if cmp -s $base.o $base.r; then :; else
29			echo "*** Output $base.o of script $i is incorrect ***"
30		fi
31	else
32		echo "*** The script $i exited abnormally ***"
33	fi
34done >scripts.o 2>&1
35
36grep -h '\*\*\*' errs.o scripts.o
37