4.4BSD/usr/src/usr.bin/f77/tests/testf77

#!/bin/sh -
#
# Copyright (c) 1980 The Regents of the University of California.
# All rights reserved.
#
# This module is believed to contain source code proprietary to AT&T.
# Use and redistribution is subject to the Berkeley Software License
# Agreement and your Software Agreement with AT&T (Western Electric).
#
#	@(#)testf77	5.2 (Berkeley) 4/12/91
#

# This script will compile and test all of the f77 certification
# tests in then given fcvs directories

: ${FC=f77}
: ${FFLAGS=-Ns500}
export FC
export FFLAGS

   cd tests

   # Cleanup unnecessary files
   rm -f *.o *.out
   
   ls f* | sort +0.2 | awk '
   # This awk program will create a script that will compile and run
   # each fm program. Input will be in the order of number (???) then by:
   #         data if any  fd???
   #         main program fm???.f
   #         subroutines  fs???.f ...
   BEGIN {
      last = -1
      input = -1
      working = "false"
      print "# Trap any signals causing termination of execution"
      print "trap \""
      print "   echo @@@@@@@@@@@@@@@@@@@@@@"
      print "   echo @@                  @@"
      print "   echo @@ Execution failed @@"
      print "   echo @@                  @@"
      print "   echo @@@@@@@@@@@@@@@@@@@@@@"
      print "   \" 3 4 5 6 7 8 10 12 13 14 15 16"
      print " "
	  print "# Trap user interrupt"
	  print "trap \""
      print "   echo @@@@@@@@@@@@@@@@"
      print "   echo @@            @@"
      print "   echo @@ INTERRUPT  @@"
      print "   echo @@            @@"
      print "   echo @@@@@@@@@@@@@@@@"
      print "   \" 1 2"
      }
   
   /f[dm]/ && working == "true" {
      printf "-o %s \n", runfile
      printf "%s ", runfile
      if (substr (input, 3, 3) == substr (runfile, 3, 3))
         printf "< %s ", input
      print " "
      print "case $? in"
      print "   0) echo " runfile " completed successfully.;;"
      print "   *) echo " runfile " had a return code of $?.;;"
      print "esac"
      print "rm -f *.o *.out"
      working = "false"
      }
   
   /fd/ {
      input = $1
      }
   
   /fm/ {
      print " "
      print "echo -page-"
      printf "echo ===== Testing %s =====\n", $1
      printf "${FC} ${FFLAGS} %s ", $1
      working = "true"
      runfile = sprintf ("%s.out", substr ($1, 1, 5))
      }
   /fs/ {
      printf "%s ", $1
      }
   
   END {
      printf "-o %s \n", runfile
      printf "%s ", runfile
      if (substr (input, 3, 3) == substr (runfile, 3, 3))
         printf "< %s ", input
      print " "
      print "case $? in"
      print "   0) echo " runfile " completed successfully.;;"
      print "   *) echo " runfile " had a return code of $?.;;"
      print "esac"
      print "rm -f *.o *.out"
      print "\n# Script is complete."
      }
   ' > tst$$
   
   # Now execute the script we created.
   sh tst$$ 2>&1
   rm tst$$
   echo ===== test is complete =====