diff --git a/testcases/integration-tests.sh b/testcases/integration-tests.sh
index 5b9bbebf..b522bda0 100755
--- a/testcases/integration-tests.sh
+++ b/testcases/integration-tests.sh
@@ -1,307 +1,307 @@
#!/bin/bash
# Copyright 2018-2020 The KPhotoAlbum Development Team
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
export LC_ALL=C
myname=`basename "$0"`
mydir=`dirname "$0"`
DEPS="kphotoalbum convert exiv2 kdialog"
# basic kphotoalbumrc options to make testing less annoying (i.e. prevent some pop-ups):
BASE_RC="\n[Thumbnails]\ndisplayCategories=true\n[Notification Messages]\nimage_config_typein_show_help=false\n[TipOfDay]\nRunOnStart=false"
TEMPDIR=
KEEP_TEMPDIR=0
declare -A _checks _context _check_db_file
result_ok=0
result_failed=1
result_err_crash=2
result_err_setup=3
declare -A LOG_LEVELS
LOG_LEVELS[debug]=0
LOG_LEVELS[info]=1
LOG_LEVELS[notice]=2
LOG_LEVELS[warning]=3
LOG_LEVELS[err]=4
# default log level:
LOG_LEVEL=2
### functions
cleanup()
{
if [[ "$KEEP_TEMPDIR" == 1 ]]
then
log info "NOT removing temporary directory '$TEMPDIR'."
else
if [[ -d "$TEMPDIR" ]]
then
log debug "Removing '$TEMPDIR'..."
rm -rf "$TEMPDIR"
fi
fi
}
log()
{
lvl="$1"
shift
if [ "${LOG_LEVELS[$lvl]}" -ge "$LOG_LEVEL" ]
then
echo "$myname[$lvl]: $*" >&2
fi
}
print_help()
{
echo "Usage: $myname --check ] [PARAMETERS...] [--all|CHECKS...]" >&2
echo " $myname --help" >&2
echo " $myname --list" >&2
echo " $myname --print" >&2
echo "" >&2
echo "List or run integration tests for KPhotoAlbum." >&2
echo "This script allows guided integration tests that present the user with concrete things to check." >&2
echo "" >&2
echo "Modes:" >&2
echo "-c|--check Run the specified checks." >&2
echo "-l|--list List available checks." >&2
echo "-p|--print Print available checks with description." >&2
echo "" >&2
echo "Parameters:" >&2
echo "--all Run all tests (only valid for --check)." >&2
echo "--keep-tempdir Do not remove temporary files." >&2
echo "--log-level debug|info|notice|warning|err Set log level (default: notice)." >&2
echo "--tempdir DIR Use DIR for temporary files (implies --keep-tempdir)." >&2
echo "" >&2
}
setup_check()
# setup_check DIR
# sets up a demo db in DIR/db
{
local check_dir="$1"
if ! mkdir "$check_dir" "$check_dir/db" "$check_dir/QtProject"
then
log err "Could not create check directories for prefix '$check_dir'!"
return 1
fi
# set logging rules
cat > "$check_dir/QtProject/qtlogging.ini" <$check_name${_context[$check_name]}"
export XDG_CONFIG_HOME="$check_dir"
prepare_$check_name "$check_dir"
call_$check_name "$check_dir" > "$check_dir/log" 2>&1 || return $result_err_crash
local check_db_file="$mydir/${_check_db_file[$check_name]}"
if [[ -n "$check_db_file" ]]
then
test -f "$check_db_file" || echo "$check_db_file does not exist!"
if ! diff -u "$check_db_file" "$check_dir/db/index.xml"
then
- log info "$check_name: Mismatch in index.xml!"
+ log notice "$check_name: Mismatch in index.xml!"
return $result_failed
else
return $result_ok
fi
fi
# fallback: ask the user to verify
if kdialog --yesno "$check_name — Did KPhotoAlbum pass the test?
As a reminder what you should check:
${_context[$check_name]}
"
then
return $result_ok
else
- log info "$check_name: Failed test as determined by user."
+ log notice "$check_name: Failed test as determined by user."
return $result_failed
fi
}
### MAIN
for dep in $DEPS
do
if ! which "$dep" >/dev/null 2>&1
then
log err "Could not find required dependency '$dep'!"
exit 2
fi
done
version=`kphotoalbum --version 2>&1`
TEMP=`getopt -o clhp --long "all,check,help,keep-tempdir,list,log-level:,print,tempdir:" -n "$myname" -- "$@"`
if [ $? != 0 ] ; then log err "Terminating..." ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
MODE=check
while true ; do
case "$1" in
-h|--help) print_help ; exit ;;
-l|--list) MODE="list" ; shift ;;
-c|--check) MODE="check" ; shift ;;
-p|--print) MODE="print" ; shift ;;
--keep-tempdir) KEEP_TEMPDIR=1 ; shift ;;
--tempdir) TEMPDIR="$2" ; KEEP_TEMPDIR=1 ; shift 2 ;;
--all) RUN_ALL=1 ; shift ;;
--log-level) LOG_LEVEL="${LOG_LEVELS[$2]}" ; shift 2 ;;
--) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;;
esac
done
log info "Using $version (`which kphotoalbum`)..."
if [ -z "$TEMPDIR" ]
then
TEMPDIR=`mktemp -d --tmpdir kphotoalbum-tests-XXXXXX`
fi
trap cleanup EXIT
# read test files
for f in "$mydir/integration-tests/"*.sh
do
. "$f"
done
case $MODE in
list|print)
do_$MODE
;;
check)
if [[ "$RUN_ALL" == 1 ]]
then
eval set -- "${!_checks[@]}"
fi
do_checks "$@"
;;
esac
diff --git a/testcases/integration-tests/check_dbv6-transition.sh b/testcases/integration-tests/check_dbv6-transition.sh
index f4d7ab42..54bbed15 100644
--- a/testcases/integration-tests/check_dbv6-transition.sh
+++ b/testcases/integration-tests/check_dbv6-transition.sh
@@ -1,56 +1,56 @@
_checks[check_dbv6-transition]="Compatibility: upgrade to version 6 database files."
_context[check_dbv6-transition]="What this test will do:
- This test checks whether pre version 6 database files are properly handled.
- After you close this dialog, KPhotoAlbum will be started 4 times in a row.
For more information, you can read the remarks in testcases/db/version6-transition/README.
What you have to do:
- Each time KPhotoAlbum starts, save the database and exit KPhotoAlbum.
"
check_dbv6-transition()
{
local check_name="check_dbv6-transition"
local check_dir="$TEMPDIR/$check_name"
local data_dir="$mydir/db/version6-transition"
setup_check "$check_dir" || return $result_err_setup
# not needed in this scenario:
rm -r "$check_dir/db"
kdialog --msgbox "$check_name
${_context[$check_name]}"
for subcheck in compressed demo-to-compressed positionable-tags uncompressed
do
local subcheck_dir="$check_dir/$subcheck"
mkdir "$subcheck_dir" || return $result_err_setup
local add_rc="[General]\nuntaggedCategory=\nuntaggedTag=\n"
if [[ "$subcheck" == "uncompressed" ]]
then
add_rc="$add_rc\nuseCompressedIndexXML=false\n"
fi
echo -e "$add_rc$BASE_RC" > "$subcheck_dir/kphotoalbumrc" || return $result_err_setup
# set logging rules:
cp -a "$check_dir/QtProject" "$subcheck_dir"
# prepare database:
cp "$data_dir/$subcheck.orig.xml" "$subcheck_dir/index.xml" || return $result_err_setup
export XDG_CONFIG_HOME="$subcheck_dir"
kphotoalbum --db "$subcheck_dir/index.xml" > "$subcheck_dir/log" 2>&1 || return $result_err_crash
if ! diff -u "$data_dir/$subcheck.result.xml" "$subcheck_dir/index.xml"
then
- log info "$check_name/$subcheck: Mismatch in index.xml!"
+ log notice "$check_name/$subcheck: Mismatch in index.xml!"
return $result_failed
fi
if ! grep -q '^kphotoalbum.DB: "Standard category names are no longer used since index.xml version 7. Standard categories will be left untranslated from now on."$' "$subcheck_dir/log"
then
- log info "$check_name/$subcheck: Missing expected log message!"
+ log notice "$check_name/$subcheck: Missing expected log message!"
return $result_failed
fi
done
return $result_ok
}
diff --git a/testcases/integration-tests/check_diacritical.sh b/testcases/integration-tests/check_diacritical.sh
index b1f10dab..bd8cbcae 100644
--- a/testcases/integration-tests/check_diacritical.sh
+++ b/testcases/integration-tests/check_diacritical.sh
@@ -1,51 +1,51 @@
_checks[check_diacritical]="Compatibility: Diacritical characters in v7 database files."
_context[check_diacritical]="What this test will do:
- This test checks whether a version 7 database file with diacritical characters in categories and tags is properly handled.
- After you close this dialog, KPhotoAlbum will be started 4 times in a row.
- This test case was inspired by Bug #403668
What you have to do:
- Each time KPhotoAlbum starts, save the database and exit KPhotoAlbum.
"
check_diacritical()
{
local check_name="check_diacritical"
local check_dir="$TEMPDIR/$check_name"
local data_dir="$mydir/db/diacritical"
setup_check "$check_dir" || return $result_err_setup
# not needed in this scenario:
rm -r "$check_dir/db"
kdialog --msgbox "$check_name
${_context[$check_name]}"
for subcheck in compressed uncompressed uncompressed-to-compressed compressed-to-uncompressed
do
local subcheck_dir="$check_dir/$subcheck"
mkdir "$subcheck_dir" || return $result_err_setup
local add_rc="[General]\nuntaggedCategory=\nuntaggedTag=\n"
if [[ "$subcheck" == "uncompressed" || "$subcheck" == "compressed-to-uncompressed" ]]
then
add_rc="$add_rc\nuseCompressedIndexXML=false\n"
fi
echo -e "$add_rc$BASE_RC" > "$subcheck_dir/kphotoalbumrc" || return $result_err_setup
# set logging rules:
cp -a "$check_dir/QtProject" "$subcheck_dir"
# prepare database:
cp "$data_dir/$subcheck.orig.xml" "$subcheck_dir/index.xml" || return $result_err_setup
export XDG_CONFIG_HOME="$subcheck_dir"
kphotoalbum --db "$subcheck_dir/index.xml" > "$subcheck_dir/log" 2>&1 || return $result_err_crash
if ! diff -u "$data_dir/$subcheck.result.xml" "$subcheck_dir/index.xml"
then
- log info "$check_name: Mismatch in index.xml!"
+ log notice "$check_name: Mismatch in index.xml!"
return $result_failed
fi
done
return $result_ok
}
diff --git a/testcases/integration-tests/check_old-index.xml.sh b/testcases/integration-tests/check_old-index.xml.sh
index c6e70711..d400e326 100644
--- a/testcases/integration-tests/check_old-index.xml.sh
+++ b/testcases/integration-tests/check_old-index.xml.sh
@@ -1,46 +1,46 @@
_checks[check_old-index.xml]="Compatibility: Old/ancient file formats"
_context[check_old-index.xml]="What this test will do:
- This test checks whether old file versions are still correctly read.
- After you close this dialog, KPhotoAlbum will be started 2 times in a row.
What you have to do:
- Each time KPhotoAlbum starts, save the database and exit KPhotoAlbum.
"
check_old-index.xml()
{
local check_name="check_old-index.xml"
local check_dir="$TEMPDIR/$check_name"
local data_dir="$mydir/db/old-index.xml"
setup_check "$check_dir" || return $result_err_setup
# not needed in this scenario:
rm -r "$check_dir/db"
kdialog --msgbox "$check_name
${_context[$check_name]}"
for subcheck in v2.2 v3.0
do
local subcheck_dir="$check_dir/$subcheck"
mkdir "$subcheck_dir" || return $result_err_setup
local add_rc="[General]\nuntaggedCategory=\nuntaggedTag=\n"
echo -e "$add_rc$BASE_RC" > "$subcheck_dir/kphotoalbumrc" || return $result_err_setup
# set logging rules:
cp -a "$check_dir/QtProject" "$subcheck_dir"
# prepare database:
cp "$data_dir/$subcheck.orig.xml" "$subcheck_dir/index.xml" || return $result_err_setup
export XDG_CONFIG_HOME="$subcheck_dir"
kphotoalbum --db "$subcheck_dir/index.xml" > "$subcheck_dir/log" 2>&1 || return $result_err_crash
if ! diff -u "$data_dir/$subcheck.result.xml" "$subcheck_dir/index.xml"
then
- log info "$check_name/$subcheck: Mismatch in index.xml!"
+ log notice "$check_name/$subcheck: Mismatch in index.xml!"
return $result_failed
fi
done
return $result_ok
}
diff --git a/testcases/integration-tests/check_recover-from-duplicates.sh b/testcases/integration-tests/check_recover-from-duplicates.sh
index 650fa49c..d81cd0ce 100644
--- a/testcases/integration-tests/check_recover-from-duplicates.sh
+++ b/testcases/integration-tests/check_recover-from-duplicates.sh
@@ -1,48 +1,48 @@
_checks[check_recover-from-duplicates]="Recovery from duplicate image entries"
_context[check_recover-from-duplicates]="What this test will do:
- This test checks whether a version 7 database file with duplicate images is correctly de-duplicated when reading in.
- After you close this dialog, KPhotoAlbum will be started 4 times in a row.
What you have to do:
- Each time KPhotoAlbum starts, save the database and exit KPhotoAlbum.
"
check_recover-from-duplicates()
{
local check_name="check_recover-from-duplicates"
local check_dir="$TEMPDIR/$check_name"
local data_dir="$mydir/db/recover-from-duplicates"
setup_check "$check_dir" || return $result_err_setup
# not needed in this scenario:
rm -r "$check_dir/db"
kdialog --msgbox "$check_name
${_context[$check_name]}"
for subcheck in compressed uncompressed uncompressed-to-compressed compressed-to-uncompressed
do
local subcheck_dir="$check_dir/$subcheck"
mkdir "$subcheck_dir" || return $result_err_setup
local add_rc="[General]\nuntaggedCategory=\nuntaggedTag=\n"
if [[ "$subcheck" == "uncompressed" || "$subcheck" == "compressed-to-uncompressed" ]]
then
add_rc="$add_rc\nuseCompressedIndexXML=false\n"
fi
echo -e "$add_rc$BASE_RC" > "$subcheck_dir/kphotoalbumrc" || return $result_err_setup
# prepare database:
cp "$data_dir/$subcheck.orig.xml" "$subcheck_dir/index.xml" || return $result_err_setup
export XDG_CONFIG_HOME="$subcheck_dir"
kphotoalbum --db "$subcheck_dir/index.xml" > "$subcheck_dir/log" 2>&1 || return $result_err_crash
if ! diff -u "$data_dir/$subcheck.result.xml" "$subcheck_dir/index.xml"
then
- log info "$check_name/$subcheck: Mismatch in index.xml!"
+ log notice "$check_name/$subcheck: Mismatch in index.xml!"
return $result_failed
fi
done
return $result_ok
}
diff --git a/testcases/integration-tests/check_recover-from-idzero.sh b/testcases/integration-tests/check_recover-from-idzero.sh
index 8948276a..f749bfb9 100644
--- a/testcases/integration-tests/check_recover-from-idzero.sh
+++ b/testcases/integration-tests/check_recover-from-idzero.sh
@@ -1,56 +1,56 @@
_checks[check_recover-from-idzero]="Recovery from tags with id=0"
_context[check_recover-from-idzero]="What this test will do:
- This test checks whether a database file with tags with id=0 is read correctly.
For a detailed analysis on how this kind of database inconsistency could occur, see bug #415415
- After you close this dialog, KPhotoAlbum will be started 2 times in a row.
What you have to do:
- Each time KPhotoAlbum starts, save the database and exit KPhotoAlbum.
"
check_recover-from-idzero()
{
local check_name="check_recover-from-idzero"
local check_dir="$TEMPDIR/$check_name"
local data_dir="$mydir/db/recover-from-idzero"
setup_check "$check_dir" || return $result_err_setup
# not needed in this scenario:
rm -r "$check_dir/db"
kdialog --msgbox "$check_name
${_context[$check_name]}"
for subcheck in compressed uncompressed
do
local subcheck_dir="$check_dir/$subcheck"
mkdir "$subcheck_dir" || return $result_err_setup
local add_rc="[General]\nuntaggedCategory=\nuntaggedTag=\n"
if [[ "$subcheck" == "uncompressed" ]]
then
add_rc="$add_rc\nuseCompressedIndexXML=false\n"
fi
echo -e "$add_rc$BASE_RC" > "$subcheck_dir/kphotoalbumrc" || return $result_err_setup
# prepare database:
cp "$data_dir/$subcheck.orig.xml" "$subcheck_dir/index.xml" || return $result_err_setup
export XDG_CONFIG_HOME="$subcheck_dir"
kphotoalbum --db "$subcheck_dir/index.xml" > "$subcheck_dir/log" 2>&1 || return $result_err_crash
if ! diff -u "$data_dir/$subcheck.result.xml" "$subcheck_dir/index.xml"
then
- log info "$check_name/$subcheck: Mismatch in index.xml!"
+ log notice "$check_name/$subcheck: Mismatch in index.xml!"
return $result_failed
fi
if ! diff -u "$data_dir/$subcheck.expected.log" "$subcheck_dir/log"
then
- log info "$check_name/$subcheck: Mismatch in log messages!"
+ log notice "$check_name/$subcheck: Mismatch in log messages!"
return $result_failed
fi
done
return $result_ok
}