#!/bin/sh # Shell script #2 used to test MINIX. setglobal PATH = ':/bin:/usr/bin' export PATH # CC="exec cc -wo -F" # nonstandard flags for ACK :-( setglobal CC = 'cc' setglobal ARCH = $[arch] echo -n "Shell test 2 " rm -rf DIR_SH2 mkdir DIR_SH2 # all files are created here cd DIR_SH2 cat >file <makefile </dev/null 2>&1 END cat >x.c < char s[] = {"MS-DOS: Just say no"}; /* used by strings later */ main() { int i; for (i = 15; i < 18; i++) printf("%d\\n",i*i); } END cat >answer <x if test -f x { : ; } else { echo No compiler output; } if cmp -s x answer { : ; } else { echo Error in cc test 1; } #Test chmod echo Hi there folks >x if test -r x { : ; } else { echo Error on chmod test 1; } chmod 377 x if test -r x { test -w / || echo Error on chmod test 2; } chmod 700 x if test -r x { : ; } else { echo Error on chmod test 3; } #Test cut cat >x <answer <y # extract columns 3-7 if cmp -s y answer { : ; } else { echo Error in cut test 1; } #Test dd dd if=$f of=x bs=12 count=1 2>/dev/null # x = bytes 0-11 dd if=$f of=y bs=6 count=4 skip=2 2>/dev/null # y = bytes 11-35 cat x y >z # z = bytes 0-35 dd if=$f of=answer bs=9 count=4 2>/dev/null # answer = bytes 0-35 if cmp -s z answer { : ; } else { echo Error in dd test 1; } #Test df # hard to make a sensible Test here rm ? df >x if test -r x { : ; } else { echo Error in df Test 1; } #Test du # see df rm ? du >x if test -r x { : ; } else { echo Error in du Test 1; } #Test od head -1 $f |od >x # see if od converts ascii to octal ok if test $ARCH = i86 -o $ARCH = i386 { cat >answer <answer <x # see if od converts ascii to decimal ok if test $ARCH = i86 -o $ARCH = i386 { cat >answer <answer <x <y <answer <z if cmp -s z answer { : ; } else { echo Error in paste test 1; } #Test prep echo >x <answer <x if grep HOME x >/dev/null { : ; } else { echo Error in printenv test 1; } if grep PATH x >/dev/null { : ; } else { echo Error in printenv test 2; } if grep SHELL x >/dev/null { : ; } else { echo Error in printenv test 3; } if grep USER x >/dev/null { : ; } else { echo Error in printenv test 4; } #Test pwd pwd >Pwd_file cd $[pwd] pwd >x if test -s Pwd_file { : ; } else { echo Error in pwd test 1; } if cmp -s Pwd_file x { : ; } else { echo Error in pwd test 2; } #Test strings strings a.out | grep "MS-DOS" >x cat >answer <x cat >answer </dev/null if cmp -s x $f { : ; } else { echo Error in tee test 1; } #Test true if true { : ; } else { echo Error in true test 1; } #Test uniq cat >x <answer <y if cmp -s y answer { : ; } else { echo Error in uniq test 1; } #Test pipelines cat >x <answer <y1 sort +1 y if cmp -s y answer { : ; } else { echo Error in pipeline test 1; } cat $f $f $f | sort | uniq >x sort <$f >y if cmp -s x y { : ; } else { echo Error in pipeline test 2; } cd .. rm -rf DIR_SH2 echo ok