import source from 4.82
[external/lsof.git] / tests / CkTestDB
1 #!/bin/sh
2 #
3 # CkTestDB -- see if this dialect is has been tested
4 #
5 # This script builds a line from config.flags in the form of lines in
6 # ./TestDB,  (See Add2TestDB.)
7 #
8 # It then compares the line to TestDB.  If the line is found, the script
9 # exits.  if the line is not found, the script issues a warning and requests
10 # a go-ahead confirmation.
11 #
12 # The script will exit 0 if the test line is in the DB or the go-ahead
13 # confirmation is positive.
14 #
15 # $Id: CkTestDB,v 1.2 2002/04/19 11:54:00 abe Exp $
16
17 # Check for config.flags.
18
19 if test ! -r config.cflags
20 then
21   echo "$0: no ./config.cflags file"
22   exit 1
23 fi
24
25 # Check for a current data base file.
26
27 if test ! -r TestDB
28 then
29   echo "$0: no ./TestDB file"
30   exit 1
31 fi
32
33 # Form a data base line.
34
35 new=""
36 for i in `sort < config.cflags`
37 do
38   w=`echo $i | sed 's/^-D//'`
39   if test "X$new" = "X"
40   then
41     new=$w
42   else
43     new="$new $w"
44   fi
45 done
46
47 # See if the line is already in the data base.  Exit with success (0), if it is.
48
49 grep "^$new\$" TestDB > /dev/null 2>&1
50 if test $? -eq 0
51 then
52   exit 0
53 fi
54
55 # This dialect may never have been validated with the test suite.
56
57 # If the standard input is not a TTY, quit, because no interaction
58 # is possible.
59
60 tty -s > /dev/null 2>&1
61 if test $? -ne 0
62 then
63   echo ""
64   echo "This suite has not been validated on:"
65   echo ""
66   echo "     $new"
67   echo ""
68   exit 1
69 fi
70
71 # Establish trap and stty handling.
72
73 ISIG=":"
74 trap '$ISIG; exit 1'  1 2 3 15
75 stty -a 2>&1 | grep isig > /dev/null
76 if test $? -eq 0
77 then
78   stty -a 2>&1 | egrep -e -isig > /dev/null
79   if test $? -eq 0
80   then
81     ISIG="stty -isig"
82     stty isig
83   fi
84 fi
85
86 # Establish echo type -- Berkeley or SYSV.
87
88 j=`echo -n ""`
89 if test "X$j" = "X-n "
90 then
91   EC="\c"
92   EO=""
93 else
94   EC=""
95   EO="-n"
96 fi
97
98 # Display a validation warning.
99
100 cat << .CAT_MARK > /dev/tty
101
102 ==================================================================
103
104 !!!WARNING!!!
105
106 This dialect or its particular version may not have been validated
107 with the lsof test suite.  Consequently some tests may fail or may
108 not even compile.
109
110 This is the computed identity of this dialect, not found in the
111 test data base file, ./TestDB:
112
113 .CAT_MARK
114 echo "    $new" > /dev/tty
115 END=0
116 while test $END = 0
117 do
118   echo "" > /dev/tty
119   echo $EO "Do you want to continue (y|n) [n]? $EC" > /dev/tty
120   read ANS EXCESS
121   if test "X$ANS" = "Xn" -o "X$ANS" = "XN"
122   then
123     exit 1
124   fi
125   if test "X$ANS" = "Xy" -o "X$ANS" = "XY"
126   then
127     exit 0
128   else
129     echo "Please answer y or n." > /dev/tty
130   fi
131 done
132
133 # Should never get here!
134
135 echo "$0: unexpected failure!"
136 exit 2