From 99a6200cab0b498fa4e360e64da26292cd2cef4d Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Wed, 10 May 2017 09:43:33 +0200 Subject: [PATCH] tests: Make it possible to create multiple test repos --- tests/libtest.sh | 51 +++++++++++++++++++++++--------------- tests/make-test-app.sh | 5 +++- tests/make-test-runtime.sh | 4 ++- tests/test-bundle.sh | 2 +- tests/test-extensions.sh | 4 +-- tests/test-oci.sh | 4 +-- tests/testlibrary.c | 4 +-- 7 files changed, 45 insertions(+), 29 deletions(-) diff --git a/tests/libtest.sh b/tests/libtest.sh index 31169a6b..019830a1 100644 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -178,47 +178,58 @@ export FL_GPG_ID=7B0961FD export FL_GPGARGS="--gpg-homedir=${FL_GPG_HOMEDIR} --gpg-sign=${FL_GPG_ID}" setup_repo () { - GPGARGS="$FL_GPGARGS" . $(dirname $0)/make-test-runtime.sh org.test.Platform bash ls cat echo readlink > /dev/null - GPGARGS="$FL_GPGARGS" . $(dirname $0)/make-test-app.sh > /dev/null - update_repo - $(dirname $0)/test-webserver.sh repos - port=$(cat httpd-port) - FLATPAK_HTTP_PID=$(cat httpd-pid) - flatpak remote-add ${U} --gpg-import=${FL_GPG_HOMEDIR}/pubring.gpg test-repo "http://127.0.0.1:${port}/test" + REPONAME=${1:-test} + GPGARGS="$FL_GPGARGS" . $(dirname $0)/make-test-runtime.sh ${REPONAME} org.test.Platform bash ls cat echo readlink > /dev/null + GPGARGS="$FL_GPGARGS" . $(dirname $0)/make-test-app.sh ${REPONAME} > /dev/null + update_repo $REPONAME + if [ $REPONAME == "test" ]; then + $(dirname $0)/test-webserver.sh repos + FLATPAK_HTTP_PID=$(cat httpd-pid) + mv httpd-port httpd-port-main + fi + port=$(cat httpd-port-main) + flatpak remote-add ${U} --gpg-import=${FL_GPG_HOMEDIR}/pubring.gpg ${REPONAME}-repo "http://127.0.0.1:${port}/$REPONAME" } update_repo () { - ${FLATPAK} build-update-repo $FL_GPGARGS ${UPDATE_REPO_ARGS-} repos/test + REPONAME=${1:-test} + ${FLATPAK} build-update-repo $FL_GPGARGS ${UPDATE_REPO_ARGS-} repos/${REPONAME} } make_updated_app () { - GPGARGS="$FL_GPGARGS" . $(dirname $0)/make-test-app.sh ${1:-UPDATED} > /dev/null - update_repo + REPONAME=${1:-test} + GPGARGS="$FL_GPGARGS" . $(dirname $0)/make-test-app.sh ${REPONAME} ${2:-UPDATED} > /dev/null + update_repo $REPONAME } setup_sdk_repo () { - GPGARGS="$FL_GPGARGS" . $(dirname $0)/make-test-runtime.sh org.test.Sdk bash ls cat echo readlink make mkdir cp touch > /dev/null - update_repo + REPONAME=${1:-test} + GPGARGS="$FL_GPGARGS" . $(dirname $0)/make-test-runtime.sh ${REPONAME} org.test.Sdk bash ls cat echo readlink make mkdir cp touch > /dev/null + update_repo $REPONAME } setup_python2_repo () { - GPGARGS="$FL_GPGARGS" . $(dirname $0)/make-test-runtime.sh org.test.PythonPlatform bash python2 ls cat echo readlink > /dev/null - GPGARGS="$FL_GPGARGS" . $(dirname $0)/make-test-runtime.sh org.test.PythonSdk python2 bash ls cat echo readlink make mkdir cp touch > /dev/null - update_repo + REPONAME=${1:-test} + GPGARGS="$FL_GPGARGS" . $(dirname $0)/make-test-runtime.sh ${REPONAME} org.test.PythonPlatform bash python2 ls cat echo readlink > /dev/null + GPGARGS="$FL_GPGARGS" . $(dirname $0)/make-test-runtime.sh ${REPONAME} org.test.PythonSdk python2 bash ls cat echo readlink make mkdir cp touch > /dev/null + update_repo $REPONAME } install_repo () { - ${FLATPAK} ${U} install test-repo org.test.Platform master - ${FLATPAK} ${U} install test-repo org.test.Hello master + REPONAME=${1:-test} + ${FLATPAK} ${U} install ${REPONAME}-repo org.test.Platform master + ${FLATPAK} ${U} install ${REPONAME}-repo org.test.Hello master } install_sdk_repo () { - ${FLATPAK} ${U} install test-repo org.test.Sdk master + REPONAME=${1:-test} + ${FLATPAK} ${U} install ${REPONAME}-repo org.test.Sdk master } install_python2_repo () { - ${FLATPAK} ${U} install test-repo org.test.PythonPlatform master - ${FLATPAK} ${U} install test-repo org.test.PythonSdk master + REPONAME=${1:-test} + ${FLATPAK} ${U} install ${REPONAME}-repo org.test.PythonPlatform master + ${FLATPAK} ${U} install ${REPONAME}-repo org.test.PythonSdk master } run () { diff --git a/tests/make-test-app.sh b/tests/make-test-app.sh index a3776c1e..e28a1c0c 100755 --- a/tests/make-test-app.sh +++ b/tests/make-test-app.sh @@ -4,6 +4,9 @@ set -e DIR=`mktemp -d` +REPONAME=$1 +shift + EXTRA="${1-}" ARCH=`flatpak --default-arch` @@ -62,5 +65,5 @@ cp $(dirname $0)/org.test.Hello.png ${DIR}/files/share/app-info/icons/flatpak/64 flatpak build-finish --command=hello.sh ${DIR} mkdir -p repos -flatpak build-export ${GPGARGS-} repos/test ${DIR} +flatpak build-export ${GPGARGS-} repos/${REPONAME} ${DIR} rm -rf ${DIR} diff --git a/tests/make-test-runtime.sh b/tests/make-test-runtime.sh index b1182fe3..d9f5e7f7 100755 --- a/tests/make-test-runtime.sh +++ b/tests/make-test-runtime.sh @@ -4,6 +4,8 @@ set -e DIR=`mktemp -d` +REPONAME=$1 +shift ID=$1 shift @@ -64,5 +66,5 @@ mkdir -p ${DIR}/usr/lib/locale/ cp -r /usr/lib/locale/C.* ${DIR}/usr/lib/locale/en_US mkdir -p repos -flatpak build-export --runtime ${GPGARGS-} repos/test ${DIR} +flatpak build-export --runtime ${GPGARGS-} repos/${REPONAME} ${DIR} rm -rf ${DIR} diff --git a/tests/test-bundle.sh b/tests/test-bundle.sh index 955be9f9..4aa143ba 100755 --- a/tests/test-bundle.sh +++ b/tests/test-bundle.sh @@ -148,7 +148,7 @@ assert_file_has_content hello_out '^Hello world, from a sandboxUPDATED$' echo "ok update" -make_updated_app UPDATED2 +make_updated_app test UPDATED2 ${FLATPAK} build-bundle repos/test --repo-url=file://`pwd`/repos/test --gpg-keys=${FL_GPG_HOMEDIR}/pubring.gpg bundles/hello2.flatpak org.test.Hello assert_has_file bundles/hello2.flatpak diff --git a/tests/test-extensions.sh b/tests/test-extensions.sh index db0e9c7c..181603b1 100755 --- a/tests/test-extensions.sh +++ b/tests/test-extensions.sh @@ -90,8 +90,8 @@ EOF mkdir -p repos ostree init --repo=repos/test --mode=archive-z2 -. $(dirname $0)/make-test-runtime.sh org.test.Platform bash ls cat echo readlink > /dev/null -. $(dirname $0)/make-test-app.sh > /dev/null +. $(dirname $0)/make-test-runtime.sh test org.test.Platform bash ls cat echo readlink > /dev/null +. $(dirname $0)/make-test-app.sh test > /dev/null # Modify platform metadata ostree checkout -U --repo=repos/test runtime/org.test.Platform/${ARCH}/master platform diff --git a/tests/test-oci.sh b/tests/test-oci.sh index 0ad36aca..bbca8fa0 100755 --- a/tests/test-oci.sh +++ b/tests/test-oci.sh @@ -76,7 +76,7 @@ echo "ok update oci" flatpak uninstall ${U} org.test.Hello -make_updated_app HTTP +make_updated_app test HTTP ${FLATPAK} build-bundle --oci $FL_GPGARGS repos/test oci/registry org.test.Hello $(dirname $0)/test-webserver.sh `pwd`/oci @@ -91,7 +91,7 @@ assert_file_has_content hello_out '^Hello world, from a sandboxHTTP$' echo "ok install oci http" -make_updated_app UPDATEDHTTP +make_updated_app test UPDATEDHTTP ${FLATPAK} build-bundle --oci $FL_GPGARGS repos/test oci/registry org.test.Hello ${FLATPAK} update ${U} org.test.Hello diff --git a/tests/testlibrary.c b/tests/testlibrary.c index 11df0c9c..326d36a8 100644 --- a/tests/testlibrary.c +++ b/tests/testlibrary.c @@ -530,7 +530,7 @@ make_test_runtime (void) g_autoptr(GError) error = NULL; g_autofree char *arg0 = NULL; char *argv[] = { - NULL, "org.test.Platform", "bash", "ls", "cat", "echo", "readlink", NULL + NULL, "test", "org.test.Platform", "bash", "ls", "cat", "echo", "readlink", NULL }; GSpawnFlags flags = G_SPAWN_DEFAULT; @@ -556,7 +556,7 @@ make_test_app (void) int status; g_autoptr(GError) error = NULL; g_autofree char *arg0 = NULL; - char *argv[] = { NULL, NULL }; + char *argv[] = { NULL, "test", NULL }; GSpawnFlags flags = G_SPAWN_DEFAULT; arg0 = g_test_build_filename (G_TEST_DIST, "make-test-app.sh", NULL);