Changeset 787510d in mainline for contrib/tools/random_check.sh


Ignore:
Timestamp:
2014-04-22T06:54:29Z (10 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
88a0f58
Parents:
170e181
Message:

random_check.sh refactoring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • contrib/tools/random_check.sh

    r170e181 r787510d  
    3737[ -z "$COMPILERS" ] && COMPILERS="gcc_cross gcc_helenos clang"
    3838
    39 
    40 run_clean() {
    41         echo "  Cleaning after previous build." >&2
    42         make distclean -j$PARALLELISM 2>&1 || exit 1
    43 }
    44 
    45 run_random_config() {
    46         echo "  Preparing random configuration." >&2
    47         make random-config 2>&1 || exit 1
    48 }
    49 
    50 run_make() {
    51         BASIC_CONFIG=`sed -n \
    52                 -e 's#PLATFORM = \(.*\)#\1#p' \
    53                 -e 's#MACHINE = \(.*\)#\1#p' \
    54                 -e 's#COMPILER = \(.*\)#\1#p' \
    55                 Makefile.config \
    56                 | paste '-sd,' | sed 's#,#, #g'`
    57        
    58         echo -n "  Building ($BASIC_CONFIG)... " >&2
    59        
    60         make -j$PARALLELISM 2>&1
    61         if [ $? -eq 0 ]; then
    62                 echo "okay." >&2
    63                 return 0
    64         else
    65                 echo "failed." >&2
    66                 return 1
    67         fi
    68 }
    69 
    70 
    71 
    7239COUNTER=0
    7340FAILED=0
    74 SKIPPED=0
    7541while [ $COUNTER -lt $LOOPS ]; do
    7642        COUNTER=$(( $COUNTER + 1 ))
    77         echo "Try #$COUNTER (F$FAILED/S$SKIPPED):" >&2
     43        echo "Try #$COUNTER ($FAILED failed):" >&2
     44       
    7845        (
    79                 run_clean
    80                 run_random_config
    81                 CC=`sed -n 's#^COMPILER = \(.*\)#\1#p' <Makefile.config`
    82                 if ! echo " $COMPILERS " | grep -q " $CC "; then
    83                         echo "  Skipping this one (compiler is $CC)." >&2
    84                         exit 2
     46                echo "  Cleaning after previous build." >&2
     47                make distclean -j$PARALLELISM 2>&1 || exit 1
     48               
     49               
     50                echo "  Preparing random configuration." >&2
     51                # It would be nicer to allow set the constraints directly to
     52                # the tools/config.py script but this usually works.
     53                # We retry several times if the compiler is wrong and abort if
     54                # we do not succeed after many attempts.
     55                RETRIES=0
     56                while true; do
     57                        RETRIES=$(( $RETRIES + 1 ))
     58                        if [ $RETRIES -ge 20 ]; then
     59                                echo "  Failed to generate random configuration with given constraints after $RETRIES tries." >&2
     60                                exit 2
     61                        fi
     62                       
     63                        make random-config 2>&1 || exit 1
     64                       
     65                        CC=`sed -n 's#^COMPILER = \(.*\)#\1#p' <Makefile.config`
     66                        if echo " $COMPILERS " | grep -q " $CC "; then
     67                                break
     68                        fi
     69                done
     70               
     71               
     72                # Report basic info about the configuration and build it
     73                BASIC_CONFIG=`sed -n \
     74                        -e 's#PLATFORM = \(.*\)#\1#p' \
     75                        -e 's#MACHINE = \(.*\)#\1#p' \
     76                        -e 's#COMPILER = \(.*\)#\1#p' \
     77                        Makefile.config \
     78                        | paste '-sd,' | sed 's#,#, #g'`
     79                echo -n "  Building ($BASIC_CONFIG)... " >&2
     80       
     81                make -j$PARALLELISM 2>&1
     82                if [ $? -eq 0 ]; then
     83                        echo "okay." >&2
     84                        exit 0
     85                else
     86                        echo "failed." >&2
     87                        exit 1
    8588                fi
    86                 run_make
    87                 exit $?
     89               
    8890        ) >random_run_$COUNTER.log
    8991        RC=$?
    90         if [ $RC -eq 2 ]; then
    91                 SKIPPED=$(( $SKIPPED + 1 ))
    92         elif [ $RC -ne 0 ]; then
     92       
     93        if [ $RC -ne 0 ]; then
    9394                tail -n 10 random_run_$COUNTER.log | sed 's#.*#    | &#'
    9495                FAILED=$(( $FAILED + 1 ))
    9596        fi
    96         cp Makefile.config random_run_$COUNTER.Makefile.config
    97         cp config.h random_run_$COUNTER.config.h       
     97       
     98        if [ -e Makefile.config ]; then
     99                cp Makefile.config random_run_$COUNTER.Makefile.config
     100                cp config.h random_run_$COUNTER.config.h
     101        fi     
    98102done
    99103
    100 echo "Out of $LOOPS tries, $SKIPPED were skipped and $FAILED configurations failed to compile." >&2
     104
     105echo "Out of $LOOPS tries, $FAILED configurations failed to compile." >&2
Note: See TracChangeset for help on using the changeset viewer.