source: mainline/contrib/tools/random_check.sh@ 530f2de

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 530f2de was a35b458, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 7 years ago

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

  • Property mode set to 100755
File size: 4.5 KB
Line 
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
32LOOPS=1
33JOBS=1
34MAX_RETRIES=20
35FILENAME_PREFIX=random_run_
36PRUNE_CONFIG_FILE=${FILENAME_PREFIX}prune.config
37
38echo -n "">"$PRUNE_CONFIG_FILE"
39
40while getopts n:j:x:hs option; do
41 case $option in
42 n)
43 LOOPS="$OPTARG"
44 ;;
45 j)
46 JOBS="$OPTARG"
47 ;;
48 x)
49 echo "$OPTARG" | tr -d ' ' >>"$PRUNE_CONFIG_FILE"
50 ;;
51 s)
52 echo "COMPILER=gcc_native" >>"$PRUNE_CONFIG_FILE"
53 echo "COMPILER=gcc_helenos" >>"$PRUNE_CONFIG_FILE"
54 ;;
55 *|h)
56 echo "Usage: $0 [options]"
57 echo "where [options] could be:"
58 echo
59 echo " -n LOOPS"
60 echo " How many configurations to check."
61 echo " (Default is one configuration.)"
62 echo " -j PARALLELISM"
63 echo " How many parallel jobs to execute by 'make'."
64 echo " (Default is single job configuration.)"
65 echo " -s"
66 echo " Use only supported compilers."
67 echo " (That is, only GCC cross-compiler and Clang.)"
68 echo " -x CONFIG_OPTION=value"
69 echo " Skip the configuration if this option is present."
70 echo " (Example: CONFIG_BINUTILS=n means that only configurations"
71 echo " where binutils *are* included would be built.)"
72 echo " -h"
73 echo " Print this help and exit."
74 echo
75 if [ "$option" = "h" ]; then
76 exit 0
77 else
78 exit 1
79 fi
80 ;;
81 esac
82done
83
84
85COUNTER=0
86FAILED=0
87while [ $COUNTER -lt $LOOPS ]; do
88 COUNTER=$(( $COUNTER + 1 ))
89 echo "Try #$COUNTER ($FAILED failed):" >&2
90
91 (
92 echo " Cleaning after previous build." >&2
93 make distclean -j$JOBS 2>&1 || exit 1
94
95
96 echo " Preparing random configuration." >&2
97 # It would be nicer to allow set the constraints directly to
98 # the tools/config.py script but this usually works.
99 # We retry $MAX_RETRIES before aborting this run completely.
100 RETRIES=0
101 while true; do
102 RETRIES=$(( $RETRIES + 1 ))
103 if [ $RETRIES -ge $MAX_RETRIES ]; then
104 echo " Failed to generate random configuration with given constraints after $RETRIES tries." >&2
105 exit 2
106 fi
107
108 make random-config 2>&1 || exit 1
109
110 tr -d ' ' <Makefile.config >"${FILENAME_PREFIX}config.trimmed"
111
112 THIS_CONFIG_OKAY=true
113 while read pattern; do
114 if grep -q -e "$pattern" "${FILENAME_PREFIX}config.trimmed"; then
115 THIS_CONFIG_OKAY=false
116 break
117 fi
118 done <"$PRUNE_CONFIG_FILE"
119
120 rm -f "${FILENAME_PREFIX}config.trimmed"
121
122 if $THIS_CONFIG_OKAY; then
123 break
124 fi
125 done
126
127
128 # Report basic info about the configuration and build it
129 BASIC_CONFIG=`sed -n \
130 -e 's#PLATFORM = \(.*\)#\1#p' \
131 -e 's#MACHINE = \(.*\)#\1#p' \
132 -e 's#COMPILER = \(.*\)#\1#p' \
133 Makefile.config \
134 | paste '-sd,' | sed 's#,#, #g'`
135 echo -n " Building ($BASIC_CONFIG)... " >&2
136
137 make -j$JOBS 2>&1
138 if [ $? -eq 0 ]; then
139 echo "okay." >&2
140 exit 0
141 else
142 echo "failed." >&2
143 exit 1
144 fi
145
146 ) >random_run_$COUNTER.log
147 RC=$?
148
149 if [ $RC -ne 0 ]; then
150 tail -n 10 random_run_$COUNTER.log | sed 's#.*# | &#'
151 FAILED=$(( $FAILED + 1 ))
152 fi
153
154 if [ -e Makefile.config ]; then
155 cp Makefile.config "$FILENAME_PREFIX$COUNTER.Makefile.config"
156 cp config.h "$FILENAME_PREFIX$COUNTER.config.h"
157 fi
158done
159
160rm "$PRUNE_CONFIG_FILE"
161
162echo "Out of $LOOPS tries, $FAILED configurations failed to compile." >&2
Note: See TracBrowser for help on using the repository browser.