diff --git a/document-portal/xdp-main.c b/document-portal/xdp-main.c index abd240b5..5e346b88 100644 --- a/document-portal/xdp-main.c +++ b/document-portal/xdp-main.c @@ -958,8 +958,13 @@ on_name_lost (GDBusConnection *connection, gpointer user_data) { g_debug ("%s lost", name); - final_exit_status = 20; - g_set_error (&exit_error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "D-Bus name \"%s\" lost", name); + + if (final_exit_status == 0) + final_exit_status = 20; + + if (exit_error == NULL) + g_set_error (&exit_error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "D-Bus name \"%s\" lost", name); + g_main_loop_quit (loop); } @@ -977,7 +982,9 @@ session_bus_closed (GDBusConnection *connection, gboolean remote_peer_vanished, GError *bus_error) { - g_set_error (&exit_error, G_IO_ERROR, G_IO_ERROR_BROKEN_PIPE, "Disconnected from session bus"); + if (exit_error == NULL) + g_set_error (&exit_error, G_IO_ERROR, G_IO_ERROR_BROKEN_PIPE, "Disconnected from session bus"); + g_main_loop_quit (loop); } diff --git a/tests/Makefile.am.inc b/tests/Makefile.am.inc index ec8e9f2c..6531c6cf 100644 --- a/tests/Makefile.am.inc +++ b/tests/Makefile.am.inc @@ -6,7 +6,9 @@ TESTS_ENVIRONMENT += FLATPAK_TESTS_DEBUG=1 \ PATH=$$(cd $(top_builddir) && pwd):$${PATH} \ $(NULL) -if !WITH_SYSTEM_BWRAP +if WITH_SYSTEM_BWRAP +TESTS_ENVIRONMENT += FLATPAK_BWRAP=$(BWRAP) +else TESTS_ENVIRONMENT += FLATPAK_BWRAP=$$(cd $(top_builddir) && pwd)/flatpak-bwrap endif @@ -72,13 +74,14 @@ tests/test-basic.sh: tests/package_version.txt dist_installed_test_extra_scripts += \ buildutil/tap-driver.sh \ + tests/empty-configure \ tests/test-configure \ tests/make-test-app.sh \ tests/make-test-runtime.sh \ tests/make-test-bundles.sh \ $(NULL) -installed_test_data = \ +dist_installed_test_data = \ tests/libtest.sh \ tests/org.test.Hello.png \ tests/package_version.txt \ @@ -86,7 +89,6 @@ installed_test_data = \ tests/session.conf.in \ tests/0001-Add-test-logo.patch \ tests/org.test.Python.json \ - tests/empty-configure \ tests/testpython.py \ tests/importme.py \ tests/importme2.py \ @@ -104,8 +106,6 @@ dist_installed_test_keyring_DATA = \ dist_installed_test_dbs_DATA = tests/dbs/no_tables endif -EXTRA_DIST += $(installed_test_data) - dist_test_scripts = \ tests/test-basic.sh \ tests/test-run.sh \ diff --git a/tests/libtest.sh b/tests/libtest.sh index cf74760d..6b4414a9 100644 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -264,6 +264,7 @@ fi cleanup () { /bin/kill $DBUS_SESSION_BUS_PID + gpg-connect-agent --homedir "${FL_GPG_HOMEDIR}" killagent /bye || true fusermount -u $XDG_RUNTIME_DIR/doc || : rm -rf $TEST_DATA_DIR } diff --git a/tests/make-test-bundles.sh b/tests/make-test-bundles.sh index fda23135..7b7ea64b 100755 --- a/tests/make-test-bundles.sh +++ b/tests/make-test-bundles.sh @@ -25,3 +25,5 @@ flatpak build-bundle repo --repo-url=${URL} --gpg-keys=test-keyring/pubring.gpg REF=`(cd repo/refs/heads; echo runtime/org.test.Platform/*/master)` ostree gpg-sign --repo=repo --gpg-homedir=test-keyring ${REF} 7B0961FD flatpak build-bundle --runtime repo --repo-url=${URL} --gpg-keys=test-keyring/pubring.gpg platform.flatpak org.test.Platform + +gpg-connect-agent --homedir test-keyring killagent /bye || true diff --git a/tests/make-test-runtime.sh b/tests/make-test-runtime.sh index 461d36e8..22031552 100755 --- a/tests/make-test-runtime.sh +++ b/tests/make-test-runtime.sh @@ -33,8 +33,16 @@ for i in $@; do _sysconfigdata ; do cp ${PYDIR}/$py.py ${DIR}/usr/lib/python2.7 done + # These might not exist, depending how Python was configured; and the + # part after ${so} might be "module" or ".x86_64-linux-gnu" or + # something else for so in _locale strop ; do - cp ${PYDIR}/lib-dynload/${so}module.so ${DIR}/usr/lib/python2.7/lib-dynload + cp ${PYDIR}/lib-dynload/${so}*.so ${DIR}/usr/lib/python2.7/lib-dynload || : + done + for plat in $( cd ${PYDIR} && echo plat-* ); do + test -e ${PYDIR}/${plat} || continue + mkdir -p ${DIR}/usr/lib/python2.7/${plat} + cp ${PYDIR}/${plat}/*.py ${DIR}/usr/lib/python2.7/${plat}/ done fi done diff --git a/tests/testlibrary.c b/tests/testlibrary.c index abf5fb6c..6a7db875 100644 --- a/tests/testlibrary.c +++ b/tests/testlibrary.c @@ -276,7 +276,7 @@ test_install_launch_uninstall (void) { gint exit_code = 0; char *argv[] = { (char *)bwrap, "--ro-bind", "/", "/", "/bin/true", NULL }; - g_spawn_sync (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, &exit_code, &error); + g_spawn_sync (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL, &exit_code, &error); g_assert_no_error (error); if (exit_code != 0) { @@ -314,8 +314,8 @@ test_install_launch_uninstall (void) &progress_count, NULL, &error); - g_assert (FLATPAK_IS_INSTALLED_REF (ref)); g_assert_no_error (error); + g_assert (FLATPAK_IS_INSTALLED_REF (ref)); g_assert_cmpint (progress_count, >, 0); quit_id = g_timeout_add (500, quit, NULL); @@ -359,8 +359,8 @@ test_install_launch_uninstall (void) &progress_count, NULL, &error); - g_assert (FLATPAK_IS_INSTALLED_REF (ref)); g_assert_no_error (error); + g_assert (FLATPAK_IS_INSTALLED_REF (ref)); g_assert_cmpint (progress_count, >, 0); quit_id = g_timeout_add (500, quit, loop); @@ -384,8 +384,8 @@ test_install_launch_uninstall (void) g_ptr_array_unref (refs); res = flatpak_installation_launch (inst, "org.test.Hello", NULL, NULL, NULL, NULL, &error); - g_assert_true (res); g_assert_no_error (error); + g_assert_true (res); quit_id = g_timeout_add (500, quit, loop); g_main_loop_run (loop); @@ -402,8 +402,8 @@ test_install_launch_uninstall (void) &progress_count, NULL, &error); - g_assert_true (res); g_assert_no_error (error); + g_assert_true (res); //FIXME: no progress for uninstall //g_assert_cmpint (progress_count, >, 0); @@ -428,8 +428,8 @@ test_install_launch_uninstall (void) &progress_count, NULL, &error); - g_assert_true (res); g_assert_no_error (error); + g_assert_true (res); //FIXME: no progress for uninstall //g_assert_cmpint (progress_count, >, 0); @@ -668,9 +668,33 @@ global_setup (void) static void global_teardown (void) { + int status; + g_autoptr (GError) error = NULL; + char *argv[] = { "gpg-connect-agent", "--homedir", "", "killagent", "/bye", NULL }; + GSpawnFlags flags = G_SPAWN_SEARCH_PATH; + if (g_getenv ("SKIP_TEARDOWN")) return; + argv[2] = gpg_homedir; + + if (g_test_verbose ()) + { + g_autofree char *commandline = g_strjoinv (" ", argv); + g_print ("running %s\n", commandline); + } + else + { + flags |= G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL; + } + + /* mostly ignore failure here */ + if (!g_spawn_sync (NULL, (char **)argv, NULL, flags, NULL, NULL, NULL, NULL, &status, &error) || + !g_spawn_check_exit_status (status, &error)) + { + g_print ("# failed to run gpg-connect-agent to stop gpg-agent: %s\n", error->message); + } + glnx_shutil_rm_rf_at (-1, testdir, NULL, NULL); g_free (testdir); }