Home | History | Annotate | Download | only in tests
      1 #!/bin/sh
      2 
      3 #
      4 # Purpose: test all machine configurations, pydebug, refleaks, release build
      5 #          and release build with valgrind.
      6 #
      7 # Synopsis: ./runall-memorydebugger.sh [--all-configs64 | --all-configs32]
      8 #
      9 # Requirements: valgrind
     10 #
     11 
     12 # Set additional CFLAGS and LDFLAGS for ./configure
     13 ADD_CFLAGS=
     14 ADD_LDFLAGS=
     15 
     16 
     17 CONFIGS_64="x64 uint128 ansi64 universal"
     18 CONFIGS_32="ppro ansi32 ansi-legacy universal"
     19 
     20 VALGRIND="valgrind --tool=memcheck --leak-resolution=high \
     21           --db-attach=yes --suppressions=Misc/valgrind-python.supp"
     22 
     23 # Get args
     24 case $@ in
     25      *--all-configs64*)
     26          CONFIGS=$CONFIGS_64
     27          ;;
     28      *--all-configs32*)
     29          CONFIGS=$CONFIGS_32
     30          ;;
     31      *)
     32          CONFIGS="auto"
     33          ;;
     34 esac
     35 
     36 # gmake required
     37 GMAKE=`which gmake`
     38 if [ X"$GMAKE" = X"" ]; then
     39     GMAKE=make
     40 fi
     41 
     42 # Pretty print configurations
     43 print_config ()
     44 {
     45     len=`echo $@ | wc -c`
     46     margin="#%"`expr \( 74 - $len \) / 2`"s"
     47 
     48     echo ""
     49     echo "# ========================================================================"
     50     printf $margin ""
     51     echo $@
     52     echo "# ========================================================================"
     53     echo ""
     54 }
     55 
     56 
     57 cd ..
     58 
     59 # test_decimal: refleak, regular and Valgrind tests
     60 for config in $CONFIGS; do
     61 
     62         unset PYTHON_DECIMAL_WITH_MACHINE
     63         libmpdec_config=$config
     64         if [ X"$config" != X"auto" ]; then
     65             PYTHON_DECIMAL_WITH_MACHINE=$config
     66             export PYTHON_DECIMAL_WITH_MACHINE
     67         else
     68             libmpdec_config=""
     69         fi
     70 
     71         ############ refleak tests ###########
     72         print_config "refleak tests: config=$config"
     73         printf "\nbuilding python ...\n\n"
     74 
     75         cd ../../
     76         $GMAKE distclean > /dev/null 2>&1
     77         ./configure CFLAGS="$ADD_CFLAGS" LDFLAGS="$ADD_LDFLAGS" --with-pydebug > /dev/null 2>&1
     78         $GMAKE | grep _decimal
     79 
     80         printf "\n\n# ======================== refleak tests ===========================\n\n"
     81         ./python -m test -uall -R 2:2 test_decimal
     82 
     83 
     84         ############ regular tests ###########
     85         print_config "regular tests: config=$config"
     86         printf "\nbuilding python ...\n\n"
     87 
     88         $GMAKE distclean > /dev/null 2>&1
     89         ./configure CFLAGS="$ADD_CFLAGS" LDFLAGS="$ADD_LDFLAGS" > /dev/null 2>&1
     90         $GMAKE | grep _decimal
     91 
     92         printf "\n\n# ======================== regular tests ===========================\n\n"
     93         ./python -m test -uall test_decimal
     94 
     95 
     96         ########### valgrind tests ###########
     97         valgrind=$VALGRIND
     98         case "$config" in
     99             # Valgrind has no support for 80 bit long double arithmetic.
    100             ppro) valgrind= ;;
    101             auto) case `uname -m` in
    102                       i386|i486|i586|i686) valgrind= ;;
    103                   esac
    104         esac
    105 
    106         print_config "valgrind tests: config=$config"
    107         printf "\nbuilding python ...\n\n"
    108         $GMAKE distclean > /dev/null 2>&1
    109         ./configure CFLAGS="$ADD_CFLAGS" LDFLAGS="$ADD_LDFLAGS" --without-pymalloc > /dev/null 2>&1
    110         $GMAKE | grep _decimal
    111 
    112         printf "\n\n# ======================== valgrind tests ===========================\n\n"
    113         $valgrind ./python -m test -uall test_decimal
    114 
    115         cd Modules/_decimal
    116 done
    117 
    118 # deccheck
    119 cd ../../
    120 for config in $CONFIGS; do
    121 
    122         unset PYTHON_DECIMAL_WITH_MACHINE
    123         if [ X"$config" != X"auto" ]; then
    124             PYTHON_DECIMAL_WITH_MACHINE=$config
    125             export PYTHON_DECIMAL_WITH_MACHINE
    126         fi
    127 
    128         ############ debug ############
    129         print_config "deccheck: config=$config --with-pydebug"
    130         printf "\nbuilding python ...\n\n"
    131 
    132         $GMAKE distclean > /dev/null 2>&1
    133         ./configure CFLAGS="$ADD_CFLAGS" LDFLAGS="$ADD_LDFLAGS" --with-pydebug > /dev/null 2>&1
    134         $GMAKE | grep _decimal
    135 
    136         printf "\n\n# ========================== debug ===========================\n\n"
    137         ./python Modules/_decimal/tests/deccheck.py
    138 
    139         ########### regular ###########
    140         print_config "deccheck: config=$config "
    141         printf "\nbuilding python ...\n\n"
    142 
    143         $GMAKE distclean > /dev/null 2>&1
    144         ./configure CFLAGS="$ADD_CFLAGS" LDFLAGS="$ADD_LDFLAGS" > /dev/null 2>&1
    145         $GMAKE | grep _decimal
    146 
    147         printf "\n\n# ======================== regular ===========================\n\n"
    148         ./python Modules/_decimal/tests/deccheck.py
    149 
    150         ########### valgrind ###########
    151         valgrind=$VALGRIND
    152         case "$config" in
    153             # Valgrind has no support for 80 bit long double arithmetic.
    154             ppro) valgrind= ;;
    155             auto) case `uname -m` in
    156                       i386|i486|i586|i686) valgrind= ;;
    157                   esac
    158         esac
    159 
    160         print_config "valgrind deccheck: config=$config "
    161         printf "\nbuilding python ...\n\n"
    162 
    163         $GMAKE distclean > /dev/null 2>&1
    164         ./configure CFLAGS="$ADD_CFLAGS" LDFLAGS="$ADD_LDFLAGS" --without-pymalloc > /dev/null 2>&1
    165         $GMAKE | grep _decimal
    166 
    167         printf "\n\n# ======================== valgrind ==========================\n\n"
    168         $valgrind ./python Modules/_decimal/tests/deccheck.py
    169 done
    170 
    171 
    172 
    173