2007-09-26 14:46:41 +05:30
|
|
|
#!/bin/sh
|
2007-09-26 14:14:39 +05:30
|
|
|
|
2019-02-23 02:49:33 +05:30
|
|
|
top_srcdir=${top_srcdir:-..}
|
2008-03-24 12:47:05 +05:30
|
|
|
. ${top_srcdir}/test/setup_env.sh
|
2008-03-24 12:00:21 +05:30
|
|
|
|
2013-10-16 23:25:37 +05:30
|
|
|
libeinfo_srcdir="${srcdir}/../libeinfo"
|
|
|
|
libeinfo_builddir="${builddir}/../libeinfo"
|
2008-03-24 12:00:21 +05:30
|
|
|
librc_srcdir="${srcdir}/../librc"
|
|
|
|
librc_builddir="${builddir}/../librc"
|
|
|
|
rc_srcdir="${srcdir}/../rc"
|
|
|
|
rc_builddir="${builddir}/../rc"
|
|
|
|
|
2007-09-26 14:14:39 +05:30
|
|
|
checkit() {
|
2007-11-28 21:15:03 +05:30
|
|
|
local base=$1; shift
|
2007-09-26 14:14:39 +05:30
|
|
|
echo "$@" | tr ' ' '\n' > ${base}.out
|
|
|
|
diff -u ${base}.list ${base}.out
|
|
|
|
eend $?
|
2011-11-11 08:16:08 +05:30
|
|
|
: $(( ret += $? ))
|
2007-09-26 14:14:39 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
ret=0
|
|
|
|
|
2018-10-20 01:29:23 +05:30
|
|
|
fail_on_out() {
|
2018-12-04 01:23:14 +05:30
|
|
|
if [ -n "${out}" ]; then
|
|
|
|
eerror "Last command failed; failing"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-10-20 01:29:23 +05:30
|
|
|
}
|
|
|
|
|
2011-01-17 15:19:35 +05:30
|
|
|
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}"
|
2018-10-20 01:29:23 +05:30
|
|
|
fail_on_out
|
2011-01-17 15:19:35 +05:30
|
|
|
|
2011-01-18 06:34:53 +05:30
|
|
|
ebegin "Checking trailing newlines in code"
|
|
|
|
out=$(cd ${top_srcdir};
|
|
|
|
for f in `find */ -name '*.[ch]'` ; do
|
|
|
|
sed -n -e :a -e '/^\n*$/{$q1;N;ba' -e '}' $f || echo $f
|
|
|
|
done)
|
|
|
|
[ -z "${out}" ]
|
|
|
|
eend $? "Trailing newlines need to be deleted:"$'\n'"${out}"
|
2018-10-20 01:29:23 +05:30
|
|
|
fail_on_out
|
2011-01-18 06:34:53 +05:30
|
|
|
|
2011-01-17 15:19:35 +05:30
|
|
|
ebegin "Checking for obsolete functions"
|
|
|
|
out=$(cd ${top_srcdir}; find src -name '*.[ch]' \
|
2016-01-22 23:24:16 +05:30
|
|
|
! -name queue.h \
|
2011-01-17 15:19:35 +05:30
|
|
|
-exec grep -n -E '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' {} +)
|
|
|
|
[ -z "${out}" ]
|
|
|
|
eend $? "Avoid these obsolete functions:"$'\n'"${out}"
|
2018-10-20 01:29:23 +05:30
|
|
|
fail_on_out
|
2011-01-17 15:19:35 +05:30
|
|
|
|
|
|
|
ebegin "Checking for x* func usage"
|
|
|
|
out=$(cd ${top_srcdir}; find src -name '*.[ch]' \
|
2016-01-22 23:24:16 +05:30
|
|
|
! -name queue.h \
|
2011-01-17 15:19:35 +05:30
|
|
|
-exec grep -n -E '\<(malloc|strdup)[[:space:]]*\(' {} + \
|
|
|
|
| grep -v \
|
2012-05-06 05:55:53 +05:30
|
|
|
-e src/includes/helpers.h \
|
2011-01-17 15:19:35 +05:30
|
|
|
-e src/libeinfo/libeinfo.c)
|
|
|
|
[ -z "${out}" ]
|
|
|
|
eend $? "These need to be using the x* variant:"$'\n'"${out}"
|
2018-10-20 01:29:23 +05:30
|
|
|
fail_on_out
|
2011-01-17 15:19:35 +05:30
|
|
|
|
|
|
|
ebegin "Checking spacing style"
|
|
|
|
out=$(cd ${top_srcdir}; find src -name '*.[ch]' \
|
2016-01-22 23:24:16 +05:30
|
|
|
! -name queue.h \
|
2011-01-17 15:19:35 +05:30
|
|
|
-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}"
|
2018-10-20 01:29:23 +05:30
|
|
|
fail_on_out
|
2011-01-17 15:19:35 +05:30
|
|
|
|
2008-07-03 17:37:46 +05:30
|
|
|
einfo "Running unit tests"
|
|
|
|
eindent
|
2008-07-03 18:39:10 +05:30
|
|
|
for u in units/*; do
|
2008-07-03 17:37:46 +05:30
|
|
|
[ -x "${u}" -a -f "${u}" ] || continue
|
2008-07-03 18:39:10 +05:30
|
|
|
ebegin "$(basename "${u}")"
|
2008-07-03 17:37:46 +05:30
|
|
|
./"${u}"
|
|
|
|
eend $?
|
2011-11-11 08:16:08 +05:30
|
|
|
: $(( ret += $? ))
|
2008-07-03 17:37:46 +05:30
|
|
|
done
|
|
|
|
|
2007-09-26 14:14:39 +05:30
|
|
|
exit ${ret}
|