summaryrefslogtreecommitdiff
path: root/tests/CkTestDB
blob: 80bee632f304850ab587511749845187bec041bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/sh
#
# CkTestDB -- see if this dialect is has been tested
#
# This script builds a line from config.flags in the form of lines in
# ./TestDB,  (See Add2TestDB.)
#
# It then compares the line to TestDB.  If the line is found, the script
# exits.  if the line is not found, the script issues a warning and requests
# a go-ahead confirmation.
#
# The script will exit 0 if the test line is in the DB or the go-ahead
# confirmation is positive.
#
# $Id: CkTestDB,v 1.3 2010/01/18 19:02:21 abe Exp abe $

# Check for config.flags.

if test ! -r config.cflags
then
  echo "$0: no ./config.cflags file"
  exit 1
fi

# Check for a current data base file.

if test ! -r TestDB
then
  echo "$0: no ./TestDB file"
  exit 1
fi

# Form a data base line.

new=""
for i in `LC_ALL=C sort < config.cflags`
do
  w=`echo $i | sed 's/^-D//'`
  if test "X$new" = "X"
  then
    new=$w
  else
    new="$new $w"
  fi
done

# See if the line is already in the data base.  Exit with success (0), if it is.

grep "^$new\$" TestDB > /dev/null 2>&1
if test $? -eq 0
then
  exit 0
fi

# This dialect may never have been validated with the test suite.

# If the standard input is not a TTY, quit, because no interaction
# is possible.

tty -s > /dev/null 2>&1
if test $? -ne 0
then
  echo ""
  echo "This suite has not been validated on:"
  echo ""
  echo "     $new"
  echo ""
  exit 1
fi

# Establish trap and stty handling.

ISIG=":"
trap '$ISIG; exit 1'  1 2 3 15
stty -a 2>&1 | grep isig > /dev/null
if test $? -eq 0
then
  stty -a 2>&1 | egrep -e -isig > /dev/null
  if test $? -eq 0
  then
    ISIG="stty -isig"
    stty isig
  fi
fi

# Establish echo type -- Berkeley or SYSV.

j=`echo -n ""`
if test "X$j" = "X-n "
then
  EC="\c"
  EO=""
else
  EC=""
  EO="-n"
fi

# Display a validation warning.

cat << .CAT_MARK > /dev/tty

==================================================================

!!!WARNING!!!

This dialect or its particular version may not have been validated
with the lsof test suite.  Consequently some tests may fail or may
not even compile.

This is the computed identity of this dialect, not found in the
test data base file, ./TestDB:

.CAT_MARK
echo "    $new" > /dev/tty
END=0
while test $END = 0
do
  echo "" > /dev/tty
  echo $EO "Do you want to continue (y|n) [n]? $EC" > /dev/tty
  read ANS EXCESS
  if test "X$ANS" = "Xn" -o "X$ANS" = "XN"
  then
    exit 1
  fi
  if test "X$ANS" = "Xy" -o "X$ANS" = "XY"
  then
    exit 0
  else
    echo "Please answer y or n." > /dev/tty
  fi
done

# Should never get here!

echo "$0: unexpected failure!"
exit 2