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