"Fossies" - the Fresh Open Source Software Archive 
Member "xorriso-1.5.4/releng/run_all_auto" (8 Aug 2017, 7103 Bytes) of package /linux/misc/xorriso-1.5.4.pl02.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the last
Fossies "Diffs" side-by-side code changes report for "run_all_auto":
1.4.6_vs_1.4.8.
1 #!/bin/bash
2
3 # Copyright 2011 George Danchev <danchev@spnet.net>
4 # Copyright 2011 - 2014 Thomas Schmitt <scdbackup@gmx.net>
5 # Licensed under GNU GPL version 2 or later
6
7 set -e
8
9 export RELENG_SCRIPT_RUN_BY_RUN_ALL_AUTO=1
10
11 SELF=$(basename "$0")
12 GEN_DATA_DIR=releng_generated_data
13 CLOG=${GEN_DATA_DIR}/log.${SELF}
14 CLOG_PREV=${CLOG}.prev
15 PASSED_OPTIONS="$@"
16 RELENG_XORRISO=
17 CLEANUP_LOG=0
18
19 # It is not a good idea to include inc/releng_getopts.inc with the
20 # master script as it calls the subordinate scripts and they include
21 # this file too, and we want to avoid sharing variable with subshells
22 if [ ! -f inc/releng_getopts.inc ]; then
23 printf "\nPlease execute the tests from releng directory.\n\n"
24 exit 1
25 fi
26
27 # To catch the exit value of a command in a pipe
28 return_value_file="$GEN_DATA_DIR"/run_all_"$$"_return_value
29 return_wrapper()
30 {
31 cmd="$1"
32 shift 1
33 "$cmd" "$@"
34 RET="$?"
35 echo "$RET" >"$return_value_file"
36 return "$RET"
37 }
38
39 # Using only bash builtin commands.
40 # On 4 year old amd64 x2 3000 MHz, xterm local,it counts 22471 lines per second
41 # On 2 year old amd64 x4 2600 MHz, ssh remote, it counts 35348 lines per second
42 count_lines()
43 {
44 # $1 if not empty: start count
45 line=
46 if test -n "$1"
47 then
48 count="$1"
49 else
50 count=0
51 fi
52 while read line
53 do
54 count=$(($count + 1))
55 printf "\r %4d lines logged ... " "$count" >&2
56 printf "%s\n" "$line"
57 done
58 return 0
59 }
60
61 #############################################
62 # copied from releng/inc/releng_getopts.inc which is not included here.
63 boldify() {
64 if which tput >/dev/null 2>&1
65 then
66 tput smso || dummy_variable=1
67 fi
68 }
69
70 unboldify() {
71 if which tput >/dev/null 2>&1
72 then
73 tput rmso || dummy_variable=1
74 fi
75 }
76
77 #############################################
78 print_usage()
79 {
80 cat << HLP
81
82 ${SELF} runs executables from releng directory starting with auto_*,
83 and passing them its own options. stdout/stderr output is stored in:
84 ./${CLOG} (last run) and
85 ./${CLOG_PREV} (previous run)
86
87 Usage: ${SELF} -x path/to/xorriso [-k] [-c] [-h]
88 -x absolute or relative path to xorriso binary to be run.
89 -k keep self-generated data in ./${GEN_DATA_DIR}.
90 -c cleanup self-generated data kept from previous run and exit.
91 -h print this help text
92
93 Examples:
94 # run xorriso and keep the self-generated data
95 $ ./${SELF} -x path/to/xorriso -k
96
97 # clean up self-generated data from previous run
98 $ ./${SELF} -c
99
100 HLP
101 }
102
103 #############################################
104 if [ ! "${1}" ]; then
105 print_usage
106 exit 0
107 fi
108 next_is=
109 for i in "$@"
110 do
111 if test x"$i" = x"-h" -o x"$i" = x"--h" -o x"$i" = x"-help" -o x"$i" = x"--help"
112 then :
113 print_usage
114 exit 0
115 fi
116
117 if test "$next_is" = "ignore"
118 then :
119 elif test "$next_is" = "x"
120 then
121 RELENG_XORRISO="$i"
122 next_is=
123 elif test x"$i" = x"-x"
124 then
125 next_is="x"
126 elif test x"$i" = x"-c"
127 then
128 CLEANUP_LOG=1
129 fi
130 done
131 #############################################
132 if test "$next_is" = x
133 then
134 echo
135 echo "Option -x expects an argument (the path to the xorriso program)"
136 exit 31
137 fi
138
139
140 ########################################################
141 if [ -f "${CLOG}" ]; then
142 mv "${CLOG}" "${CLOG_PREV}"
143 fi
144 > ${CLOG}
145 if [ -x "${RELENG_XORRISO}" ]; then
146 echo "_OVERVIEW_______________________________________________________________" >> ${CLOG}
147 date -u >> ${CLOG}
148 ${RELENG_XORRISO} --version >> ${CLOG}
149 echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> ${CLOG}
150 fi
151 DSTART=`date -u`
152 echo "${SELF}: Started at ${DSTART}" | tee -a ${CLOG}
153 E1=`date '+%s'`
154 exit_value=0
155 # require ^auto_, avoid running (your)self explicitly
156 for s in `ls | grep ^auto_ | grep -v ${SELF} | sort -n`; do
157 if [ -x ${s} -a ! -d ${s} ]; then
158 echo >> ${CLOG}
159 echo >> ${CLOG}
160 echo "_STARTING_TEST_________________________________________________________" >> ${CLOG}
161 echo "${SELF}: Running ./${s} ${PASSED_OPTIONS} :" \
162 | tee -a ${CLOG}
163 T1=`date '+%s'`
164 set +e
165
166 return_wrapper ./${s} ${PASSED_OPTIONS} 2>&1 | count_lines >> ${CLOG}
167 RET=$(cat "$return_value_file")
168 rm "$return_value_file"
169
170 # echo "RET='$RET'" >/dev/tty
171
172 T2=`date '+%s'`
173 TS=`expr ${T2} - ${T1}`
174 case ${RET} in
175 0)
176 echo "done in ${TS} sec. ok."
177 ;;
178 *)
179 exit_value=2
180 printf "done in ${TS} sec. "
181 boldify
182 printf "FAIL -> EXIT CODE $RET"
183 unboldify
184 echo
185 ;;
186 esac
187 set -e
188 fi
189 done
190
191 DEND=`date -u`
192 echo | tee -a ${CLOG}
193 echo -n "${SELF}: Stopped at ${DEND}." | tee -a ${CLOG}
194 if [ "${CLEANUP_LOG}" -eq 1 ]; then
195 if [ -f "${CLOG}" ]; then
196 rm -f "${CLOG}"
197 echo # | tee -a ${CLOG}
198 echo -n "${SELF}: Removed my own log ${CLOG}." # | tee -a ${CLOG}
199 fi
200 if [ -f "${CLOG_PREV}" ]; then
201 rm -f "${CLOG_PREV}"
202 echo # | tee -a ${CLOG}
203 echo "${SELF}: Removed my own log ${CLOG_PREV}." # | tee -a ${CLOG}
204 fi
205 else
206 E2=`date '+%s'`
207 if [ ${E2} -eq ${E1} ]; then
208 echo " Total elapsed 0 sec." | tee -a ${CLOG}
209 else
210 ES=`expr ${E2} - ${E1}`
211 echo " Total elapsed ${ES} sec." | tee -a ${CLOG}
212 fi
213 #####
214 echo >> ${CLOG}
215 echo "_SUMMARY________________________________________________________________" >> ${CLOG}
216 echo "${SELF}: Trivial log examination: ${CLOG}" | tee -a ${CLOG}
217 echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" | tee -a ${CLOG}
218 # severity classes of libdax_msgs.h in libburn and libisofs
219 # List of boring keywords:
220 # 'UPDATE|NOTE|DEBUG|ALL' - not considered interesting for lazy log inspection.
221 # List of interesting keywords:
222 # thrown by xorriso and underlying libraries
223 LIST_KWD="NEVER|ABORT|FATAL|FAILURE|MISHAP|SORRY|WARNING|HINT"
224 # thrown by others
225 LIST_KWD="${LIST_KWD}|FAIL|ERROR|WRONG"
226
227 if [ -f "${CLOG}" ]; then
228 set +e
229 # lines, perl regex, leading tabs
230 grep -n -E "${LIST_KWD}" "${CLOG}"
231 RET_GREP="$?"
232 case ${RET_GREP} in
233 0) # found
234 ;;
235 1) # not found
236 echo "${SELF}: Log file looks clear." # | tee -a ${CLOG}
237 ;;
238 *) #
239 echo "${SELF}: grep returned EXIT CODE: ${RET_GREP}." # | tee -a ${CLOG}
240 ;;
241 esac
242 set -e
243 fi
244 echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" | tee -a ${CLOG}
245
246 ##### TODO: work out a less noisy diff'ing technique!
247 if [ -f "${CLOG_PREV}" -a -f "${CLOG}" ]; then
248 echo "${SELF}: See diff against previous log file (might be long):" | tee -a ${CLOG}
249 echo "diff -Naur ${CLOG_PREV} ${CLOG} | less" | tee -a ${CLOG}
250 fi
251
252 fi
253
254 #
255 boldify
256 echo # | tee -a ${CLOG}
257 echo "${SELF}: Leaving the following cruft in ${GEN_DATA_DIR}:" # | tee -a ${CLOG}
258 unboldify
259 ls -lth "${GEN_DATA_DIR}" # | tee -a ${CLOG}
260
261 # Fin
262 exit $exit_value
263