2015-04-09 23:20:51 +00:00
|
|
|
#!/bin/bash -x
|
2007-09-10 20:28:03 +00:00
|
|
|
|
2021-12-26 22:29:28 +00:00
|
|
|
# SPDX-FileCopyrightText: 2021-2022 Ole Tange, http://ole.tange.dk and Free Software and Foundation, Inc.
|
2021-04-22 16:20:41 +00:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2012-11-21 21:28:52 +00:00
|
|
|
# Argument can be substring of tests (such as 'local')
|
|
|
|
|
2010-06-14 22:05:47 +00:00
|
|
|
export LANG=C
|
2019-09-22 05:30:08 +00:00
|
|
|
export LC_ALL=C
|
2016-08-03 21:45:13 +00:00
|
|
|
unset LC_MONETARY
|
2010-05-27 22:34:00 +00:00
|
|
|
SHFILE=/tmp/unittest-parallel.sh
|
2013-02-01 19:44:56 +00:00
|
|
|
MAX_SEC_PER_TEST=900
|
|
|
|
export TIMEOUT=$MAX_SEC_PER_TEST
|
2010-05-27 22:34:00 +00:00
|
|
|
|
2017-04-01 00:59:07 +00:00
|
|
|
run_once() {
|
|
|
|
script=$1
|
|
|
|
base=`basename "$script" .sh`
|
2015-04-27 20:56:26 +00:00
|
|
|
diff -Naur wanted-results/"$base" actual-results/"$base" >/dev/null ||
|
2017-04-01 00:59:07 +00:00
|
|
|
bash "$script" | perl -pe 's:'$HOME':~:g' > actual-results/"$base"
|
|
|
|
}
|
|
|
|
export -f run_once
|
2015-04-09 23:20:51 +00:00
|
|
|
|
2017-04-01 00:59:07 +00:00
|
|
|
run_test() {
|
|
|
|
script="$1"
|
|
|
|
base=`basename "$script" .sh`
|
|
|
|
export TMPDIR=/tmp/"$base"-tmpdir
|
|
|
|
mkdir -p "$TMPDIR"
|
|
|
|
# Clean before. May be owned by other users
|
2019-01-18 15:15:47 +00:00
|
|
|
sudo rm -f /tmp/*.{tmx,pac,arg,all,log,swp,loa,ssh,df,pip,tmb,chr,tms,par} ||
|
|
|
|
printf "%s\0" /tmp/*.par | sudo parallel -0 -X rm
|
2017-04-01 00:59:07 +00:00
|
|
|
# Force running once
|
|
|
|
echo >> actual-results/"$base"
|
|
|
|
if [ "$TRIES" = "3" ] ; then
|
|
|
|
# Try 2 times
|
|
|
|
run_once $script
|
|
|
|
run_once $script
|
|
|
|
fi
|
|
|
|
run_once $script
|
|
|
|
diff -Naur wanted-results/"$base" actual-results/"$base" ||
|
|
|
|
(touch "$script" && echo touch "$script")
|
|
|
|
|
|
|
|
# Check if it was cleaned up
|
|
|
|
find /tmp -maxdepth 1 |
|
|
|
|
perl -ne '/\.(tmx|pac|arg|all|log|swp|loa|ssh|df|pip|tmb|chr|tms|par)$/ and
|
|
|
|
++$a and
|
|
|
|
print "TMP NOT CLEAN. FOUND: $_".`touch '$script'`;'
|
|
|
|
# May be owned by other users
|
|
|
|
sudo rm -f /tmp/*.{tmx,pac,arg,all,log,swp,loa,ssh,df,pip,tmb,chr,tms,par}
|
2015-04-09 23:20:51 +00:00
|
|
|
}
|
|
|
|
export -f run_test
|
2012-11-21 21:28:52 +00:00
|
|
|
|
2020-09-23 15:41:03 +00:00
|
|
|
create_monitor_script() {
|
|
|
|
# Create a monitor script
|
|
|
|
echo forever "'echo; pstree -lp '"$$"'; pstree -l'" $$ >/tmp/monitor
|
|
|
|
chmod 755 /tmp/monitor
|
|
|
|
}
|
|
|
|
|
|
|
|
log_rotate() {
|
|
|
|
# Log rotate
|
|
|
|
mkdir -p log
|
|
|
|
seq 10 -1 1 |
|
|
|
|
parallel -j1 mv log/testsuite.log.{} log/testsuite.log.'{= $_++ =}'
|
|
|
|
mv testsuite.log log/testsuite.log.1
|
|
|
|
}
|
|
|
|
|
|
|
|
create_monitor_script
|
|
|
|
log_rotate
|
|
|
|
|
|
|
|
printf "\033[48;5;78;38;5;0m `date` \033[00m\n"
|
2010-06-25 23:56:14 +00:00
|
|
|
mkdir -p actual-results
|
2015-05-23 16:00:00 +00:00
|
|
|
ls -t tests-to-run/*${1}*.sh | egrep -v "${2}" |
|
2020-09-23 15:41:03 +00:00
|
|
|
parallel --tty -tj1 run_test | tee testsuite.log
|
2011-07-16 23:46:02 +00:00
|
|
|
# If testsuite.log contains @@ then there is a diff
|
|
|
|
if grep -q '@@' testsuite.log ; then
|
2017-04-01 00:59:07 +00:00
|
|
|
false
|
2011-07-16 23:46:02 +00:00
|
|
|
else
|
2017-04-01 00:59:07 +00:00
|
|
|
# No @@'s: So everything worked: Copy the source
|
|
|
|
rm -rf src-passing-testsuite
|
|
|
|
cp -a ../src src-passing-testsuite
|
2011-07-16 23:46:02 +00:00
|
|
|
fi
|
2020-09-23 15:41:03 +00:00
|
|
|
printf "\033[48;5;208;38;5;0m `date` \033[00m\n"
|