summaryrefslogtreecommitdiffstats
path: root/fixincludes/check.tpl
blob: 0d1f44431fc55cc1bb265d25f4d6de22b717b4e3 (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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
[= autogen5 template sh=check.sh =]
[=
#
#  This file contains the shell template to run tests on the fixes
#
=]#!/bin/sh

set -e
TESTDIR=tests
TESTBASE=`cd $1;${PWDCMD-pwd}`

[ -d ${TESTDIR} ] || mkdir ${TESTDIR}
cd ${TESTDIR}
TESTDIR=`${PWDCMD-pwd}`

TARGET_MACHINE='*'
DESTDIR=`${PWDCMD-pwd}`/res
SRCDIR=`${PWDCMD-pwd}`/inc
FIND_BASE='.'
VERBOSE=[=` echo ${VERBOSE-1} `=]
INPUT=`${PWDCMD-pwd}`
ORIGDIR=${INPUT}

export TARGET_MACHINE DESTDIR SRCDIR FIND_BASE VERBOSE INPUT ORIGDIR

rm -rf ${DESTDIR} ${SRCDIR}
mkdir ${DESTDIR} ${SRCDIR}
(
[=
  (shellf
    "for f in %s
     do case $f in
        */* ) echo $f | sed 's;/[^/]*$;;' ;;
        esac
     done | sort -u | \
     while read g
     do echo \"  mkdir \\${SRCDIR}/$g || mkdir -p \\${SRCDIR}/$g || exit 1\"
     done" (join " " (stack "fix.files"))  ) =]
) 2> /dev/null[= # suppress 'No such file or directory' messages =]
cd inc
[=
(define sfile "")
(define HACK  "")
(define dfile "")              =][=

FOR fix                        =][=

  IF (> (count "test_text") 1) =][=
    (set! HACK (string-upcase! (get "hackname")))
    (set! sfile (if (exist? "files") (get "files[]") "testing.h"))
    (set! dfile (string-append
          (if (*==* sfile "/")
              (shellf "echo \"%s\"|sed 's,/[^/]*,/,'" sfile )
              "" )
          (string-tr! (get "hackname") "_A-Z" "-a-z")
    )           )              =][=

    FOR test_text (for-from 1) =]
cat >> [=(. sfile)=] <<_HACK_EOF_


#if defined( [=(. HACK)=]_CHECK_[=(for-index)=] )
[=test_text=]
#endif  /* [=(. HACK)=]_CHECK_[=(for-index)=] */
_HACK_EOF_
echo [=(. sfile)=] | ../../fixincl
mv -f [=(. sfile)=] [=(. dfile)=]-[=(for-index)=].h
[ -f ${DESTDIR}/[=(. sfile)=] ] && [=#
   =]mv ${DESTDIR}/[=(. sfile)=] ${DESTDIR}/[=(. dfile)=]-[=(for-index)=].h[=

    ENDFOR  test_text =][=

  ENDIF  multi-test   =][=

ENDFOR  fix

=][=

FOR fix  =][=
  (set! HACK (string-upcase! (get "hackname")))  =][=

  IF (not (exist? "test_text")) =][=
    (if (not (exist? "replace"))
        (error (sprintf "include fix '%s' has no test text"
                        (get "hackname") )) )
         =][=
  ELSE   =]
cat >> [= (raw-shell-str (if (exist? "files") (get "files[0]") "testing.h"))
         =] <<_HACK_EOF_


#if defined( [=(. HACK)=]_CHECK )
[=test_text=]
#endif  /* [=(. HACK)=]_CHECK */
_HACK_EOF_
[=ENDIF =][=

ENDFOR  fix

=]

export TEST_MODE=true
find . -type f | sed 's;^\./;;' | sort | ../../fixincl
cd ${DESTDIR}

exitok=true

find * -type f -print > ${TESTDIR}/LIST

#  Special hack for sys/types.h:  the #define-d types for size_t,
#  ptrdiff_t and wchar_t are different for each port.  Therefore,
#  strip off the defined-to type so that the test results are the
#  same for all platforms.
#
sed 's/\(#define __[A-Z_]*_TYPE__\).*/\1/' sys/types.h > XX
mv -f XX sys/types.h

#  The following subshell weirdness is for saving an exit
#  status from within a while loop that reads input.  If you can
#  think of a cleaner way, suggest away, please...
#
exitok=`
exec < ${TESTDIR}/LIST
while read f
do
  if [ ! -f ${TESTBASE}/$f ]
  then
    echo "Newly fixed header:  $f" >&2
    exitok=false

  elif cmp $f ${TESTBASE}/$f >&2
  then
    :

  else
    ${DIFF:-diff} -c $f ${TESTBASE}/$f >&2 || :
    exitok=false
  fi
done
echo $exitok`

cd $TESTBASE

find * -type f -print | \
fgrep -v 'CVS/' | \
fgrep -v '.svn/' > ${TESTDIR}/LIST

exitok=`
exec < ${TESTDIR}/LIST
while read f
do
  if [ -s $f ] && [ ! -f ${DESTDIR}/$f ]
  then
    echo "Missing header fix:  $f" >&2
    exitok=false
  fi
done
echo $exitok`

echo
if $exitok
then
  cd ${TESTDIR}
  rm -rf inc res LIST
  cd ..
  rmdir ${TESTDIR} > /dev/null 2>&1 || :
  echo All fixinclude tests pass >&2
else
  echo There were fixinclude test FAILURES  >&2
fi
$exitok[=

(if (defined? 'set-writable) (set-writable))

=]
OpenPOWER on IntegriCloud