diff options
author | Mike Frysinger <vapier@gentoo.org> | 2011-01-17 04:49:35 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2011-01-17 04:49:35 -0500 |
commit | 6e876bca1313d0cc2ef576da15124a9082f404db (patch) | |
tree | 560933bcfcd11fefeb0d2ae3834cb89e29194f0d /src/test/runtests.sh | |
parent | faa2df11597cf496205d3d629e3b3147b569afc8 (diff) |
tests: check for common style issues
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'src/test/runtests.sh')
-rwxr-xr-x | src/test/runtests.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/runtests.sh b/src/test/runtests.sh index 076bd754..8a8c467e 100755 --- a/src/test/runtests.sh +++ b/src/test/runtests.sh @@ -66,6 +66,42 @@ syms=$(diff -u librc.funcs.hidden.list librc.funcs.hidden.out | sed -n '/^+[^+]/ eend $? "Missing hidden defs:"$'\n'"${syms}" ret=$(($ret + $?)) +ebegin "Checking trailing whitespace in code" +# XXX: Should we check man pages too ? +out=$(cd ${top_srcdir}; find */ \ + '(' -name '*.[ch]' -o -name '*.in' -o -name '*.sh' ')' \ + -exec grep -n -E '[[:space:]]+$' {} +) +[ -z "${out}" ] +eend $? "Trailing whitespace needs to be deleted:"$'\n'"${out}" + +ebegin "Checking for obsolete functions" +out=$(cd ${top_srcdir}; find src -name '*.[ch]' \ + -exec grep -n -E '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' {} +) +[ -z "${out}" ] +eend $? "Avoid these obsolete functions:"$'\n'"${out}" + +ebegin "Checking for x* func usage" +out=$(cd ${top_srcdir}; find src -name '*.[ch]' \ + -exec grep -n -E '\<(malloc|strdup)[[:space:]]*\(' {} + \ + | grep -v \ + -e src/includes/rc-misc.h \ + -e src/libeinfo/libeinfo.c) +[ -z "${out}" ] +eend $? "These need to be using the x* variant:"$'\n'"${out}" + +ebegin "Checking spacing style" +out=$(cd ${top_srcdir}; find src -name '*.[ch]' \ + -exec grep -n -E \ + -e '\<(for|if|switch|while)\(' \ + -e '\<(for|if|switch|while) \( ' \ + -e ' ;' \ + -e '[[:space:]]$' \ + -e '\){' \ + -e '(^|[^:])//' \ + {} +) +[ -z "${out}" ] +eend $? "These lines violate style rules:"$'\n'"${out}" + einfo "Running unit tests" eindent for u in units/*; do |