blob: 7dcbbe8f5cc4e2f93a0ad01e7d310481ad0efaad [file] [log] [blame]
Mike Frysingerb0c54452006-04-01 01:36:32 +00001#!/bin/sh
2
3# Tests for the sourcecode base itself.
4# Copyright 2006 by Mike Frysinger <vapier@gentoo.org>
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02005# Licensed under GPLv2, see file LICENSE in this source tree.
Mike Frysingerb0c54452006-04-01 01:36:32 +00006
Mike Frysinger819b56b2006-04-01 20:38:22 +00007[ -n "$srcdir" ] || srcdir=$(pwd)
Mike Frysingercaa79402009-11-04 18:41:22 -05008. ./testing.sh
Mike Frysingerb0c54452006-04-01 01:36:32 +00009
Mike Frysingerdbd8c3b2006-04-16 06:09:46 +000010
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#
Mike Frysinger25cd7fd2008-02-15 01:42:28 +000019# make sure all usage strings are properly escaped. oftentimes people miss
20# an escape sequence so we end up with:
21# #define foo_usage \
22# " this line is ok" \
23# " as is this line"
24# " but this one is broken as the \ is missing from above"
25#
26${CROSS_COMPILE}cpp -dD -P $srcdir/../include/usage.h \
27 | sed -e '/^#define/d' -e '/^$/d' > src.usage.escaped
28testing "Usage strings escaped" "cat src.usage.escaped" "" "" ""
29rm -f src.usage.escaped
30
31
32#
Mike Frysingerb0c54452006-04-01 01:36:32 +000033# verify the applet order is correct in applets.h, otherwise
34# applets won't be called properly.
Mike Frysingerdbd8c3b2006-04-16 06:09:46 +000035#
Mike Frysingereacbca52009-11-04 18:49:08 -050036sed -n -e 's:^//::' -e '/^IF_[A-Z]*(APPLET/{s:,.*::;s:.*(::;s:"::g;p}' \
Mike Frysingerdbd8c3b2006-04-16 06:09:46 +000037 $srcdir/../include/applets.h > applet.order.current
Mike Frysingerb0c54452006-04-01 01:36:32 +000038LC_ALL=C sort applet.order.current > applet.order.correct
39testing "Applet order" "diff -u applet.order.current applet.order.correct" "" "" ""
40rm -f applet.order.current applet.order.correct
41
Mike Frysingerdbd8c3b2006-04-16 06:09:46 +000042
43#
44# check for misc common typos
45#
46find $srcdir/../ \
47 '(' -type d -a '(' -name .svn -o -name testsuite ')' -prune ')' \
48 -o '(' -type f -a -print0 ')' | xargs -0 \
49 grep -I \
50 -e '\<compatability\>' \
51 -e '\<compatable\>' \
52 -e '\<fordeground\>' \
Mike Frysinger9c03cb92006-05-26 01:41:04 +000053 -e '\<depency\>' -e '\<dependancy\>' -e '\<dependancies\>' \
Mike Frysingerdbd8c3b2006-04-16 06:09:46 +000054 -e '\<defalt\>' \
55 -e '\<remaing\>' \
Mike Frysinger9c03cb92006-05-26 01:41:04 +000056 -e '\<queueing\>' \
Mike Frysingerdbd8c3b2006-04-16 06:09:46 +000057 -e '\<detatch\>' \
58 -e '\<sempahore\>' \
59 -e '\<reprenstative\>' \
60 -e '\<overriden\>' \
61 -e '\<readed\>' \
62 -e '\<formated\>' \
Bernhard Reutner-Fischer9b68dbd2006-04-18 08:44:19 +000063 -e '\<algorithic\>' \
Bernhard Reutner-Fischer074fe342006-04-18 11:15:19 +000064 -e '\<deamon\>' \
Bernhard Reutner-Fischer18260d52006-04-18 14:17:49 +000065 -e '\<derefernce\>' \
Bernhard Reutner-Fischer73561cc2006-08-28 23:31:54 +000066 -e '\<acomadate\>' \
Mike Frysingerdbd8c3b2006-04-16 06:09:46 +000067 | sed -e "s:^$srcdir/\.\./::g" > src.typos
68testing "Common typos" "cat src.typos" "" "" ""
69rm -f src.typos
70
71
72#
73# don't allow obsolete functions
74#
75find $srcdir/.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
Bernhard Reutner-Fischera307af12009-11-15 00:12:53 +010076 grep -E -e '\<(bcmp|bcopy|bzero|getwd|index|mktemp|rindex|utime|sigblock|siggetmask|sigsetmask)\>[[:space:]]*\(' \
Mike Frysingerd017d732006-04-16 21:14:59 +000077 | sed -e "s:^$srcdir/\.\./::g" > src.obsolete.funcs
78testing "Obsolete function usage" "cat src.obsolete.funcs" "" "" ""
79rm -f src.obsolete.funcs
80
81
82#
83# don't allow obsolete headers
84#
85find $srcdir/.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
Mike Frysinger02fe8102006-04-29 04:44:08 +000086 grep -E -e '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' \
Mike Frysingerd017d732006-04-16 21:14:59 +000087 | sed -e "s:^$srcdir/\.\./::g" > src.obsolete.headers
Bernhard Reutner-Fischer15545b12006-04-28 19:53:48 +000088testing "Obsolete headers" "cat src.obsolete.headers" "" "" ""
Mike Frysingerd017d732006-04-16 21:14:59 +000089rm -f src.obsolete.headers
Mike Frysingerdbd8c3b2006-04-16 06:09:46 +000090
91
Mike Frysingerb0c54452006-04-01 01:36:32 +000092exit $FAILCOUNT