db2html: more planning
[gtk-doc.git] / tests / sanity.sh
blobfe78576704fcab2458109f4bdec6e9c9593bed3b
1 #!/bin/sh
3 dir=$BUILDDIR
4 #`dirname $0`
5 suite="sanity"
7 failed=0
8 tested=0
10 echo "Running suite(s): gtk-doc-$suite";
12 # check the presence and non-emptyness of certain files
13 nok=0
14 for path in $dir/*/docs/html; do
15 if test ! -s $path/index.html ; then
16 echo 1>&2 "no or empty $path/index.html"
17 nok=`expr $nok + 1`; break;
19 if test ! -s $path/home.png ; then
20 echo 1>&2 "no or empty $path/home.png"
21 nok=`expr $nok + 1`; break;
23 file=`echo $path/*.devhelp2`
24 if test ! -s $file ; then
25 echo 1>&2 "no or empty $file"
26 nok=`expr $nok + 1`; break;
28 done
29 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
30 tested=`expr $tested + 1`
32 # TODO: if we have pdf support check for ./tests/*/docs/tester.pdf
33 nok=0
34 for path in $dir/*/docs; do
35 if test ! -s $path/tester.pdf ; then
36 if test -s $path/gtkdoc-mkpdf.log; then
37 if ! grep >/dev/null 2>&1 "must be installed to use gtkdoc-mkpdf" $path/gtkdoc-mkpdf.log; then
38 echo 1>&2 "no or empty $path/tester.pdf"
39 nok=`expr $nok + 1`; break;
43 done
44 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
45 tested=`expr $tested + 1`
47 # check validity of generated xml files
48 nok=0
49 for file in $dir/*/docs/xml/*.xml; do
50 xmllint --noout --noent $file
51 if test $? != 0 ; then
52 echo 1>&2 "xml validity check failed for $file"
53 nok=`expr $nok + 1`;
55 done
56 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
57 tested=`expr $tested + 1`
60 # check validity of generated sgml files
61 nok=0
62 for file in $dir/*/docs/xml/*.sgml; do
63 xmllint --noout --noent $file
64 if test $? != 0 ; then
65 echo 1>&2 "sgml validity check failed for $file"
66 nok=`expr $nok + 1`;
68 done
69 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
70 tested=`expr $tested + 1`
72 # check validity of devhelp2 files
73 nok=0
74 for file in $dir/*/docs/html/*.devhelp2; do
75 xmllint --noout --nonet --schema $ABS_TOP_SRCDIR/devhelp2.xsd $file
76 if test $? != 0 ; then
77 echo 1>&2 "devhelp2 xml validity check failed for $file"
78 nok=`expr $nok + 1`;
80 done
81 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
82 tested=`expr $tested + 1`
84 # check that log files have only one line (the command)
85 # discard references to launchapd bugs
86 nok=0
87 DISCARD_PATTERN='Please fix https://bugs.launchpad.net/ubuntu/+source/gtk-doc/+bug/[0-9]* . For now run:
88 gunzip .*.gz
91 for file in $dir/*/docs/gtkdoc-*.log; do
92 expected_lines="1"
93 # adjust for known files
94 if test $file = "$dir/fail/docs/gtkdoc-mkdb.log"; then
95 expected_lines="16"
97 if test $file = "$dir/bugs/docs/gtkdoc-mkdb.log"; then
98 expected_lines="2"
100 if test $file = "$dir/gobject/docs/gtkdoc-fixxref.log"; then
101 expected_lines="2"
103 case $file in
104 *gtkdoc-fixxref.log)
105 # if there is no /usr/share/gtk-doc/html/gobject we should skip fixxref logs
106 if test ! -d "$GLIB_PREFIX/share/gtk-doc/html/gobject"; then
107 continue
110 esac
112 lines=`grep -v -x -G -e "$DISCARD_PATTERN" $file | wc -l | cut -d' ' -f1`
113 if test $lines -gt $expected_lines; then
114 echo 1>&2 "expected no more than $expected_lines log line in $file, but got $lines"
115 nok=`expr $nok + 1`;
117 done
118 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
119 tested=`expr $tested + 1`
121 # check stability of generated xml/html
122 nok=0
123 for path in $dir/*/docs*; do
124 if test -d $path/xml.ref; then
125 diff -u $path/xml.ref $path/xml
126 if test $? = 1 ; then
127 echo 1>&2 "difference in generated xml for $path"
128 nok=`expr $nok + 1`;
131 if test -d $path/html.ref; then
132 diff -u $path/html.ref $path/html
133 if test $? = 1 ; then
134 echo 1>&2 "difference in generated html for $path"
135 nok=`expr $nok + 1`;
138 done
139 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
140 tested=`expr $tested + 1`
143 # summary
144 successes=`expr $tested - $failed`
145 rate=`expr 100 \* $successes / $tested`;
146 echo "$rate %: Checks $tested, Failures: $failed"
148 test $failed = 0
149 exit $?