all_sourcecode.tests 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/sh
  2. # Tests for the sourcecode base itself.
  3. # Copyright 2006 by Mike Frysinger <vapier@gentoo.org>
  4. # Licensed under GPL v2, see file LICENSE for details.
  5. [ -n "$srcdir" ] || srcdir=$(pwd)
  6. . ./testing.sh
  7. #
  8. # if we don't have the sourcecode available, let's just bail
  9. #
  10. [ -s "$srcdir/../Makefile" ] || exit 0
  11. [ -s "$srcdir/../include/applets.h" ] || exit 0
  12. #
  13. # make sure all usage strings are properly escaped. oftentimes people miss
  14. # an escape sequence so we end up with:
  15. # #define foo_usage \
  16. # " this line is ok" \
  17. # " as is this line"
  18. # " but this one is broken as the \ is missing from above"
  19. #
  20. ${CROSS_COMPILE}cpp -dD -P $srcdir/../include/usage.h \
  21. | sed -e '/^#define/d' -e '/^$/d' > src.usage.escaped
  22. testing "Usage strings escaped" "cat src.usage.escaped" "" "" ""
  23. rm -f src.usage.escaped
  24. #
  25. # verify the applet order is correct in applets.h, otherwise
  26. # applets won't be called properly.
  27. #
  28. sed -n -e 's:^//::' -e '/^IF_[A-Z]*(APPLET/{s:,.*::;s:.*(::;s:"::g;p}' \
  29. $srcdir/../include/applets.h > applet.order.current
  30. LC_ALL=C sort applet.order.current > applet.order.correct
  31. testing "Applet order" "diff -u applet.order.current applet.order.correct" "" "" ""
  32. rm -f applet.order.current applet.order.correct
  33. #
  34. # check for misc common typos
  35. #
  36. find $srcdir/../ \
  37. '(' -type d -a '(' -name .svn -o -name testsuite ')' -prune ')' \
  38. -o '(' -type f -a -print0 ')' | xargs -0 \
  39. grep -I \
  40. -e '\<compatability\>' \
  41. -e '\<compatable\>' \
  42. -e '\<fordeground\>' \
  43. -e '\<depency\>' -e '\<dependancy\>' -e '\<dependancies\>' \
  44. -e '\<defalt\>' \
  45. -e '\<remaing\>' \
  46. -e '\<queueing\>' \
  47. -e '\<detatch\>' \
  48. -e '\<sempahore\>' \
  49. -e '\<reprenstative\>' \
  50. -e '\<overriden\>' \
  51. -e '\<readed\>' \
  52. -e '\<formated\>' \
  53. -e '\<algorithic\>' \
  54. -e '\<deamon\>' \
  55. -e '\<derefernce\>' \
  56. -e '\<acomadate\>' \
  57. | sed -e "s:^$srcdir/\.\./::g" > src.typos
  58. testing "Common typos" "cat src.typos" "" "" ""
  59. rm -f src.typos
  60. #
  61. # don't allow obsolete functions
  62. #
  63. find $srcdir/.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
  64. grep -E -e '\<(bcmp|bcopy|bzero|getwd|index|mktemp|rindex|utime|sigblock|siggetmask|sigsetmask)\>[[:space:]]*\(' \
  65. | sed -e "s:^$srcdir/\.\./::g" > src.obsolete.funcs
  66. testing "Obsolete function usage" "cat src.obsolete.funcs" "" "" ""
  67. rm -f src.obsolete.funcs
  68. #
  69. # don't allow obsolete headers
  70. #
  71. find $srcdir/.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
  72. grep -E -e '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' \
  73. | sed -e "s:^$srcdir/\.\./::g" > src.obsolete.headers
  74. testing "Obsolete headers" "cat src.obsolete.headers" "" "" ""
  75. rm -f src.obsolete.headers
  76. exit $FAILCOUNT