From 0048066a2a6c7e99f0767ce00f3293f88f6e3f7e Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Mon, 20 Mar 2017 16:15:02 +0100 Subject: [PATCH] Test op coding practices --- .../070-coding-practice.dsc | 16 ++++++++ .../070-coding-practice.pre | 14 +++++++ .../070-coding-practice.test | 40 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.dsc create mode 100644 src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.pre create mode 100644 src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.test diff --git a/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.dsc b/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.dsc new file mode 100644 index 00000000..b2101c47 --- /dev/null +++ b/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.dsc @@ -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: diff --git a/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.pre b/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.pre new file mode 100644 index 00000000..150497af --- /dev/null +++ b/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.pre @@ -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 diff --git a/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.test b/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.test new file mode 100644 index 00000000..b0360279 --- /dev/null +++ b/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.test @@ -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