2e780ed2f8549e8338eeaf49d255863a0fd87b30
[oweals/busybox.git] / testsuite / all_sourcecode.tests
1 #!/bin/sh
2
3 # Tests for the sourcecode base itself.
4 # Copyright 2006 by Mike Frysinger <vapier@gentoo.org>
5 # Licensed under GPL v2, see file LICENSE for details.
6
7 [ -n "$srcdir" ] || srcdir=$(pwd)
8 . testing.sh
9
10
11 #
12 # if we don't have the sourcecode available, let's just bail
13 #
14 [ -s "$srcdir/../Makefile" ] || exit 0
15 [ -s "$srcdir/../include/applets.h" ] || exit 0
16
17
18 #
19 # verify the applet order is correct in applets.h, otherwise
20 # applets won't be called properly.
21 #
22 sed -n -e '/^USE_[A-Z]*(APPLET(/{s:.*(::;s:,.*::;s:"::g;p}' \
23         $srcdir/../include/applets.h > applet.order.current
24 LC_ALL=C sort applet.order.current > applet.order.correct
25 testing "Applet order" "diff -u applet.order.current applet.order.correct" "" "" ""
26 rm -f applet.order.current applet.order.correct
27
28
29 #
30 # check for misc common typos
31 #
32 find $srcdir/../ \
33         '(' -type d -a '(' -name .svn -o -name testsuite ')' -prune ')' \
34         -o '(' -type f -a -print0 ')' | xargs -0 \
35         grep -I \
36                 -e '\<compatability\>' \
37                 -e '\<compatable\>' \
38                 -e '\<fordeground\>' \
39                 -e '\<depency\>' \
40                 -e '\<defalt\>' \
41                 -e '\<remaing\>' \
42                 -e '\<detatch\>' \
43                 -e '\<sempahore\>' \
44                 -e '\<reprenstative\>' \
45                 -e '\<overriden\>' \
46                 -e '\<readed\>' \
47                 -e '\<formated\>' \
48                 -e '\<algorithic\>' \
49                 -e '\<deamon\>' \
50                 -e '\<derefernce\>' \
51                 | sed -e "s:^$srcdir/\.\./::g" > src.typos
52 testing "Common typos" "cat src.typos" "" "" ""
53 rm -f src.typos
54
55
56 #
57 # don't allow obsolete functions
58 #
59 find $srcdir/.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
60         grep -E -e '\<(bcmp|bcopy|bzero|getwd|index|mktemp|rindex|utimes)\>[[:space:]]*\(' \
61         | sed -e "s:^$srcdir/\.\./::g" > src.obsolete.funcs
62 testing "Obsolete function usage" "cat src.obsolete.funcs" "" "" ""
63 rm -f src.obsolete.funcs
64
65
66 #
67 # don't allow obsolete headers
68 #
69 find $srcdir/.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
70         grep -E -e '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' \
71         | sed -e "s:^$srcdir/\.\./::g" > src.obsolete.headers
72 testing "Obsolete headers" "cat src.obsolete.headers" "" "" ""
73 rm -f src.obsolete.headers
74
75
76 exit $FAILCOUNT