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.3 2010/01/18 19:02:21 abe Exp abe $
16
17# Check for config.flags.
18
19if test ! -r config.cflags
20then
21  echo "$0: no ./config.cflags file"
22  exit 1
23fi
24
25# Check for a current data base file.
26
27if test ! -r TestDB
28then
29  echo "$0: no ./TestDB file"
30  exit 1
31fi
32
33# Form a data base line.
34
35new=""
36for i in `LC_ALL=C sort < config.cflags`
37do
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
45done
46
47# See if the line is already in the data base.  Exit with success (0), if it is.
48
49grep "^$new\$" TestDB > /dev/null 2>&1
50if test $? -eq 0
51then
52  exit 0
53fi
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
60tty -s > /dev/null 2>&1
61if test $? -ne 0
62then
63  echo ""
64  echo "This suite has not been validated on:"
65  echo ""
66  echo "     $new"
67  echo ""
68  exit 1
69fi
70
71# Establish trap and stty handling.
72
73ISIG=":"
74trap '$ISIG; exit 1'  1 2 3 15
75stty -a 2>&1 | grep isig > /dev/null
76if test $? -eq 0
77then
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
84fi
85
86# Establish echo type -- Berkeley or SYSV.
87
88j=`echo -n ""`
89if test "X$j" = "X-n "
90then
91  EC="\c"
92  EO=""
93else
94  EC=""
95  EO="-n"
96fi
97
98# Display a validation warning.
99
100cat << .CAT_MARK > /dev/tty
101
102==================================================================
103
104!!!WARNING!!!
105
106This dialect or its particular version may not have been validated
107with the lsof test suite.  Consequently some tests may fail or may
108not even compile.
109
110This is the computed identity of this dialect, not found in the
111test data base file, ./TestDB:
112
113.CAT_MARK
114echo "    $new" > /dev/tty
115END=0
116while test $END = 0
117do
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
131done
132
133# Should never get here!
134
135echo "$0: unexpected failure!"
136exit 2
137