xref: /freebsd/bin/ed/test/ckscripts.sh (revision d0b2dbfa)
130154ac8SAndrew Moore#!/bin/sh -
230154ac8SAndrew Moore# This script runs the .ed scripts generated by mkscripts.sh
330154ac8SAndrew Moore# and compares their output against the .r files, which contain
430154ac8SAndrew Moore# the correct output
5148531efSWolfram Schneider#
630154ac8SAndrew Moore
730154ac8SAndrew MoorePATH="/bin:/usr/bin:/usr/local/bin/:."
830154ac8SAndrew MooreED=$1
930154ac8SAndrew Moore[ ! -x $ED ] && { echo "$ED: cannot execute"; exit 1; }
1030154ac8SAndrew Moore
1195e6217eSAndrew Moore# Run the *.red scripts first, since these don't generate output;
1295e6217eSAndrew Moore# they exit with non-zero status
1395e6217eSAndrew Moorefor i in *.red; do
1495e6217eSAndrew Moore	echo $i
1530154ac8SAndrew Moore	if $i; then
1695e6217eSAndrew Moore		echo "*** The script $i exited abnormally  ***"
1730154ac8SAndrew Moore	fi
1830154ac8SAndrew Mooredone >errs.o 2>&1
1930154ac8SAndrew Moore
2030154ac8SAndrew Moore# Run the remainding scripts; they exit with zero status
2130154ac8SAndrew Moorefor i in *.ed; do
2295e6217eSAndrew Moore#	base=`expr $i : '\([^.]*\)'`
2330154ac8SAndrew Moore#	base=`echo $i | sed 's/\..*//'`
2495e6217eSAndrew Moore	base=`$ED - \!"echo $i" <<-EOF
2595e6217eSAndrew Moore		s/\..*
2695e6217eSAndrew Moore	EOF`
2730154ac8SAndrew Moore	if $base.ed; then
2830154ac8SAndrew Moore		if cmp -s $base.o $base.r; then :; else
2930154ac8SAndrew Moore			echo "*** Output $base.o of script $i is incorrect ***"
3030154ac8SAndrew Moore		fi
3130154ac8SAndrew Moore	else
3230154ac8SAndrew Moore		echo "*** The script $i exited abnormally ***"
3330154ac8SAndrew Moore	fi
3430154ac8SAndrew Mooredone >scripts.o 2>&1
3530154ac8SAndrew Moore
3630154ac8SAndrew Mooregrep -h '\*\*\*' errs.o scripts.o
37