Changeset 474 for trunk/test


Ignore:
Timestamp:
May 30, 2015, 7:57:16 PM (9 years ago)
Author:
katerina
Message:

Fix for ticket #372 (Replace obsolete smatch by clang in test suite).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/testcompile.sh

    r473 r474  
    2020#
    2121
    22 # dnmalloc + cppcheck + flawfinder + (38 * 2)
     22# dnmalloc + cppcheck + flawfinder + (38 * 2) - 8
    2323MAXTEST=79; export MAXTEST
    2424
     
    8585run_cppcheck ()
    8686{
    87     if [ -z "$doall" ]; then
    88         [ -z "$quiet" ] && log_skip $2 ${MAXTEST} "check w/cppcheck";
    89         return 0
    90     fi
    9187    #
    9288    CPC=`find_path cppcheck`
     
    124120}
    125121
    126 run_smatch ()
     122run_clang ()
    127123{
    128124    export CDIR=`pwd`;
    129125
    130126    if [ -z "$doall" ]; then
    131         [ -z "$quiet" ] && log_skip $2 ${MAXTEST} "$TEST (smatch)";
     127        [ -z "$quiet" ] && log_skip $2 ${MAXTEST} "$TEST (clang)";
    132128        return 0
    133129    fi
    134130
    135     if [ ! -f "./x_samhain.c.sm" ]; then
    136         [ -z "$quiet" ] && log_skip $2 ${MAXTEST} "$TEST (skip sm)";
     131    CLANGPATH=`find_path clang`
     132    if [ -n "$CLANGPATH" ]; then
     133        CLANG_CC="$CLANGPATH"; export CLANG_CC
     134    else
     135        [ -z "$quiet" ] && log_skip $2 ${MAXTEST} "$TEST (clang)";
    137136        return 0
    138137    fi
    139138
    140     if [ "x$3" = "xdebug" ]; then memcheck=debug; else memcheck=simple; fi
    141     if [ -f ../../static/sm_scripts/smatch.pm ]; then
    142         (
    143             cd ../../static/sm_scripts;
    144            
    145             for i in ${CDIR}/*.c.sm ; do
    146                 # echo $i;
    147                 cat $i | ./unreached_code.pl | grep -v sh_threaded_module_run;
    148                 cat $i | ./ampersand_missing.sh;
    149                 cat $i | ./eqeq.pl;
    150                 cat $i | ./for_bounds.pl;    # doesn't work?
    151                 cat $i | ./unchecked_returns.pl;
    152                 cat $i | ./uninitialized.pl; # doesn't work?
    153 
    154                 # from http://people.redhat.com/mstefani/wine/smatch/
    155                 if [ -f ./while_for_check.pl ]; then
    156                     cat $i | ./while_for_check.pl; # works
    157                 fi
    158                 # --> end wine <--
    159 
    160                 # samhain specific modifications (list of free/malloc funcs)
    161                 # doesn't seem to find anything useful
    162                 if [ $memcheck = xsimple ]; then
    163                     if [ -f ./samhain_unfree.pl ]; then
    164                         cat $i | ./samhain_unfree.pl | \
    165                             egrep -v 'x_cutest_.*Test_' | \
    166                             egrep -v 'x_sh_unix.c .... .... sh_unix_copyenv';
    167                     fi
    168                 fi
    169                 if [ $memcheck = xdebug ]; then
    170                     if [ -f ./samhain_unfree_debug.pl ]; then
    171                         cat $i | ./samhain_unfree_debug.pl | \
    172                             egrep -v 'x_cutest_.*Test_' | \
    173                             egrep -v 'x_sh_unix.c .... .... sh_unix_copyenv';
    174                     fi
    175                 fi
    176                 # --> end samhain specific <--
    177 
    178                 echo malloc >  list_null_funcs_uniq;
    179                 echo getenv >> list_null_funcs_uniq;
    180                 cat $i | ./deference_check.pl |\
    181                      egrep -v 'x_trustfile.c ... ... sl_trustfile' | \
    182                      egrep -v 'x_sh_mem.c ';
    183                 rm -f list_null_funcs_uniq;
    184                 # rm -f $i
    185             done
    186         ) >test_log_smatch 2>&1
    187         if [ -f test_log_smatch ]; then
    188             lines=`cat test_log_smatch | wc -l`
    189             if [ $lines -ne 0 ]; then
    190                 cat test_log_smatch
    191                 rm -f test_log_smatch
    192                 [ -z "$quiet" ] && log_fail $2 ${MAXTEST} "$TEST (smatch)";
    193                 return 1
    194             fi
    195         fi
    196         [ -z "$quiet" ] && log_ok $2 ${MAXTEST} "$TEST (smatch)";
    197         return 0
    198     fi
    199     [ -z "$quiet" ] && log_skip $2 ${MAXTEST} "$TEST (smatch)";
    200     return 0
     139    SAVE_TEST="$TEST"
     140    TEST="$TEST (clang)"
     141    testmake $1 $2
     142    retval=$?
     143    CLANG_CC=""; export CLANG_CC
     144    TEST="$SAVE_TEST"
     145    return $retval
    201146}
    202147
    203148testmake ()
    204149{
    205 
    206150        fail=0
    207151        #
     
    219163                [ -z "$verbose" ]     ||  log_msg_ok  "configure...  $TEST";
    220164                $MAKE clean > /dev/null 2>> test_log
    221                 $MAKE ${SMATCH} cutest > /dev/null 2>> test_log
     165                if [ -z "$CLANG_CC" ]; then
     166                    $MAKE cutest > /dev/null 2>> test_log
     167                else
     168                    sed --in-place 's/-Wno-empty-body/-Wno-empty-body -Wno-invalid-source-encoding/g' Makefile
     169                    sed --in-place 's/-fno-strength-reduce//g' Makefile
     170                    $MAKE -e CC=$CLANG_CC -e BUILD_CC=$CLANG_CC cutest > /dev/null 2>> test_log
     171                fi
    222172                if test x$? = x0; then
    223173                    [ -z "$verbose" ] || log_msg_ok   "make cutest... $TEST";
     
    247197{
    248198        log_start "COMPILE"
    249 
    250         if [ "x$doall" = xon ]; then
    251             uname -a | grep x86_64 >/dev/null
    252             if [ $? -ne 0 ]; then
    253                 if [ -f /usr/local/gcc-smatch/bin/gcc ]; then  # FIXME
    254                     SAVE_CC="${CC}"
    255                     SMATCH="DBGDEF=--smatch"; export SMATCH
    256                     SAVE_SMATCH="${SMATCH}"; export SAVE_SMATCH
    257                     CC="/usr/local/gcc-smatch/bin/gcc"; export CC
    258                     SMATCH_CC="${CC}"
    259                 fi
    260             fi
    261         fi
    262199
    263200        num=0
     
    342279        testmake $? $num || let "numfail = numfail + 1"  >/dev/null
    343280        let "num = num + 1" >/dev/null
    344         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     281        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    345282
    346283        #
     
    353290        fi
    354291        #
    355         [ -z "${SMATCH}" ] || { CC="${SAVE_CC}"; export CC; SMATCH=""; export SMATCH; }
    356         #
    357292        ${TOP_SRCDIR}/configure --quiet  --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test  --enable-static --enable-suidcheck --enable-process-check ${C_LOGFILE} > /dev/null 2>> test_log
    358293        #
     
    360295        testmake $? $num || let "numfail = numfail + 1"  >/dev/null
    361296        let "num = num + 1" >/dev/null
    362         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    363         #
    364         [ -z "${SMATCH_CC}" ] || { CC="${SMATCH_CC}"; export CC; SMATCH="${SAVE_SMATCH}"; export SMATCH; }
     297        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    365298        #
    366299        # test standalone compilation
     
    377310        testmake $? $num || let "numfail = numfail + 1"  >/dev/null
    378311        let "num = num + 1" >/dev/null
    379         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     312        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    380313
    381314        #
     
    388321        fi
    389322        #
    390         [ -z "${SMATCH}" ] || { CC="${SAVE_CC}"; export CC; SMATCH=""; export SMATCH; }
    391         #
    392323        ${TOP_SRCDIR}/configure --quiet  --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test  --enable-process-check --enable-port-check --enable-static > /dev/null 2>> test_log
    393324        #
     
    395326        testmake $? $num || let "numfail = numfail + 1"  >/dev/null
    396327        let "num = num + 1" >/dev/null
    397         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    398         #
    399         [ -z "${SMATCH_CC}" ] || { CC="${SMATCH_CC}"; export CC; SMATCH="${SAVE_SMATCH}"; export SMATCH; }
     328        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    400329        #
    401330        # test standalone compilation
     
    412341        testmake $? $num || let "numfail = numfail + 1"  >/dev/null
    413342        let "num = num + 1" >/dev/null
    414         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     343        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    415344
    416345        #
     
    428357        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    429358        let "num = num + 1" >/dev/null
    430         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     359        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    431360
    432361
     
    445374        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    446375        let "num = num + 1" >/dev/null
    447         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     376        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    448377
    449378        #
     
    461390        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    462391        let "num = num + 1" >/dev/null
    463         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     392        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    464393
    465394        #
     
    477406        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    478407        let "num = num + 1" >/dev/null
    479         run_smatch $? $num debug || let "numfail = numfail + 1"  >/dev/null
     408        run_clang $? $num debug || let "numfail = numfail + 1"  >/dev/null
    480409
    481410        #
     
    500429            testmake $? $num || let "numfail = numfail + 1" >/dev/null
    501430            let "num = num + 1" >/dev/null
    502             run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     431            run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    503432        fi
    504433
     
    517446        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    518447        let "num = num + 1" >/dev/null
    519         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     448        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    520449
    521450        #
     
    533462        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    534463        let "num = num + 1" >/dev/null
    535         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     464        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    536465
    537466        #
     
    549478        testmake $? $num "skip" || let "numfail = numfail + 1" >/dev/null
    550479        let "num = num + 1" >/dev/null
    551         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     480        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    552481
    553482        #
     
    565494        testmake $? $num "skip" || let "numfail = numfail + 1" >/dev/null
    566495        let "num = num + 1" >/dev/null
    567         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     496        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    568497
    569498        #
     
    581510        testmake $? $num "skip" || let "numfail = numfail + 1" >/dev/null
    582511        let "num = num + 1" >/dev/null
    583         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     512        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    584513
    585514        #
     
    597526        testmake $? $num "skip" || let "numfail = numfail + 1" >/dev/null
    598527        let "num = num + 1" >/dev/null
    599         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     528        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    600529
    601530        #
     
    613542        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    614543        let "num = num + 1" >/dev/null
    615         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     544        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    616545
    617546        #
     
    629558        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    630559        let "num = num + 1" >/dev/null
    631         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     560        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    632561
    633562        # echo; echo "${S}__ TEST CLIENT/SERVER __${E}"; echo;
     
    647576        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    648577        let "num = num + 1" >/dev/null
    649         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     578        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    650579       
    651580        if test -r "Makefile"; then
     
    658587        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    659588        let "num = num + 1" >/dev/null
    660         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     589        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    661590
    662591        #
     
    685614            testmake $? $num || let "numfail = numfail + 1" >/dev/null
    686615            let "num = num + 1" >/dev/null
    687             run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     616            run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    688617           
    689618            if test -r "Makefile"; then
     
    696625            testmake $? $num || let "numfail = numfail + 1" >/dev/null
    697626            let "num = num + 1" >/dev/null
    698             run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     627            run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    699628            #
    700629        fi
     
    709638        fi
    710639        #
    711         [ -z "${SMATCH}" ] || { CC="${SAVE_CC}"; export CC; SMATCH=""; export SMATCH; }
    712         #
    713640        ${TOP_SRCDIR}/configure --quiet --enable-network=client  --enable-static --enable-srp --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test   --with-timeserver=127.0.0.1 ${C_LOGFILE} > /dev/null 2>> test_log   
    714641        #
     
    716643        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    717644        let "num = num + 1" >/dev/null
    718         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     645        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    719646       
    720647        if test -r "Makefile"; then
     
    727654        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    728655        let "num = num + 1" >/dev/null
    729         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    730         #
    731         [ -z "${SMATCH_CC}" ] || { CC="${SMATCH_CC}"; export CC; SMATCH="${SAVE_SMATCH}"; export SMATCH; }
     656        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    732657        #
    733658        # test c/s compilation w/ gpg
     
    755680            testmake $? $num || let "numfail = numfail + 1" >/dev/null
    756681            let "num = num + 1" >/dev/null
    757             run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     682            run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    758683            #
    759684            if test -r "Makefile"; then
     
    766691            testmake $? $num || let "numfail = numfail + 1" >/dev/null
    767692            let "num = num + 1" >/dev/null
    768             run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     693            run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    769694        fi
    770695
     
    784709        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    785710        let "num = num + 1" >/dev/null
    786         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     711        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    787712        #
    788713        if test -r "Makefile"; then
     
    795720        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    796721        let "num = num + 1" >/dev/null
    797         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     722        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    798723
    799724        #
     
    811736        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    812737        let "num = num + 1" >/dev/null
    813         run_smatch $? $num debug || let "numfail = numfail + 1"  >/dev/null
     738        run_clang $? $num debug || let "numfail = numfail + 1"  >/dev/null
    814739        #
    815740        if test -r "Makefile"; then
     
    822747        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    823748        let "num = num + 1" >/dev/null
    824         run_smatch $? $num debug || let "numfail = numfail + 1"  >/dev/null
     749        run_clang $? $num debug || let "numfail = numfail + 1"  >/dev/null
    825750
    826751        #
     
    838763        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    839764        let "num = num + 1" >/dev/null
    840         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     765        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    841766        #
    842767        if test -r "Makefile"; then
     
    849774        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    850775        let "num = num + 1" >/dev/null
    851         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     776        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    852777
    853778        #
     
    865790        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    866791        let "num = num + 1" >/dev/null
    867         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     792        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    868793        #
    869794        if test -r "Makefile"; then
     
    876801        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    877802        let "num = num + 1" >/dev/null
    878         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     803        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    879804
    880805        #
     
    892817        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    893818        let "num = num + 1" >/dev/null
    894         run_smatch $? $num debug || let "numfail = numfail + 1"  >/dev/null
     819        run_clang $? $num debug || let "numfail = numfail + 1"  >/dev/null
    895820        #
    896821        if test -r "Makefile"; then
     
    903828        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    904829        let "num = num + 1" >/dev/null
    905         run_smatch $? $num debug || let "numfail = numfail + 1"  >/dev/null
     830        run_clang $? $num debug || let "numfail = numfail + 1"  >/dev/null
    906831
    907832        #
     
    919844        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    920845        let "num = num + 1" >/dev/null
    921         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
     846        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    922847        #
    923848        if test -r "Makefile"; then
     
    930855        testmake $? $num || let "numfail = numfail + 1" >/dev/null
    931856        let "num = num + 1" >/dev/null
    932         run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    933 
    934         [ -z "${SMATCH}" ] || { CC="${SAVE_CC}"; export CC; }
     857        run_clang $? $num || let "numfail = numfail + 1"  >/dev/null
    935858
    936859        log_end "COMPILE"
Note: See TracChangeset for help on using the changeset viewer.