logging: add back support for GTKDOC_TRACE
[gtk-doc.git] / tests / sanity.sh
blob1db182f2903cc10731e58314586353f0795e5c61
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 nok=0
86 for file in $dir/*/docs/gtkdoc-*.log; do
87 expected_lines="1"
88 # adjust for known files
89 if test $file = "$dir/fail/docs/gtkdoc-mkdb.log"; then
90 expected_lines="16"
92 if test $file = "$dir/gobject/docs/gtkdoc-fixxref.log"; then
93 expected_lines="2"
95 case $file in
96 *gtkdoc-fixxref.log)
97 # if there is no /usr/share/gtk-doc/html/gobject we should skip fixxref logs
98 if test ! -d "$GLIB_PREFIX/share/gtk-doc/html/gobject"; then
99 continue
102 esac
104 lines=`wc -l $file | cut -d' ' -f1`
105 if test $lines -gt $expected_lines; then
106 echo 1>&2 "expected no more than $expected_lines log line in $file, but got $lines"
107 nok=`expr $nok + 1`;
109 done
110 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
111 tested=`expr $tested + 1`
113 # check stability of generated xml/html
114 nok=0
115 for path in $dir/*/docs*; do
116 if test -d $path/xml.ref; then
117 diff -u $path/xml.ref $path/xml
118 if test $? = 1 ; then
119 echo 1>&2 "difference in generated xml for $path"
120 nok=`expr $nok + 1`;
123 if test -d $path/html.ref; then
124 diff -u $path/html.ref $path/html
125 if test $? = 1 ; then
126 echo 1>&2 "difference in generated html for $path"
127 nok=`expr $nok + 1`;
130 done
131 if test $nok -gt 0 ; then failed=`expr $failed + 1`; fi
132 tested=`expr $tested + 1`
135 # summary
136 successes=`expr $tested - $failed`
137 rate=`expr 100 \* $successes / $tested`;
138 echo "$rate %: Checks $tested, Failures: $failed"
140 test $failed = 0
141 exit $?