#!/bin/bash
set -e # quit script on error
-set -x # show each command as it is executed
echo_header() {
- echo "=============================================================================="
- echo $1
+ { echo -e "==============================================================================\n$1"; } 2>/dev/null
}
copy_apks_into_repo() {
create_test_dir() {
test -e $WORKSPACE/.testfiles || mkdir $WORKSPACE/.testfiles
- TMPDIR=$WORKSPACE/.testfiles mktemp -d
+ mktemp -d $WORKSPACE/.testfiles/run-tests.XXXX
}
create_test_file() {
exit 1
fi
+if [ -d tests ]; then
+ cd tests
+fi
+
if [ -z "$1" ]; then
APKDIR=`pwd`
else
python=python2
fi
+set -x # show each command as it is executed
#------------------------------------------------------------------------------#
echo_header "run commit hooks"
done
+#------------------------------------------------------------------------------#
+echo_header "print fdroid version"
+
+$fdroid --version
+
+
+#------------------------------------------------------------------------------#
+echo_header "build the TeX manual"
+
+cd $WORKSPACE/docs
+# this is only ever generated officially on GNU/Linux
+if [ `uname -s` == "Linux" ]; then
+ ./gendocs.sh -o html --email admin@f-droid.org fdroid "F-Droid Server Manual"
+fi
+
+
+#------------------------------------------------------------------------------#
+echo_header "test UTF-8 metadata"
+
+REPOROOT=`create_test_dir`
+cd $REPOROOT
+
+$fdroid init
+sed -i.tmp 's,^ *repo_description.*,repo_description = """获取已安装在您的设备上的应用的,' config.py
+echo "mirrors = {'https://foo.bar/fdroid', 'http://secret.onion/fdroid'}" >> config.py
+mkdir metadata
+cp $WORKSPACE/tests/urzip.apk repo/
+cp $WORKSPACE/tests/metadata/info.guardianproject.urzip.txt metadata/
+
+$fdroid readmeta
+$fdroid update
+
+
+#------------------------------------------------------------------------------#
+echo_header "test metadata checks"
+
+REPOROOT=`create_test_dir`
+cd $REPOROOT
+
+touch config.py
+mkdir repo
+cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
+
+set +e
+$fdroid build
+if [ $? -eq 0 ]; then
+ echo "This should have failed because there is no metadata!"
+ exit 1
+else
+ echo "testing metadata checks passed"
+fi
+set -e
+
+mkdir $REPOROOT/metadata/
+cp $WORKSPACE/tests/metadata/org.smssecure.smssecure.txt $REPOROOT/metadata/
+$fdroid readmeta
+
+# now make a fake duplicate
+touch $REPOROOT/metadata/org.smssecure.smssecure.yaml
+
+set +e
+$fdroid readmeta
+if [ $? -eq 0 ]; then
+ echo "This should have failed because there is a duplicate metadata file!"
+ exit 1
+else
+ echo "testing duplicate metadata checks passed"
+fi
+set -e
+
+
+#------------------------------------------------------------------------------#
+echo_header "ensure commands that don't need the JDK work without a JDK configed"
+
+REPOROOT=`create_test_dir`
+cd $REPOROOT
+mkdir repo
+mkdir metadata
+echo "License:GPL" >> metadata/fake.txt
+echo "Summary:Yup still fake" >> metadata/fake.txt
+echo "Categories:Internet" >> metadata/fake.txt
+echo "Description:" >> metadata/fake.txt
+echo "this is fake" >> metadata/fake.txt
+echo "." >> metadata/fake.txt
+
+# fake that no JDKs are available
+echo 'java_paths = {}' > config.py
+
+LOCAL_COPY_DIR=`create_test_dir`/fdroid
+mkdir -p $LOCAL_COPY_DIR/repo
+echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
+
+$fdroid checkupdates
+$fdroid gpgsign
+$fdroid lint
+$fdroid readmeta
+$fdroid rewritemeta fake
+$fdroid server update
+$fdroid scanner
+
+# run these to get their output, but the are not setup, so don't fail
+$fdroid build || true
+$fdroid import || true
+$fdroid install || true
+
+
#------------------------------------------------------------------------------#
echo_header "create a source tarball and use that to build a repo"
cd $REPOROOT
./fdroidserver-*/fdroid init
copy_apks_into_repo $REPOROOT
-./fdroidserver-*/fdroid update --create-metadata
+./fdroidserver-*/fdroid update --create-metadata --verbose
#------------------------------------------------------------------------------#
REPOROOT=`create_test_dir`
cd $REPOROOT
$fdroid init
-$fdroid update --create-metadata
+$fdroid update --create-metadata --verbose
$fdroid readmeta
$fdroid server update --local-copy-dir=/tmp/fdroid
cd $REPOROOT
$fdroid init
copy_apks_into_repo $REPOROOT
-$fdroid update --create-metadata
+$fdroid update --create-metadata --verbose
$fdroid readmeta
grep -F '<application id=' repo/index.xml > /dev/null
$fdroid init --keystore $KEYSTORE --android-home $STORED_ANDROID_HOME --no-prompt
test -e $KEYSTORE
copy_apks_into_repo $REPOROOT
-$fdroid update --create-metadata
+$fdroid update --create-metadata --verbose
$fdroid readmeta
grep -F '<application id=' repo/index.xml > /dev/null
test -e repo/index.xml
mkdir repo
copy_apks_into_repo $REPOROOT
$fdroid init
-$fdroid update --create-metadata
+$fdroid update --create-metadata --verbose
$fdroid readmeta
grep -F '<application id=' repo/index.xml > /dev/null
$fdroid init --keystore $KEYSTORE
test -e $KEYSTORE
copy_apks_into_repo $REPOROOT
-$fdroid update --create-metadata
+$fdroid update --create-metadata --verbose
$fdroid readmeta
test -e repo/index.xml
test -e repo/index.jar
echo "This should have failed because this repo has no keystore!"
exit 1
else
- echo "`fdroid update` prompted to add keystore"
+ echo '`fdroid update` prompted to add keystore'
fi
set -e
$fdroid update --create-key
test -e $KEYSTORE
copy_apks_into_repo $REPOROOT
-$fdroid update --create-metadata
+$fdroid update --create-metadata --verbose
$fdroid readmeta
test -e repo/index.xml
test -e repo/index.jar
$fdroid init --keystore $KEYSTORE
test -e $KEYSTORE
copy_apks_into_repo $REPOROOT
-$fdroid update --create-metadata
+$fdroid update --create-metadata --verbose
$fdroid readmeta
test -e repo/index.xml
test -e repo/index.jar
grep -F '<application id=' repo/index.xml > /dev/null
test -e $REPOROOT/repo/info.guardianproject.urzip_100.apk || \
cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
-$fdroid update --create-metadata
+$fdroid update --create-metadata --verbose
$fdroid readmeta
test -e repo/index.xml
test -e repo/index.jar
#------------------------------------------------------------------------------#
echo_header "setup a new repo from scratch with a HSM/smartcard"
-
REPOROOT=`create_test_dir`
cd $REPOROOT
$fdroid init --keystore NONE
mkdir repo
cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
set +e
-$fdroid update --create-metadata
+$fdroid update --create-metadata --verbose
if [ $? -eq 0 ]; then
echo "This should have failed because this repo has no keystore!"
exit 1
else
- echo "`fdroid update` prompted to add keystore"
+ echo '`fdroid update` prompted to add keystore'
fi
set -e
echo 'keystorepass = "foo"' >> config.py
echo 'keypass = "foo"' >> config.py
set +e
-$fdroid update --create-metadata
+$fdroid update --create-metadata --verbose
if [ $? -eq 0 ]; then
echo "This should have failed because this repo has a bad/fake keystore!"
exit 1
else
- echo "`fdroid update` prompted to add keystore"
+ echo '`fdroid update` prompted to add keystore'
fi
set -e
$fdroid init --keystore $KEYSTORE
test -e $KEYSTORE
cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
-$fdroid update --create-metadata
+$fdroid update --create-metadata --verbose
$fdroid readmeta
test -e repo/index.xml
test -e repo/index.jar
grep -F '<application id=' repo/index.xml > /dev/null
# now set fake repo_keyalias
-sed -i 's,^ *repo_keyalias.*,repo_keyalias = "fake",' $REPOROOT/config.py
+sed -i.tmp 's,^ *repo_keyalias.*,repo_keyalias = "fake",' $REPOROOT/config.py
set +e
$fdroid update
if [ $? -eq 0 ]; then
echo "This should have failed because this repo has a bad repo_keyalias!"
exit 1
else
- echo "`fdroid update` prompted to add keystore"
+ echo '`fdroid update` prompted to add keystore'
fi
set -e
echo "This should have failed because a keystore is already there!"
exit 1
else
- echo "`fdroid update` complained about existing keystore"
+ echo '`fdroid update` complained about existing keystore'
fi
set -e