2011-06-26 14:06:38 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2011-07-11 09:40:23 +00:00
|
|
|
# Copyright 2011 George Danchev <danchev@spnet.net>
|
2014-03-05 09:21:17 +00:00
|
|
|
# Copyright 2011 - 2014 Thomas Schmitt <scdbackup@gmx.net>
|
2011-07-15 06:05:57 +00:00
|
|
|
# Licensed under GNU GPL version 2 or later
|
2011-07-11 09:40:23 +00:00
|
|
|
|
2011-06-26 14:06:38 +00:00
|
|
|
set -e
|
|
|
|
|
2012-04-21 15:53:14 +00:00
|
|
|
export RELENG_SCRIPT_RUN_BY_RUN_ALL_AUTO=1
|
2012-04-21 15:41:45 +00:00
|
|
|
|
2011-07-17 13:38:52 +00:00
|
|
|
SELF=$(basename "$0")
|
|
|
|
GEN_DATA_DIR=releng_generated_data
|
|
|
|
CLOG=${GEN_DATA_DIR}/log.${SELF}
|
2011-12-15 14:14:17 +00:00
|
|
|
CLOG_PREV=${CLOG}.prev
|
2011-07-17 13:38:52 +00:00
|
|
|
PASSED_OPTIONS="$@"
|
|
|
|
RELENG_XORRISO=
|
|
|
|
CLEANUP_LOG=0
|
|
|
|
|
2011-12-14 06:09:22 +00:00
|
|
|
# It is not a good idea to include inc/releng_getopts.inc with the
|
|
|
|
# master script as it calls the subordinate scripts and they include
|
|
|
|
# this file too, and we want to avoid sharing variable with subshells
|
|
|
|
if [ ! -f inc/releng_getopts.inc ]; then
|
2011-07-13 11:24:32 +00:00
|
|
|
printf "\nPlease execute the tests from releng directory.\n\n"
|
|
|
|
exit 1
|
2011-12-14 06:09:22 +00:00
|
|
|
fi
|
2011-07-13 11:24:32 +00:00
|
|
|
|
2011-07-17 13:38:52 +00:00
|
|
|
# To catch the exit value of a command in a pipe
|
|
|
|
return_value_file="$GEN_DATA_DIR"/run_all_"$$"_return_value
|
|
|
|
return_wrapper()
|
|
|
|
{
|
|
|
|
cmd="$1"
|
|
|
|
shift 1
|
|
|
|
"$cmd" "$@"
|
|
|
|
RET="$?"
|
|
|
|
echo "$RET" >"$return_value_file"
|
|
|
|
return "$RET"
|
|
|
|
}
|
|
|
|
|
2011-07-17 13:08:52 +00:00
|
|
|
# Using only bash builtin commands.
|
|
|
|
# On 4 year old amd64 x2 3000 MHz, xterm local,it counts 22471 lines per second
|
|
|
|
# On 2 year old amd64 x4 2600 MHz, ssh remote, it counts 35348 lines per second
|
|
|
|
count_lines()
|
|
|
|
{
|
|
|
|
# $1 if not empty: start count
|
|
|
|
line=
|
|
|
|
if test -n "$1"
|
|
|
|
then
|
|
|
|
count="$1"
|
|
|
|
else
|
|
|
|
count=0
|
|
|
|
fi
|
|
|
|
while read line
|
|
|
|
do
|
|
|
|
count=$(($count + 1))
|
|
|
|
printf "\r %4d lines logged ... " "$count" >&2
|
|
|
|
printf "%s\n" "$line"
|
|
|
|
done
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2017-08-08 07:52:39 +00:00
|
|
|
#############################################
|
|
|
|
# copied from releng/inc/releng_getopts.inc which is not included here.
|
|
|
|
boldify() {
|
|
|
|
if which tput >/dev/null 2>&1
|
|
|
|
then
|
|
|
|
tput smso || dummy_variable=1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
unboldify() {
|
|
|
|
if which tput >/dev/null 2>&1
|
|
|
|
then
|
|
|
|
tput rmso || dummy_variable=1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2011-12-14 06:09:22 +00:00
|
|
|
#############################################
|
|
|
|
print_usage()
|
|
|
|
{
|
|
|
|
cat << HLP
|
|
|
|
|
|
|
|
${SELF} runs executables from releng directory starting with auto_*,
|
|
|
|
and passing them its own options. stdout/stderr output is stored in:
|
2011-12-15 14:14:17 +00:00
|
|
|
./${CLOG} (last run) and
|
|
|
|
./${CLOG_PREV} (previous run)
|
2011-12-14 06:09:22 +00:00
|
|
|
|
|
|
|
Usage: ${SELF} -x path/to/xorriso [-k] [-c] [-h]
|
|
|
|
-x absolute or relative path to xorriso binary to be run.
|
|
|
|
-k keep self-generated data in ./${GEN_DATA_DIR}.
|
|
|
|
-c cleanup self-generated data kept from previous run and exit.
|
|
|
|
-h print this help text
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
# run xorriso and keep the self-generated data
|
|
|
|
$ ./${SELF} -x path/to/xorriso -k
|
|
|
|
|
|
|
|
# clean up self-generated data from previous run
|
|
|
|
$ ./${SELF} -c
|
|
|
|
|
|
|
|
HLP
|
|
|
|
}
|
2011-07-08 14:18:54 +00:00
|
|
|
|
|
|
|
#############################################
|
2011-12-14 06:09:22 +00:00
|
|
|
if [ ! "${1}" ]; then
|
|
|
|
print_usage
|
|
|
|
exit 0
|
|
|
|
fi
|
2011-07-15 17:57:05 +00:00
|
|
|
next_is=
|
|
|
|
for i in "$@"
|
2011-07-08 14:18:54 +00:00
|
|
|
do
|
2011-12-14 06:09:22 +00:00
|
|
|
if test x"$i" = x"-h" -o x"$i" = x"--h" -o x"$i" = x"-help" -o x"$i" = x"--help"
|
|
|
|
then :
|
|
|
|
print_usage
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2011-07-15 17:57:05 +00:00
|
|
|
if test "$next_is" = "ignore"
|
2011-07-17 13:38:52 +00:00
|
|
|
then :
|
2011-07-15 17:57:05 +00:00
|
|
|
elif test "$next_is" = "x"
|
|
|
|
then
|
|
|
|
RELENG_XORRISO="$i"
|
|
|
|
next_is=
|
|
|
|
elif test x"$i" = x"-x"
|
|
|
|
then
|
|
|
|
next_is="x"
|
|
|
|
elif test x"$i" = x"-c"
|
|
|
|
then
|
|
|
|
CLEANUP_LOG=1
|
|
|
|
fi
|
2011-07-08 14:18:54 +00:00
|
|
|
done
|
2011-07-15 17:57:05 +00:00
|
|
|
#############################################
|
2011-07-15 18:33:10 +00:00
|
|
|
if test "$next_is" = x
|
|
|
|
then
|
2011-07-17 17:23:36 +00:00
|
|
|
echo
|
|
|
|
echo "Option -x expects an argument (the path to the xorriso program)"
|
2011-07-15 18:33:10 +00:00
|
|
|
exit 31
|
|
|
|
fi
|
2011-06-27 15:36:56 +00:00
|
|
|
|
|
|
|
|
2011-06-28 17:55:09 +00:00
|
|
|
########################################################
|
2011-07-04 14:58:53 +00:00
|
|
|
if [ -f "${CLOG}" ]; then
|
2011-12-15 14:14:17 +00:00
|
|
|
mv "${CLOG}" "${CLOG_PREV}"
|
2011-07-04 14:58:53 +00:00
|
|
|
fi
|
2011-07-02 17:55:04 +00:00
|
|
|
> ${CLOG}
|
2011-07-09 09:49:10 +00:00
|
|
|
if [ -x "${RELENG_XORRISO}" ]; then
|
2011-08-10 10:04:56 +00:00
|
|
|
echo "_OVERVIEW_______________________________________________________________" >> ${CLOG}
|
|
|
|
date -u >> ${CLOG}
|
2011-07-09 09:49:10 +00:00
|
|
|
${RELENG_XORRISO} --version >> ${CLOG}
|
2011-08-10 10:04:56 +00:00
|
|
|
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> ${CLOG}
|
2011-07-09 09:49:10 +00:00
|
|
|
fi
|
2011-08-10 10:04:56 +00:00
|
|
|
DSTART=`date -u`
|
2011-08-10 11:33:47 +00:00
|
|
|
echo "${SELF}: Started at ${DSTART}" | tee -a ${CLOG}
|
2011-06-27 19:23:14 +00:00
|
|
|
E1=`date '+%s'`
|
2011-08-10 10:04:56 +00:00
|
|
|
exit_value=0
|
2011-07-18 12:21:39 +00:00
|
|
|
# require ^auto_, avoid running (your)self explicitly
|
|
|
|
for s in `ls | grep ^auto_ | grep -v ${SELF} | sort -n`; do
|
2011-06-27 19:23:14 +00:00
|
|
|
if [ -x ${s} -a ! -d ${s} ]; then
|
2011-08-10 10:04:56 +00:00
|
|
|
echo >> ${CLOG}
|
|
|
|
echo >> ${CLOG}
|
|
|
|
echo "_STARTING_TEST_________________________________________________________" >> ${CLOG}
|
|
|
|
echo "${SELF}: Running ./${s} ${PASSED_OPTIONS} :" \
|
2011-07-17 13:08:52 +00:00
|
|
|
| tee -a ${CLOG}
|
2011-06-27 19:23:14 +00:00
|
|
|
T1=`date '+%s'`
|
|
|
|
set +e
|
2011-07-17 13:38:52 +00:00
|
|
|
|
2014-03-05 09:21:17 +00:00
|
|
|
return_wrapper ./${s} ${PASSED_OPTIONS} 2>&1 | count_lines >> ${CLOG}
|
|
|
|
RET=$(cat "$return_value_file")
|
|
|
|
rm "$return_value_file"
|
|
|
|
|
2011-07-17 13:38:52 +00:00
|
|
|
# echo "RET='$RET'" >/dev/tty
|
|
|
|
|
2011-06-27 19:23:14 +00:00
|
|
|
T2=`date '+%s'`
|
2011-08-14 11:19:38 +00:00
|
|
|
TS=`expr ${T2} - ${T1}`
|
2011-06-27 19:23:14 +00:00
|
|
|
case ${RET} in
|
|
|
|
0)
|
2011-08-10 11:33:47 +00:00
|
|
|
echo "done in ${TS} sec. ok."
|
2011-06-27 19:23:14 +00:00
|
|
|
;;
|
|
|
|
*)
|
2011-08-10 10:04:56 +00:00
|
|
|
exit_value=2
|
2011-07-09 18:00:05 +00:00
|
|
|
printf "done in ${TS} sec. "
|
2017-08-08 07:52:39 +00:00
|
|
|
boldify
|
2011-07-09 18:00:05 +00:00
|
|
|
printf "FAIL -> EXIT CODE $RET"
|
2017-08-08 07:52:39 +00:00
|
|
|
unboldify
|
2011-08-10 11:33:47 +00:00
|
|
|
echo
|
2011-06-27 19:23:14 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
set -e
|
|
|
|
fi
|
|
|
|
done
|
2011-06-26 15:16:10 +00:00
|
|
|
|
2011-08-10 10:04:56 +00:00
|
|
|
DEND=`date -u`
|
|
|
|
echo | tee -a ${CLOG}
|
|
|
|
echo -n "${SELF}: Stopped at ${DEND}." | tee -a ${CLOG}
|
2011-07-08 14:18:54 +00:00
|
|
|
if [ "${CLEANUP_LOG}" -eq 1 ]; then
|
|
|
|
if [ -f "${CLOG}" ]; then
|
|
|
|
rm -f "${CLOG}"
|
2011-08-10 10:04:56 +00:00
|
|
|
echo # | tee -a ${CLOG}
|
|
|
|
echo -n "${SELF}: Removed my own log ${CLOG}." # | tee -a ${CLOG}
|
2011-07-08 14:18:54 +00:00
|
|
|
fi
|
2011-12-15 14:14:17 +00:00
|
|
|
if [ -f "${CLOG_PREV}" ]; then
|
|
|
|
rm -f "${CLOG_PREV}"
|
2011-08-10 10:04:56 +00:00
|
|
|
echo # | tee -a ${CLOG}
|
2011-12-15 14:14:17 +00:00
|
|
|
echo "${SELF}: Removed my own log ${CLOG_PREV}." # | tee -a ${CLOG}
|
2011-07-08 14:18:54 +00:00
|
|
|
fi
|
2011-06-28 17:55:09 +00:00
|
|
|
else
|
2011-07-04 16:05:24 +00:00
|
|
|
E2=`date '+%s'`
|
2011-07-09 07:33:33 +00:00
|
|
|
if [ ${E2} -eq ${E1} ]; then
|
2011-08-10 10:04:56 +00:00
|
|
|
echo " Total elapsed 0 sec." | tee -a ${CLOG}
|
2011-07-09 07:33:33 +00:00
|
|
|
else
|
2011-08-14 11:19:38 +00:00
|
|
|
ES=`expr ${E2} - ${E1}`
|
2011-08-10 10:04:56 +00:00
|
|
|
echo " Total elapsed ${ES} sec." | tee -a ${CLOG}
|
2011-07-09 07:33:33 +00:00
|
|
|
fi
|
2011-07-04 16:05:24 +00:00
|
|
|
#####
|
2011-08-10 10:04:56 +00:00
|
|
|
echo >> ${CLOG}
|
|
|
|
echo "_SUMMARY________________________________________________________________" >> ${CLOG}
|
|
|
|
echo "${SELF}: Trivial log examination: ${CLOG}" | tee -a ${CLOG}
|
|
|
|
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" | tee -a ${CLOG}
|
2011-07-04 16:05:24 +00:00
|
|
|
# severity classes of libdax_msgs.h in libburn and libisofs
|
|
|
|
# List of boring keywords:
|
2011-07-24 14:49:43 +00:00
|
|
|
# 'UPDATE|NOTE|DEBUG|ALL' - not considered interesting for lazy log inspection.
|
2011-07-04 16:05:24 +00:00
|
|
|
# List of interesting keywords:
|
2011-07-05 12:07:32 +00:00
|
|
|
# thrown by xorriso and underlying libraries
|
2011-08-10 10:04:56 +00:00
|
|
|
LIST_KWD="NEVER|ABORT|FATAL|FAILURE|MISHAP|SORRY|WARNING|HINT"
|
2011-07-05 12:07:32 +00:00
|
|
|
# thrown by others
|
2011-08-10 10:04:56 +00:00
|
|
|
LIST_KWD="${LIST_KWD}|FAIL|ERROR|WRONG"
|
2011-07-04 16:05:24 +00:00
|
|
|
|
|
|
|
if [ -f "${CLOG}" ]; then
|
2011-07-04 17:16:47 +00:00
|
|
|
set +e
|
|
|
|
# lines, perl regex, leading tabs
|
2011-08-10 10:04:56 +00:00
|
|
|
grep -n -E "${LIST_KWD}" "${CLOG}"
|
2011-07-04 17:16:47 +00:00
|
|
|
RET_GREP="$?"
|
2022-07-02 07:03:43 +00:00
|
|
|
ok=0
|
2011-07-04 17:16:47 +00:00
|
|
|
case ${RET_GREP} in
|
|
|
|
0) # found
|
|
|
|
;;
|
|
|
|
1) # not found
|
2011-08-10 10:04:56 +00:00
|
|
|
echo "${SELF}: Log file looks clear." # | tee -a ${CLOG}
|
2022-07-02 07:03:43 +00:00
|
|
|
ok=1
|
2011-07-04 17:16:47 +00:00
|
|
|
;;
|
|
|
|
*) #
|
2011-08-10 10:04:56 +00:00
|
|
|
echo "${SELF}: grep returned EXIT CODE: ${RET_GREP}." # | tee -a ${CLOG}
|
2011-07-04 17:16:47 +00:00
|
|
|
;;
|
|
|
|
esac
|
2022-07-02 07:03:43 +00:00
|
|
|
if test "$ok" = 0 && test "$exit_value" = 0
|
|
|
|
then
|
|
|
|
exit_value=1
|
|
|
|
fi
|
2011-07-04 17:16:47 +00:00
|
|
|
set -e
|
2011-07-04 16:05:24 +00:00
|
|
|
fi
|
2011-08-10 10:04:56 +00:00
|
|
|
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" | tee -a ${CLOG}
|
2011-07-05 05:45:48 +00:00
|
|
|
|
|
|
|
##### TODO: work out a less noisy diff'ing technique!
|
2011-12-15 14:14:17 +00:00
|
|
|
if [ -f "${CLOG_PREV}" -a -f "${CLOG}" ]; then
|
2011-08-10 10:04:56 +00:00
|
|
|
echo "${SELF}: See diff against previous log file (might be long):" | tee -a ${CLOG}
|
2011-12-15 14:14:17 +00:00
|
|
|
echo "diff -Naur ${CLOG_PREV} ${CLOG} | less" | tee -a ${CLOG}
|
2011-07-05 05:45:48 +00:00
|
|
|
fi
|
2011-07-11 08:31:03 +00:00
|
|
|
|
2011-06-28 17:55:09 +00:00
|
|
|
fi
|
2011-07-09 07:33:33 +00:00
|
|
|
|
|
|
|
#
|
2017-08-08 07:52:39 +00:00
|
|
|
boldify
|
2011-08-10 10:04:56 +00:00
|
|
|
echo # | tee -a ${CLOG}
|
|
|
|
echo "${SELF}: Leaving the following cruft in ${GEN_DATA_DIR}:" # | tee -a ${CLOG}
|
2017-08-08 07:52:39 +00:00
|
|
|
unboldify
|
2011-07-11 08:31:03 +00:00
|
|
|
ls -lth "${GEN_DATA_DIR}" # | tee -a ${CLOG}
|
2011-06-26 15:16:10 +00:00
|
|
|
|
2011-07-08 14:18:54 +00:00
|
|
|
# Fin
|
2022-07-02 07:03:43 +00:00
|
|
|
if test "$exit_value" = 0
|
|
|
|
then
|
|
|
|
echo "${SELF}: +++ Test run and its log look like success."
|
|
|
|
else
|
|
|
|
echo
|
|
|
|
echo "${SELF}: --- Test run detected some failures."
|
|
|
|
echo
|
|
|
|
fi
|
2011-08-10 10:04:56 +00:00
|
|
|
exit $exit_value
|
|
|
|
|