1#!/bin/sh 2# 3# Add2TestDB -- add the current test to the lsof test suite DB 4# 5# This script saves the current TestDB file in TestDB.old and adds 6# the words in config.cflags to it. "-D" prefixes on the words are 7# removed, the words are sorted, and they are joint in a single 8# line that is catenated to TestDB if it isn't already there. 9# 10# $Id: Add2TestDB,v 1.2 2002/04/19 11:53:37 abe Exp $ 11 12# Check for config.flags. 13 14if test ! -r config.cflags 15then 16 echo "$0: no ./config.cflags file" 17 exit 1 18fi 19 20# Check for a current data base file. 21 22if test ! -r TestDB 23then 24 echo "$0: no ./TestDB file" 25 exit 1 26fi 27 28# Form a new data base line. 29 30new="" 31for i in `sort < config.cflags` 32do 33 w=`echo $i | sed 's/^-D//'` 34 if test "X$new" = "X" 35 then 36 new=$w 37 else 38 new="$new $w" 39 fi 40done 41 42# See if the new line is already in the data base. 43 44grep "$new" TestDB > /dev/null 2>&1 45if test $? -eq 0 46then 47 echo "\"$new\" is already in TestDB." 48 exit 1 49fi 50 51# Build a new data base file. 52 53if test ! -w TestDB 54then 55 echo "$0: can't write the following to the end of TestDB:" 56 echo " \"$new\"" 57 exit 1 58fi 59rm -f TestDB.new 60cp TestDB TestDB.new 61chmod 644 TestDB.new 62echo "$new" >> TestDB.new 63 64# Archive the current data base file, if possible. 65 66if test -d OLD 67then 68 dt=`date` 69 dtm="========== $dt ==========" 70 if test -r OLD/TestDB 71 then 72 echo "$dtm" >> OLD/TestDB 73 else 74 echo "$dtm" > OLD/TestDB 75 fi 76 cat TestDB >> OLD/TestDB 77fi 78 79# Put the new data base file in place. 80 81mv TestDB.new TestDB 82echo "\"$new\" added to TestDB." 83exit 0 84