| 1 | #!/bin/sh
|
|---|
| 2 |
|
|---|
| 3 | #
|
|---|
| 4 | # Copyright (c) 2014 Vojtech Horky
|
|---|
| 5 | # All rights reserved.
|
|---|
| 6 | #
|
|---|
| 7 | # Redistribution and use in source and binary forms, with or without
|
|---|
| 8 | # modification, are permitted provided that the following conditions
|
|---|
| 9 | # are met:
|
|---|
| 10 | #
|
|---|
| 11 | # - Redistributions of source code must retain the above copyright
|
|---|
| 12 | # notice, this list of conditions and the following disclaimer.
|
|---|
| 13 | # - Redistributions in binary form must reproduce the above copyright
|
|---|
| 14 | # notice, this list of conditions and the following disclaimer in the
|
|---|
| 15 | # documentation and/or other materials provided with the distribution.
|
|---|
| 16 | # - The name of the author may not be used to endorse or promote products
|
|---|
| 17 | # derived from this software without specific prior written permission.
|
|---|
| 18 | #
|
|---|
| 19 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|---|
| 20 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|---|
| 21 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|---|
| 22 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 23 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|---|
| 24 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 25 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|---|
| 26 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 28 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 29 | #
|
|---|
| 30 |
|
|---|
| 31 | LOOPS="$1"
|
|---|
| 32 | PARALLELISM="$2"
|
|---|
| 33 | COMPILERS="$3"
|
|---|
| 34 | [ -z "$LOOPS" ] && LOOPS=1
|
|---|
| 35 | [ -z "$PARALLELISM" ] && PARALLELISM=1
|
|---|
| 36 | # By default, skip icc and native GCC
|
|---|
| 37 | [ -z "$COMPILERS" ] && COMPILERS="gcc_cross gcc_helenos clang"
|
|---|
| 38 |
|
|---|
| 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 |
|
|---|
| 72 | COUNTER=0
|
|---|
| 73 | FAILED=0
|
|---|
| 74 | SKIPPED=0
|
|---|
| 75 | while [ $COUNTER -lt $LOOPS ]; do
|
|---|
| 76 | COUNTER=$(( $COUNTER + 1 ))
|
|---|
| 77 | echo "Try #$COUNTER (F$FAILED/S$SKIPPED):" >&2
|
|---|
| 78 | (
|
|---|
| 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
|
|---|
| 85 | fi
|
|---|
| 86 | run_make
|
|---|
| 87 | exit $?
|
|---|
| 88 | ) >random_run_$COUNTER.log
|
|---|
| 89 | RC=$?
|
|---|
| 90 | if [ $RC -eq 2 ]; then
|
|---|
| 91 | SKIPPED=$(( $SKIPPED + 1 ))
|
|---|
| 92 | elif [ $RC -ne 0 ]; then
|
|---|
| 93 | tail -n 10 random_run_$COUNTER.log | sed 's#.*# | &#'
|
|---|
| 94 | FAILED=$(( $FAILED + 1 ))
|
|---|
| 95 | fi
|
|---|
| 96 | cp Makefile.config random_run_$COUNTER.Makefile.config
|
|---|
| 97 | cp config.h random_run_$COUNTER.config.h
|
|---|
| 98 | done
|
|---|
| 99 |
|
|---|
| 100 | echo "Out of $LOOPS tries, $SKIPPED were skipped and $FAILED configurations failed to compile." >&2
|
|---|