diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c149106..8b30053 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -54,7 +54,7 @@ jobs: - name: regression tests if: matrix.printf == 'normal' env: - REGTEST_NO_UTF8: 1 + REGTEST_PARALLEL: 1 run: mkdir /var/tmp/regtest && ./regtest/runtests.sh win: runs-on: windows-latest @@ -120,7 +120,7 @@ jobs: - name: run regression tests if: matrix.printf == 'normal' env: - REGTEST_NO_UTF8: 1 + REGTEST_PARALLEL: 1 run: mkdir /var/tmp/regtest && ./regtest/runtests.sh linux: @@ -170,5 +170,5 @@ jobs: - name: regression tests if: matrix.printf == 'normal' env: - REGTEST_NO_UTF8: 1 + REGTEST_PARALLEL: 1 run: mkdir /var/tmp/regtest && ./regtest/runtests.sh diff --git a/regtest/common.bash b/regtest/common.bash index ce629ff..d10eccc 100644 --- a/regtest/common.bash +++ b/regtest/common.bash @@ -27,9 +27,9 @@ if ! test -d $LOGDIR; then LOGDIR=/tmp fi LOGFILE="$LOGDIR/log.txt" -DIFFLOG="$LOGDIR/difflog.txt" -NEWLOG="$LOGDIR/newlog.txt" -TMPLOG="$LOGDIR/tmplog.txt" +DIFFLOG="$LOGDIR/difflog_${CODEC_PREFIX}.txt" +NEWLOG="$LOGDIR/newlog_${CODEC_PREFIX}.txt" +TMPLOG="$LOGDIR/tmplog_${CODEC_PREFIX}.txt" UNAME="$(uname -s)" @@ -43,6 +43,12 @@ if ! $MD5SUM $RNDSEQ >/dev/null 2>&1; then MD5SUM=../simple-md5sum fi +if [ "$REGTEST_PARALLEL" = 1 ]; then + REGTEST_NO_UTF8=1 +fi + +trap 'ret=$?; [ -n "$RETFILE" ] && echo $((nbfailed + ret)) > $RETFILE' EXIT + nbfailed=0 # For MSYS2 @@ -88,18 +94,33 @@ case "${param[0]}" in ;; esac -# Sanity check - -echo -n "Checking for $NEWVER: " -if test -x $NEWVER; then - echo "OK" -else - echo "missing." - exit 1 -fi - ### Helper functions +# Handle echo -n properly even in parallel mode + +printbuf='' +function echo_n() +{ + if [ "$REGTEST_PARALLEL" = 1 ]; then + printbuf="${printbuf}$*" + else + echo -n "$*" + fi +} + +# Handle "echo" even in parallel mode (output buf if parallel) + +function echo_line() +{ + if [ "$REGTEST_PARALLEL" = 1 ]; then + printbuf="${printbuf}$*" + echo "$printbuf" + else + echo "$*" + fi + printbuf='' +} + # See if file needs to be created function file_exists() @@ -166,7 +187,7 @@ function try() if [ "$REGTEST_NO_UTF8" != 1 ]; then echo -n "[ ] " fi - echo -n "${CODEC_PREFIX} - ${REGTEST_SECTION} - $1 - " + echo_n "${CODEC_PREFIX} - ${REGTEST_SECTION} - $1 - " return 0 else if [ "$REGTEST_NO_UTF8" != 1 ]; then @@ -242,7 +263,7 @@ function run_regtest() if ! test -r $REFLOG; then pass="false" if [ "$REGTEST_NO_UTF8" = 1 ]; then - echo "BAD; '$REFLOG' is missing in log file database" + echo_line "BAD; '$REFLOG' is missing in log file database" else printf "%b\r%b\n" "BAD; '$REFLOG' is missing in log file database" "[\e[31m✘\e[0m]" fi @@ -274,7 +295,7 @@ function run_regtest() if ! diff <(tail -n +3 $REFLOG | $filter) <(cat $NEWLOG | $filter) >${DIFFLOG}; then if [ "$REGTEST_NO_UTF8" = 1 ]; then - echo "BAD; diffs found (created):" + echo_line "BAD; diffs found (created):" else printf "%b\r%b\n" "BAD; diffs found (created):" "[\e[31m✘\e[0m]" fi @@ -335,7 +356,7 @@ function run_regtest() md5=$($MD5SUM ${testiso} | cut -d\ -f 1) if test "$image_md5" != "$md5"; then if [ "$REGTEST_NO_UTF8" = 1 ]; then - echo "BAD; md5 sum mismatch in image file:" + echo_line "BAD; md5 sum mismatch in image file:" else printf "%b\r%b\n" "BAD; md5 sum mismatch in image file:" "[\e[31m✘\e[0m]" fi @@ -349,7 +370,7 @@ function run_regtest() md5=$($MD5SUM ${testecc} | cut -d\ -f 1) if test "$ecc_md5" != "$md5"; then if [ "$pass" = false ] || [ "$REGTEST_NO_UTF8" = 1 ]; then - echo "BAD; md5 sum mismatch in ecc file:" + echo_line "BAD; md5 sum mismatch in ecc file:" else printf "%b\r%b\n" "BAD; md5 sum mismatch in ecc file:" "[\e[31m✘\e[0m]" fi @@ -362,7 +383,7 @@ function run_regtest() case "${pass}" in true) if [ "$REGTEST_NO_UTF8" = 1 ]; then - echo GOOD + echo_line GOOD else printf "%b\r%b\n" "GOOD" "[\e[32m✓\e[0m]" fi @@ -404,3 +425,13 @@ function run_regtest() FILE_MSG="" fi } + +# Sanity check + +echo_n "Checking for $NEWVER: " +if test -x $NEWVER; then + echo_line "OK" +else + echo_line "missing." + exit 1 +fi diff --git a/regtest/rs01.bash b/regtest/rs01.bash index fefe065..abc4dc7 100755 --- a/regtest/rs01.bash +++ b/regtest/rs01.bash @@ -1,5 +1,6 @@ #!/usr/bin/env bash +CODEC_PREFIX=RS01 . common.bash ISOSIZE=21000 @@ -11,8 +12,6 @@ TMPISO=$TMPDIR/rs01-tmp.iso TMPECC=$TMPDIR/rs01-tmp.ecc SIMISO=$TMPDIR/rs01-sim.iso -CODEC_PREFIX=RS01 - # Create master image and ecc file if ! file_exists $MASTERISO; then diff --git a/regtest/rs02.bash b/regtest/rs02.bash index 73665ae..e850cda 100755 --- a/regtest/rs02.bash +++ b/regtest/rs02.bash @@ -1,5 +1,6 @@ #!/usr/bin/env bash +CODEC_PREFIX=RS02 . common.bash ISOSIZE=30000 @@ -14,8 +15,6 @@ NO_FILE=$TMPDIR/none.file ISO_PLUS137=$ISODIR/rs02-plus137.iso -CODEC_PREFIX=RS02 - # Create master image if ! file_exists $MASTERISO; then diff --git a/regtest/rs03f.bash b/regtest/rs03f.bash index 76427ec..b3fc0dd 100755 --- a/regtest/rs03f.bash +++ b/regtest/rs03f.bash @@ -1,5 +1,6 @@ #!/usr/bin/env bash +CODEC_PREFIX=RS03f . common.bash ISOSIZE=21000 @@ -10,7 +11,6 @@ MASTERECC=$ISODIR/rs03f-master.ecc SIMISO=$TMPDIR/rs03f-sim.iso TMPISO=$TMPDIR/rs03f-tmp.iso TMPECC=$TMPDIR/rs03f-tmp.ecc -CODEC_PREFIX=RS03f # Create master image diff --git a/regtest/rs03i.bash b/regtest/rs03i.bash index f71b74d..7921397 100755 --- a/regtest/rs03i.bash +++ b/regtest/rs03i.bash @@ -1,5 +1,6 @@ #!/usr/bin/env bash +CODEC_PREFIX=RS03i . common.bash ISOSIZE=21000 @@ -17,8 +18,6 @@ LMI_HEADER=235219 LMI_LAYER_SIZE=1409 LMI_FIRSTCRC=235303 -CODEC_PREFIX=RS03i - # Create master image if ! file_exists $MASTERISO; then diff --git a/regtest/runtests.sh b/regtest/runtests.sh index ced1b10..25c0d0e 100755 --- a/regtest/runtests.sh +++ b/regtest/runtests.sh @@ -1,10 +1,27 @@ #!/usr/bin/env bash cd "$(dirname "$0")" + +export DVDISASTER_SCSI_SIMULATED_NODELAY=1 + +if [ "$REGTEST_PARALLEL" = 1 ]; then + for i in rs*.bash; do + ( RETFILE=/tmp/result.$i REGTEST_NO_UTF8=1 ./$i ) & + done + wait +else + for i in rs*.bash; do + RETFILE=/tmp/result.$i ./$i + done +fi + allfailed=0 for i in rs*.bash; do - ( DVDISASTER_SCSI_SIMULATED_NODELAY=1 ./$i ); ret=$? + ret=$(cat /tmp/result.$i) + [ -z "$ret" ] && ret=1 + rm -f /tmp/result.$i allfailed=$((allfailed + ret)) done + echo Failed $allfailed tests [ $allfailed -ge 256 ] && allfailed=255 exit $allfailed