Test op coding practices

This commit is contained in:
Willem Toorop 2017-03-20 16:15:02 +01:00
parent 0891e16147
commit 0048066a2a
3 changed files with 70 additions and 0 deletions

View File

@ -0,0 +1,16 @@
BaseName: 070-coding-practice
Version: 1.0
Description: Check for non-recommended coding practices
CreationDate: ma 20 mrt 2017 15:55:19 CET
Maintainer: Willem Toorop
Category:
Component:
CmdDepends:
Depends:
Help:
Pre: 070-coding-practice.pre
Post:
Test: 070-coding-practice.test
AuxFiles:
Passed:
Failure:

View File

@ -0,0 +1,14 @@
# #-- 070-coding-practice.pre--#
# source the master var file when it's there
if [ -f ../.tpkg.var.master ]
then
source ../.tpkg.var.master
else
(
cd ..
[ -f "${TPKG_SRCDIR}/setup-env.sh" ] \
&& sh "${TPKG_SRCDIR}/setup-env.sh"
) && source ../.tpkg.var.master
fi
# use .tpkg.var.test for in test variable passing
[ -f .tpkg.var.test ] && source .tpkg.var.test

View File

@ -0,0 +1,40 @@
# #-- 070-coding-practice.test --#
# source the master var file when it's there
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
# use .tpkg.var.test for in test variable passing
[ -f .tpkg.var.test ] && source .tpkg.var.test
rm -f report.txt
(
cd ${SRCROOT}/src
if [ `grep '[^!=]=[ ][ ]*NET_REQ_' *.[ch] */*.[ch] | wc -l` -gt 1 ]
then
echo "*** "
echo "*** Setting getdns_network_req->state should be done via"
echo "*** _getdns_netreq_change_state() only, for anticipating"
echo "*** running out of filedescriptors (sockets) and for the"
echo "*** limit_outstanding_queries feature."
echo "*** "
grep '[^!=]=[ ][ ]*NET_REQ_' *.[ch] */*.[ch]
echo ""
fi
) >> report.txt
(
cd ${SRCROOT}/src
if [ `grep '__FUNCTION__' *.[ch] */*.[ch] | wc -l` -gt 0 ]
then
echo "*** "
echo "*** Use __FUNC__ instead of __FUNCTION__ for portability"
echo "*** __FUNC__ is aliases in config.h to name to be used"
echo "*** for the system with a #define"
echo "*** "
grep '__FUNCION__' *.[ch] */*.[ch]
echo ""
fi
) >> report.txt
if [ -s report.txt ]
then
cat report.txt
false
fi