| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # Copyright 2014--2015 Red Hat Inc., Durham, North Carolina. |
| 4 | # All Rights Reserved. |
| 5 | |
| 6 | set -e -o pipefail |
| 7 | |
| 8 | . $builddir/tests/test_common.sh |
| 9 | |
| 10 | function test_illicit_function_use { |
| 11 | codebase=$(find $top_srcdir/src/ -regex '.*\.[ch]x*') |
| 12 | if grep xmlReaderForFile $codebase; then |
| 13 | echo "xmlReaderForFile is not allowed within OpenSCAP project. Please make a use of oscap_source facility." |
| 14 | return 1; |
| 15 | fi |
| 16 | if grep xmlTextReaderSetErrorHandler $codebase; then |
| 17 | echo "xmlTextReaderSetErrorHandler is not allowed within OpenSCAP project. Please make a use of oscap_source facility." |
| 18 | return 1; |
| 19 | fi |
| 20 | if grep xmlTextReaderReadString $codebase; then |
| 21 | echo "xmlTextReaderReadString is not allowed within OpenSCAP project. Its implementation in libxml does not play well with xmlWalkerReader." |
| 22 | return 1; |
| 23 | fi |
| 24 | |
| 25 | codebase_without_xml_read_file=$(echo $codebase | xsed 's/\S*\/source\/oscap_source.c / /g' -) |
| 26 | if grep xmlReadFile $codebase_without_xml_read_file; then |
| 27 | echo "xmlReadFile is not allowed within OpenSCAP project. Please make a use of oscap_source facility." |
| 28 | return 1; |
| 29 | fi |
| 30 | } |
| 31 | |
| 32 | function shell_script_syntax(){ |
| 33 | for script in $@; do |
| 34 | bash -n -u $top_srcdir/$script |
| 35 | done |
| 36 | } |
| 37 | |
| 38 | test_init "test_codebase.log" |
| 39 | |
| 40 | if [ -z ${CUSTOM_OSCAP+x} ] ; then |
| 41 | test_run "illicit use of functions" test_illicit_function_use 0 |
| 42 | test_run "Check syntax of distributed shell scripts" shell_script_syntax \ |
| 43 | utils/oscap-ssh |
| 44 | fi |
| 45 | |
| 46 | test_exit |