diff options
author | Patrick <pgriffis@igalia.com> | 2023-01-07 18:48:28 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-07 18:48:28 -0600 |
commit | e110bf7c7fc28ede5bde59a8a28cfe8b163595e4 (patch) | |
tree | 63283a96075325e86b37c3d57a7aaa1c9d2eb4e0 /tests | |
parent | b61a6d836c30d446c707f50585f7a91a8ae1857d (diff) | |
parent | 523cedc27509779e7e815806e53361d5fe7e0bd4 (diff) | |
download | flatpak-appstreamcli-compose.tar.gz |
Merge branch 'main' into appstreamcli-composeappstreamcli-compose
Diffstat (limited to 'tests')
32 files changed, 711 insertions, 53 deletions
diff --git a/tests/Makefile.am.inc b/tests/Makefile.am.inc index d452f762..9018e275 100644 --- a/tests/Makefile.am.inc +++ b/tests/Makefile.am.inc @@ -63,7 +63,6 @@ testcommon_CFLAGS = \ $(AM_CFLAGS) \ $(BASE_CFLAGS) \ $(OSTREE_CFLAGS) \ - $(SOUP_CFLAGS) \ $(JSON_CFLAGS) \ $(APPSTREAM_CFLAGS) \ -DFLATPAK_COMPILATION \ @@ -75,7 +74,6 @@ testcommon_LDADD = \ $(AM_LDADD) \ $(BASE_LIBS) \ $(OSTREE_LIBS) \ - $(SOUP_LIBS) \ $(JSON_LIBS) \ $(APPSTREAM_LIBS) \ libflatpak-app.la \ @@ -115,10 +113,10 @@ tests_hold_lock_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS) tests_hold_lock_LDADD = $(AM_LDADD) $(BASE_LIBS) libglnx.la tests_hold_lock_SOURCES = tests/hold-lock.c -tests_httpcache_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS) $(OSTREE_CFLAGS) $(SOUP_CFLAGS) $(JSON_CFLAGS) \ +tests_httpcache_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS) $(OSTREE_CFLAGS) $(JSON_CFLAGS) \ -DFLATPAK_COMPILATION \ -DLOCALEDIR=\"$(localedir)\" -tests_httpcache_LDADD = $(AM_LDADD) $(BASE_LIBS) $(OSTREE_LIBS) $(SOUP_LIBS) $(JSON_LIBS) \ +tests_httpcache_LDADD = $(AM_LDADD) $(BASE_LIBS) $(OSTREE_LIBS) $(JSON_LIBS) \ libflatpak-common.la libflatpak-common-base.la libglnx.la tests_mock_flatpak_CFLAGS = $(testcommon_CFLAGS) @@ -304,7 +302,16 @@ EXTRA_DIST += \ tests/expand-test-matrix.sh \ tests/flatpak.supp \ tests/glib.supp \ + tests/installed-services/meson.build \ tests/make-runtime-repos \ + tests/meson.build \ + tests/package_version.txt.in \ + tests/services/meson.build \ + tests/share/xdg-desktop-portal/portals/meson.build \ + tests/tap.test.in \ + tests/test-keyring/meson.build \ + tests/test-keyring2/meson.build \ + tests/test-matrix/meson.build \ tests/test-wrapper.sh \ tests/update-test-matrix \ $(NULL) diff --git a/tests/can-use-fuse.c b/tests/can-use-fuse.c index f39d2f15..fb6e2000 100644 --- a/tests/can-use-fuse.c +++ b/tests/can-use-fuse.c @@ -1,4 +1,4 @@ -/* +/* vi:set et sw=2 sts=2 cin cino=t0,f0,(0,{s,>2s,n-s,^-s,e-s: * Copyright 2019-2021 Collabora Ltd. * SPDX-License-Identifier: LGPL-2.1-or-later */ @@ -13,8 +13,15 @@ #include "libglnx.h" -#define FUSE_USE_VERSION 26 +#ifndef FUSE_USE_VERSION +#error config.h needs to define FUSE_USE_VERSION +#endif + +#if FUSE_USE_VERSION >= 31 +#include <fuse.h> +#else #include <fuse_lowlevel.h> +#endif gchar *cannot_use_fuse = NULL; @@ -26,10 +33,15 @@ check_fuse (void) { g_autofree gchar *fusermount = NULL; g_autofree gchar *path = NULL; - char *argv[] = { "flatpak-fuse-test" }; - struct fuse_args args = FUSE_ARGS_INIT (G_N_ELEMENTS (argv), argv); - struct fuse_chan *chan = NULL; + char *argv[] = { "flatpak-fuse-test", NULL }; + struct fuse_args args = FUSE_ARGS_INIT (G_N_ELEMENTS (argv) - 1, argv); g_autoptr(GError) error = NULL; +#if FUSE_USE_VERSION >= 31 + struct fuse *fuse = NULL; + const struct fuse_operations ops = { NULL }; +#else + struct fuse_chan *chan = NULL; +#endif if (cannot_use_fuse != NULL) return FALSE; @@ -64,6 +76,26 @@ check_fuse (void) path = g_dir_make_tmp ("flatpak-test.XXXXXX", &error); g_assert_no_error (error); +#if FUSE_USE_VERSION >= 31 + fuse = fuse_new (&args, &ops, sizeof (ops), NULL); + + if (fuse == NULL) + { + fuse_opt_free_args (&args); + cannot_use_fuse = g_strdup_printf ("fuse_new: %s", + g_strerror (errno)); + return FALSE; + } + + if (fuse_mount (fuse, path) != 0) + { + fuse_destroy (fuse); + fuse_opt_free_args (&args); + cannot_use_fuse = g_strdup_printf ("fuse_mount: %s", + g_strerror (errno)); + return FALSE; + } +#else chan = fuse_mount (path, &args); if (chan == NULL) @@ -73,10 +105,16 @@ check_fuse (void) g_strerror (errno)); return FALSE; } +#endif g_test_message ("Successfully set up test FUSE fs on %s", path); +#if FUSE_USE_VERSION >= 31 + fuse_unmount (fuse); + fuse_destroy (fuse); +#else fuse_unmount (path, chan); +#endif if (g_rmdir (path) != 0) g_error ("rmdir %s: %s", path, g_strerror (errno)); diff --git a/tests/expand-test-matrix.sh b/tests/expand-test-matrix.sh index 6c39ee94..4965fa6a 100755 --- a/tests/expand-test-matrix.sh +++ b/tests/expand-test-matrix.sh @@ -125,4 +125,18 @@ if [ "$1" = "--automake" ]; then echo " ${f} \\" done echo " \$(NULL)" +elif [ "$1" = "--meson" ]; then + echo "# This file is autogenerated by ./tests/update-test-matrix, don't edit" + for f in $tests $dist_tests; do + f="${f#tests/}" + case "$f" in + (*@*) + s="${f%%@*}.sh" + ;; + (*) + s="$f" + ;; + esac + echo "wrapped_tests += {'name' : '$f', 'script' : '$s'}" + done fi diff --git a/tests/flatpak.supp b/tests/flatpak.supp index aae8ae16..6938c626 100644 --- a/tests/flatpak.supp +++ b/tests/flatpak.supp @@ -254,3 +254,14 @@ fun:g_file_new_for_path fun:flatpak_get_user_base_dir_location } + +# https://github.com/ostreedev/ostree/issues/2592 +{ + ostree_issue_2592 + Memcheck:Cond + ... + fun:_ostree_repo_auto_transaction_unref + fun:glib_autoptr_clear_OstreeRepoAutoTransaction + fun:glib_autoptr_cleanup_OstreeRepoAutoTransaction + fun:ostree_repo_prepare_transaction +} diff --git a/tests/hold-lock.c b/tests/hold-lock.c index 542f8af5..53740e5f 100644 --- a/tests/hold-lock.c +++ b/tests/hold-lock.c @@ -1,4 +1,4 @@ -/* +/* vi:set et sw=2 sts=2 cin cino=t0,f0,(0,{s,>2s,n-s,^-s,e-s: * Copyright © 2019-2021 Collabora Ltd. * * SPDX-License-Identifier: LGPL-2.1-or-later diff --git a/tests/httpcache.c b/tests/httpcache.c index 57f92b04..095b732f 100644 --- a/tests/httpcache.c +++ b/tests/httpcache.c @@ -3,7 +3,7 @@ int main (int argc, char *argv[]) { - g_autoptr(SoupSession) session = flatpak_create_soup_session (PACKAGE_STRING); + g_autoptr(FlatpakHttpSession) session = flatpak_create_http_session (PACKAGE_STRING); GError *error = NULL; const char *url, *dest; int flags = 0; diff --git a/tests/installed-services/meson.build b/tests/installed-services/meson.build new file mode 100644 index 00000000..ad20f4da --- /dev/null +++ b/tests/installed-services/meson.build @@ -0,0 +1,47 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +foreach triple : [ + ['oci-authenticator', 'org.flatpak.Authenticator.Oci', {}], + ['portal', 'org.freedesktop.portal.Flatpak', { + 'extraargs' : ' --poll-timeout=1', + }], + ['session-helper', 'org.freedesktop.Flatpak', {}], + ['system-helper', 'org.freedesktop.Flatpak.SystemHelper', { + 'extraargs' : ' --session --no-idle-exit', + }], +] + directory = triple[0] + service = triple[1] + options = triple[2] + + configure_file( + input : project_source_root / directory / (service + '.service.in'), + output : service + '.service', + configuration : { + 'extraargs' : options.get('extraargs', ''), + 'libexecdir' : get_option('prefix') / get_option('libexecdir'), + }, + install_dir : installed_testdir / 'services', + ) +endforeach + +foreach service : [ + 'org.flatpak.Authenticator.test', + 'org.freedesktop.impl.portal.desktop.test', +] + configure_file( + input : project_source_root / 'tests' / (service + '.service.in'), + output : service + '.service', + configuration : { + 'libexecdir' : installed_testdir, + }, + install_dir : installed_testdir / 'services', + ) +endforeach + +install_data( + project_source_root / 'tests/test.portal.in', + install_dir : installed_testdir / 'share/xdg-desktop-portal/portals', + rename : 'test.portal', +) diff --git a/tests/libpreload.c b/tests/libpreload.c index a640a945..de434d52 100644 --- a/tests/libpreload.c +++ b/tests/libpreload.c @@ -1,4 +1,4 @@ -/* +/* vi:set et sw=2 sts=2 cin cino=t0,f0,(0,{s,>2s,n-s,^-s,e-s: * Copyright 2021 Collabora Ltd. * SPDX-License-Identifier: LGPL-2-or-later */ diff --git a/tests/libtest.sh b/tests/libtest.sh index 246f00dd..36d39ac4 100644 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -86,6 +86,7 @@ elif test -n "${FLATPAK_TESTS_VALGRIND_LEAKS:-}"; then else CMD_PREFIX="" fi +unset OSTREE_DEBUG_HTTP export MALLOC_CHECK_=3 export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) @@ -577,6 +578,13 @@ skip_without_ostree_version () { fi } +skip_without_libsystemd () { + ${FLATPAK} history > history-log 2>&1 || true + if grep -q 'history not available without libsystemd' history-log; then + skip "no libsystemd available" + fi +} + sed s#@testdir@#${test_builddir}# ${test_srcdir}/session.conf.in > session.conf dbus-daemon --fork --config-file=session.conf --print-address=3 --print-pid=4 \ 3> dbus-session-bus-address 4> dbus-session-bus-pid diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 00000000..4e6f639d --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,380 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +installed_testdir = get_option('prefix') / get_option('libexecdir') / 'installed-tests' / 'Flatpak' +installed_tests_metadir = get_option('prefix') / get_option('datadir') / 'installed-tests' / 'Flatpak' + +tests_environment = environment() +tests_environment.set('FLATPAK_CONFIG_DIR', '/dev/null') +tests_environment.set( + 'FLATPAK_PORTAL', + project_build_root / 'portal' / 'flatpak-portal', +) +tests_environment.set( + 'FLATPAK_REVOKEFS_FUSE', + project_build_root / 'revokefs' / 'revokefs-fuse', +) +tests_environment.set('FLATPAK_TESTS_DEBUG', '1') +tests_environment.set('FLATPAK_TESTS_STRICT_TAP', '1') +tests_environment.set('FLATPAK_TRIGGERSDIR', project_source_root / 'triggers') +tests_environment.set( + 'FLATPAK_VALIDATE_ICON', + project_build_root / 'icon-validator' / 'flatpak-validate-icon', +) +tests_environment.set('G_TEST_BUILDDIR', meson.current_build_dir()) +tests_environment.set('G_TEST_SRCDIR', meson.current_source_dir()) +tests_environment.prepend('GI_TYPELIB_PATH', project_build_root / 'common') +tests_environment.prepend('LD_LIBRARY_PATH', project_build_root / 'common') +tests_environment.prepend('PATH', project_build_root / 'app') + +if get_option('system_bubblewrap') == '' + tests_environment.set('FLATPAK_BWRAP', project_build_root / 'subprojects' / 'bubblewrap' / 'flatpak-bwrap') +else + tests_environment.set('FLATPAK_BWRAP', get_option('system_bubblewrap')) +endif + +if get_option('system_dbus_proxy') == '' + tests_environment.set('FLATPAK_DBUSPROXY', project_build_root / 'subprojects' / 'dbus-proxy' / 'flatpak-dbus-proxy') +else + tests_environment.set('FLATPAK_DBUSPROXY', get_option('system_dbus_proxy')) +endif + +# Explicitly doing a find_program() for this avoids lots of output with +# older Meson versions +tap_test = find_program( + files(project_source_root / 'buildutil/tap-test'), +) + +if can_run_host_binaries + runtime_repo = custom_target( + 'runtime-repo', + build_by_default : false, + command : [ + files('make-runtime-repos'), + project_build_root / 'app', + files('make-test-runtime.sh'), + project_build_root / 'tests/runtime-repo', + '@OUTPUT@', + ], + depends : [flatpak_exe], + output : 'runtime-repo.stamp', + ) +endif + +libtestlib = static_library( + 'testlib', + 'testlib.c', + include_directories : [common_include_directories], + dependencies : [ + base_deps, + libglnx_dep, + ], + install : false, +) +libtestlib_dep = declare_dependency( + dependencies : [ + base_deps, + libglnx_dep, + ], + include_directories : [common_include_directories], + link_with : libtestlib, +) + +c_tests = [ + ['testcommon', {}], + ['testlibrary', { + 'dependencies' : [ + base_deps, + fuse_dep, + libflatpak_dep, + libglnx_dep, + libostree_dep, + ], + 'extra_sources' : [ + 'can-use-fuse.c', + 'testlib.c', + ], + 'timeout' : 150, + }], + ['test-context', {}], + ['test-exports', {}], + ['test-instance', { + 'extra_dependencies' : [ + libglnx_testlib_dep, + ], + }], + ['test-portal', { + 'extra_sources' : [ + portal_gdbus[0], + portal_gdbus[1], + ], + }], +] + +foreach testcase : c_tests + name = testcase[0] + options = testcase[1] + + exe = executable( + name, + dependencies : options.get('dependencies', [ + base_deps, + appstream_dep, + json_glib_dep, + libflatpak_app_dep, + libflatpak_common_dep, + libflatpak_common_base_dep, + libglnx_dep, + libostree_dep, + libsoup_dep, + libtestlib_dep, + ] + options.get('extra_dependencies', [])), + sources : [name + '.c'] + options.get('extra_sources', []), + install : get_option('installed_tests'), + install_dir : installed_testdir, + ) + + if get_option('installed_tests') + configure_file( + input : 'tap.test.in', + output : name + '.test', + configuration : { + 'basename' : name, + 'installed_testdir' : installed_testdir, + 'wrapper' : '', + }, + install_dir : installed_tests_metadir, + ) + endif + + if can_run_host_binaries + test( + name, + tap_test, + args : [exe], + depends : runtime_repo, + env : tests_environment, + protocol : 'tap', + timeout : options.get('timeout', 30), + ) + endif +endforeach + +executable( + 'hold-lock', + 'hold-lock.c', + dependencies : [ + base_deps, + libglnx_dep, + ], + include_directories : [common_include_directories], + install : get_option('installed_tests'), + install_dir : installed_testdir, +) + +executable( + 'httpcache', + 'httpcache.c', + dependencies : [ + base_deps, + json_glib_dep, + libflatpak_common_dep, + libflatpak_common_base_dep, + libglnx_dep, + libostree_dep, + libsoup_dep, + ], + include_directories : [common_include_directories], + install : get_option('installed_tests'), + install_dir : installed_testdir, +) + +executable( + 'mock-flatpak', + 'mock-flatpak.c', + dependencies : [ + base_deps, + appstream_dep, + json_glib_dep, + libflatpak_app_dep, + libflatpak_common_dep, + libflatpak_common_base_dep, + libtestlib_dep, + libglnx_dep, + libostree_dep, + libsoup_dep, + ], + install : get_option('installed_tests'), + install_dir : installed_testdir, +) + +executable( + 'test-update-portal', + sources : [ + 'test-update-portal.c', + ] + portal_gdbus, + dependencies : base_deps, + include_directories : [common_include_directories], + install : get_option('installed_tests'), + install_dir : installed_testdir, +) + +executable( + 'test-portal-impl', + 'test-portal-impl.c', + dependencies : base_deps, + include_directories : [common_include_directories], + install : get_option('installed_tests'), + install_dir : installed_testdir, +) + +executable( + 'test-authenticator', + 'test-authenticator.c', + dependencies : [ + base_deps, + libflatpak_common_dep, + libflatpak_common_base_dep, + libglnx_dep, + ], + install : get_option('installed_tests'), + install_dir : installed_testdir, +) + +executable( + 'try-syscall', + 'try-syscall.c', + include_directories : [common_include_directories], + install : get_option('installed_tests'), + install_dir : installed_testdir, + override_options: ['b_sanitize=none'], +) + +executable( + 'list-unused', + 'list-unused.c', + dependencies : [ + base_deps, + libflatpak_common_dep, + libflatpak_common_base_dep, + libglnx_dep, + libostree_dep, + ], + include_directories : [common_include_directories], + install : get_option('installed_tests'), + install_dir : installed_testdir, +) + +subdir('share/xdg-desktop-portal/portals') +subdir('services') +subdir('test-keyring') +subdir('test-keyring2') + +configure_file( + input : 'package_version.txt.in', + output : 'package_version.txt', + configuration : { + 'PACKAGE_VERSION' : meson.project_version(), + }, + install : get_option('installed_tests'), + install_dir : installed_testdir, +) + +if get_option('installed_tests') + subdir('installed-services') + + install_data( + 'http-utils-test-server.py', + 'make-multi-collection-id-repo.sh', + 'make-test-app.sh', + 'make-test-runtime.sh', + 'oci-registry-client.py', + 'oci-registry-server.py', + 'test-webserver.sh', + 'test-wrapper.sh', + 'web-server.py', + + install_dir : installed_testdir, + install_mode : 'rwxr-xr-x', + ) + + install_data( + 'libtest.sh', + 'org.flatpak.Authenticator.test.service.in', + 'org.freedesktop.impl.portal.desktop.test.service.in', + 'org.test.Hello.png', + 'session.conf.in', + 'test.filter', + 'test.portal.in', + + install_dir : installed_testdir, + install_mode : 'rw-r--r--', + ) +endif + +shared_module( + 'preload', + 'libpreload.c', + install : get_option('installed_tests'), + install_dir : installed_testdir, + override_options: ['b_sanitize=none'], +) + +wrapped_tests = [] +subdir('test-matrix') + +foreach testcase : wrapped_tests + name = testcase['name'] + script = testcase.get('script', name) + + timeout = { + 'test-bundle.sh' : 60, + 'test-oci-registry.sh' : 60, + 'test-repo.sh' : 300, + 'test-run.sh' : 90, + 'test-summaries.sh' : 60, + 'test-unused.sh' : 90, + 'test-update-portal.sh' : 90, + }.get(script, 30) + + is_parallel = { + 'test-history.sh' : false, + }.get(script, true) + + if get_option('installed_tests') + if name == script + wrapper = '' + else + wrapper = installed_testdir / 'test-wrapper.sh' + endif + + install_data( + script, + install_dir : installed_testdir, + install_mode : 'rwxr-xr-x', + ) + configure_file( + input : 'tap.test.in', + output : name + '.test', + configuration : { + 'basename' : name, + 'installed_testdir' : installed_testdir, + 'wrapper' : wrapper, + }, + install_dir : installed_tests_metadir, + ) + endif + + if can_run_host_binaries + test( + name, + tap_test, + args : [meson.current_source_dir() / name], + depends : runtime_repo, + env : tests_environment, + is_parallel : is_parallel, + protocol : 'tap', + timeout : timeout, + ) + endif +endforeach diff --git a/tests/mock-flatpak.c b/tests/mock-flatpak.c index 03ea3d2b..c340c781 100644 --- a/tests/mock-flatpak.c +++ b/tests/mock-flatpak.c @@ -1,4 +1,4 @@ -/* +/* vi:set et sw=2 sts=2 cin cino=t0,f0,(0,{s,>2s,n-s,^-s,e-s: * Copyright © 2018-2021 Collabora Ltd. * * This program is free software; you can redistribute it and/or @@ -32,7 +32,7 @@ main (int argc, { int i; - g_debug ("This is a mock implementation of `flatpak run` for the portal"); + g_info ("This is a mock implementation of `flatpak run` for the portal"); for (i = 0; i < argc; i++) g_print ("argv[%d] = %s\n", i, argv[i]); diff --git a/tests/package_version.txt.in b/tests/package_version.txt.in new file mode 100644 index 00000000..a24f9877 --- /dev/null +++ b/tests/package_version.txt.in @@ -0,0 +1 @@ +@PACKAGE_VERSION@ diff --git a/tests/services/meson.build b/tests/services/meson.build new file mode 100644 index 00000000..27eb641c --- /dev/null +++ b/tests/services/meson.build @@ -0,0 +1,28 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +foreach triple : [ + ['oci-authenticator', 'org.flatpak.Authenticator.Oci', {}], + ['portal', 'org.freedesktop.portal.Flatpak', { + 'extraargs' : ' --poll-timeout=1', + }], + ['session-helper', 'org.freedesktop.Flatpak', {}], + ['system-helper', 'org.freedesktop.Flatpak.SystemHelper', { + 'extraargs' : ' --session --no-idle-exit', + }], + ['tests', 'org.flatpak.Authenticator.test', {}], + ['tests', 'org.freedesktop.impl.portal.desktop.test', {}], +] + directory = triple[0] + service = triple[1] + options = triple[2] + + configure_file( + input : project_source_root / directory / (service + '.service.in'), + output : service + '.service', + configuration : { + 'extraargs' : options.get('extraargs', ''), + 'libexecdir' : project_build_root / directory, + } + ) +endforeach diff --git a/tests/share/xdg-desktop-portal/portals/meson.build b/tests/share/xdg-desktop-portal/portals/meson.build new file mode 100644 index 00000000..73640145 --- /dev/null +++ b/tests/share/xdg-desktop-portal/portals/meson.build @@ -0,0 +1,6 @@ +configure_file( + input : project_source_root / 'tests/test.portal.in', + output : 'test.portal', + copy : true, +) + diff --git a/tests/tap.test.in b/tests/tap.test.in new file mode 100644 index 00000000..52894902 --- /dev/null +++ b/tests/tap.test.in @@ -0,0 +1,4 @@ +[Test] +Type=session +Exec=env G_TEST_SRCDIR=@installed_testdir@ G_TEST_BUILDDIR=@installed_testdir@ @wrapper@ @installed_testdir@/@basename@ --tap +Output=TAP diff --git a/tests/test-authenticator.c b/tests/test-authenticator.c index 3c3bb598..521ded44 100644 --- a/tests/test-authenticator.c +++ b/tests/test-authenticator.c @@ -1,4 +1,4 @@ -/* +/* vi:set et sw=2 sts=2 cin cino=t0,f0,(0,{s,>2s,n-s,^-s,e-s: * Copyright © 2019 Red Hat, Inc * * This program is free software; you can redistribute it and/or @@ -112,7 +112,7 @@ finish_request_ref_tokens (TokenRequestData *data) g_variant_builder_init (&results, G_VARIANT_TYPE ("a{sv}")); g_variant_builder_add (&results, "{sv}", "tokens", g_variant_builder_end (&tokens)); - g_debug ("emitting response"); + g_info ("emitting response"); flatpak_authenticator_request_emit_response (data->request, FLATPAK_AUTH_RESPONSE_OK, g_variant_builder_end (&results)); @@ -130,9 +130,9 @@ http_incoming (GSocketService *service, g_assert_true (data->request != NULL); /* For the test, just assume any connection is a valid use of the web flow */ - g_debug ("handling incoming http request"); + g_info ("handling incoming http request"); - g_debug ("emitting webflow done"); + g_info ("emitting webflow done"); flatpak_authenticator_request_emit_webflow_done (data->request, options); finish_request_ref_tokens (data); @@ -149,7 +149,7 @@ handle_request_close (FlatpakAuthenticatorRequest *object, { TokenRequestData *data = user_data; - g_debug ("handle_request_close"); + g_info ("handle_request_close"); flatpak_authenticator_request_complete_close (object, invocation); @@ -157,7 +157,7 @@ handle_request_close (FlatpakAuthenticatorRequest *object, { GVariantBuilder results; - g_debug ("Webflow was cancelled by client"); + g_info ("Webflow was cancelled by client"); g_variant_builder_init (&results, G_VARIANT_TYPE ("a{sv}")); flatpak_authenticator_request_emit_response (data->request, @@ -166,7 +166,7 @@ handle_request_close (FlatpakAuthenticatorRequest *object, } else { - g_debug ("Ignored webflow cancel by client"); + g_info ("Ignored webflow cancel by client"); finish_request_ref_tokens (data); /* Silently succeed anyway */ } @@ -196,7 +196,7 @@ handle_request_ref_tokens (FlatpakAuthenticator *authenticator, gsize n_refs, i; g_autofree char *options_s = NULL; - g_debug ("handling RequestRefTokens"); + g_info ("handling RequestRefTokens"); options_s = g_variant_print (arg_options, FALSE); write_request (g_strdup_printf ("remote: %s\n" @@ -260,7 +260,7 @@ handle_request_ref_tokens (FlatpakAuthenticator *authenticator, { g_autoptr(GVariant) options = g_variant_ref_sink (g_variant_new_array (G_VARIANT_TYPE ("{sv}"), NULL, 0)); uri = g_strdup_printf ("http://localhost:%d", (int)port); - g_debug ("Requesting webflow %s", uri); + g_info ("Requesting webflow %s", uri); flatpak_authenticator_request_emit_webflow (request, uri, options); } else @@ -279,7 +279,7 @@ on_bus_acquired (GDBusConnection *connection, { GError *error = NULL; - g_debug ("Bus acquired, creating skeleton"); + g_info ("Bus acquired, creating skeleton"); g_dbus_connection_set_exit_on_close (connection, FALSE); @@ -303,7 +303,7 @@ on_name_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) { - g_debug ("Name acquired"); + g_info ("Name acquired"); } static void @@ -311,7 +311,7 @@ on_name_lost (GDBusConnection *connection, const gchar *name, gpointer user_data) { - g_debug ("Name lost"); + g_info ("Name lost"); } @@ -322,7 +322,7 @@ message_handler (const gchar *log_domain, gpointer user_data) { /* Make this look like normal console output */ - if (log_level & G_LOG_LEVEL_DEBUG) + if (log_level & (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO)) g_printerr ("F: %s\n", message); else g_printerr ("%s: %s\n", g_get_prgname (), message); @@ -372,9 +372,9 @@ main (int argc, } if (opt_verbose) - g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, message_handler, NULL); + g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, message_handler, NULL); - g_debug ("Started test-authenticator"); + g_info ("Started test-authenticator"); session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); if (session_bus == NULL) diff --git a/tests/test-context.c b/tests/test-context.c index b13a2a4d..785ca509 100644 --- a/tests/test-context.c +++ b/tests/test-context.c @@ -1,4 +1,4 @@ -/* +/* vi:set et sw=2 sts=2 cin cino=t0,f0,(0,{s,>2s,n-s,^-s,e-s: * Copyright © 2021 Collabora Ltd. * * This program is free software; you can redistribute it and/or diff --git a/tests/test-exports.c b/tests/test-exports.c index 9423464e..b6ff4aed 100644 --- a/tests/test-exports.c +++ b/tests/test-exports.c @@ -1,4 +1,4 @@ -/* +/* vi:set et sw=2 sts=2 cin cino=t0,f0,(0,{s,>2s,n-s,^-s,e-s: * Copyright © 2020 Collabora Ltd. * * This program is free software; you can redistribute it and/or diff --git a/tests/test-history.sh b/tests/test-history.sh index 0647742e..712f69c6 100755 --- a/tests/test-history.sh +++ b/tests/test-history.sh @@ -10,6 +10,7 @@ USE_SYSTEMDIR=yes skip_without_bwrap skip_revokefs_without_fuse +skip_without_libsystemd HISTORY_START_TIME=$(date +"%Y-%m-%d %H:%M:%S") sleep 1 diff --git a/tests/test-http-utils.sh b/tests/test-http-utils.sh index 04f66257..ede32621 100755 --- a/tests/test-http-utils.sh +++ b/tests/test-http-utils.sh @@ -52,11 +52,11 @@ assert_cached() { } assert_304() { - assert_result "Server returned status 304:" $@ + assert_result "Server returned status 304" $@ } assert_ok() { - assert_result "Server returned status 200:" $@ + assert_result "Server returned status 200" $@ } diff --git a/tests/test-instance.c b/tests/test-instance.c index b186d60d..d6ba40d8 100644 --- a/tests/test-instance.c +++ b/tests/test-instance.c @@ -1,4 +1,4 @@ -/* +/* vi:set et sw=2 sts=2 cin cino=t0,f0,(0,{s,>2s,n-s,^-s,e-s: * Copyright © 2021 Collabora Ltd. * * This program is free software; you can redistribute it and/or diff --git a/tests/test-keyring/meson.build b/tests/test-keyring/meson.build new file mode 100644 index 00000000..b0f4851e --- /dev/null +++ b/tests/test-keyring/meson.build @@ -0,0 +1,17 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +foreach file : [ + 'README', + 'pubring.gpg', + 'secring.gpg', +] + configure_file( + input : file, + output : file, + copy : true, + install : get_option('installed_tests'), + install_dir : installed_testdir / 'test-keyring', + install_mode : 'rw-r--r--', + ) +endforeach diff --git a/tests/test-keyring2/meson.build b/tests/test-keyring2/meson.build new file mode 100644 index 00000000..0c653a08 --- /dev/null +++ b/tests/test-keyring2/meson.build @@ -0,0 +1,17 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +foreach file : [ + 'README', + 'pubring.gpg', + 'secring.gpg', +] + configure_file( + input : file, + output : file, + copy : true, + install : get_option('installed_tests'), + install_dir : installed_testdir / 'test-keyring2', + install_mode : 'rw-r--r--', + ) +endforeach diff --git a/tests/test-matrix/meson.build b/tests/test-matrix/meson.build new file mode 100644 index 00000000..15176048 --- /dev/null +++ b/tests/test-matrix/meson.build @@ -0,0 +1,45 @@ +# This file is autogenerated by ./tests/update-test-matrix, don't edit +wrapped_tests += {'name' : 'test-run@user,nodeltas.wrap', 'script' : 'test-run.sh'} +wrapped_tests += {'name' : 'test-run@user,deltas.wrap', 'script' : 'test-run.sh'} +wrapped_tests += {'name' : 'test-run@system,nodeltas.wrap', 'script' : 'test-run.sh'} +wrapped_tests += {'name' : 'test-run@system,deltas.wrap', 'script' : 'test-run.sh'} +wrapped_tests += {'name' : 'test-run@system-norevokefs,nodeltas.wrap', 'script' : 'test-run.sh'} +wrapped_tests += {'name' : 'test-run@system-norevokefs,deltas.wrap', 'script' : 'test-run.sh'} +wrapped_tests += {'name' : 'test-info@user.wrap', 'script' : 'test-info.sh'} +wrapped_tests += {'name' : 'test-info@system.wrap', 'script' : 'test-info.sh'} +wrapped_tests += {'name' : 'test-repo@user.wrap', 'script' : 'test-repo.sh'} +wrapped_tests += {'name' : 'test-repo@system.wrap', 'script' : 'test-repo.sh'} +wrapped_tests += {'name' : 'test-repo@system-norevokefs.wrap', 'script' : 'test-repo.sh'} +wrapped_tests += {'name' : 'test-repo@user,oldsummary.wrap', 'script' : 'test-repo.sh'} +wrapped_tests += {'name' : 'test-repo@system,oldsummary.wrap', 'script' : 'test-repo.sh'} +wrapped_tests += {'name' : 'test-sideload@user.wrap', 'script' : 'test-sideload.sh'} +wrapped_tests += {'name' : 'test-sideload@system.wrap', 'script' : 'test-sideload.sh'} +wrapped_tests += {'name' : 'test-bundle@user.wrap', 'script' : 'test-bundle.sh'} +wrapped_tests += {'name' : 'test-bundle@system.wrap', 'script' : 'test-bundle.sh'} +wrapped_tests += {'name' : 'test-bundle@system-norevokefs.wrap', 'script' : 'test-bundle.sh'} +wrapped_tests += {'name' : 'test-oci-registry@user.wrap', 'script' : 'test-oci-registry.sh'} +wrapped_tests += {'name' : 'test-oci-registry@system.wrap', 'script' : 'test-oci-registry.sh'} +wrapped_tests += {'name' : 'test-update-remote-configuration@newsummary.wrap', 'script' : 'test-update-remote-configuration.sh'} +wrapped_tests += {'name' : 'test-update-remote-configuration@oldsummary.wrap', 'script' : 'test-update-remote-configuration.sh'} +wrapped_tests += {'name' : 'test-update-portal@user.wrap', 'script' : 'test-update-portal.sh'} +wrapped_tests += {'name' : 'test-update-portal@system.wrap', 'script' : 'test-update-portal.sh'} +wrapped_tests += {'name' : 'test-summaries@user.wrap', 'script' : 'test-summaries.sh'} +wrapped_tests += {'name' : 'test-summaries@system.wrap', 'script' : 'test-summaries.sh'} +wrapped_tests += {'name' : 'test-subset@user.wrap', 'script' : 'test-subset.sh'} +wrapped_tests += {'name' : 'test-subset@system.wrap', 'script' : 'test-subset.sh'} +wrapped_tests += {'name' : 'test-basic.sh', 'script' : 'test-basic.sh'} +wrapped_tests += {'name' : 'test-completion.sh', 'script' : 'test-completion.sh'} +wrapped_tests += {'name' : 'test-config.sh', 'script' : 'test-config.sh'} +wrapped_tests += {'name' : 'test-build-update-repo.sh', 'script' : 'test-build-update-repo.sh'} +wrapped_tests += {'name' : 'test-http-utils.sh', 'script' : 'test-http-utils.sh'} +wrapped_tests += {'name' : 'test-history.sh', 'script' : 'test-history.sh'} +wrapped_tests += {'name' : 'test-default-remotes.sh', 'script' : 'test-default-remotes.sh'} +wrapped_tests += {'name' : 'test-metadata-validation.sh', 'script' : 'test-metadata-validation.sh'} +wrapped_tests += {'name' : 'test-extensions.sh', 'script' : 'test-extensions.sh'} +wrapped_tests += {'name' : 'test-oci.sh', 'script' : 'test-oci.sh'} +wrapped_tests += {'name' : 'test-override.sh', 'script' : 'test-override.sh'} +wrapped_tests += {'name' : 'test-auth.sh', 'script' : 'test-auth.sh'} +wrapped_tests += {'name' : 'test-unused.sh', 'script' : 'test-unused.sh'} +wrapped_tests += {'name' : 'test-prune.sh', 'script' : 'test-prune.sh'} +wrapped_tests += {'name' : 'test-seccomp.sh', 'script' : 'test-seccomp.sh'} +wrapped_tests += {'name' : 'test-repair.sh', 'script' : 'test-repair.sh'} diff --git a/tests/test-portal-impl.c b/tests/test-portal-impl.c index ae53ab54..e5264ff8 100644 --- a/tests/test-portal-impl.c +++ b/tests/test-portal-impl.c @@ -100,7 +100,7 @@ on_bus_acquired (GDBusConnection *connection, GError *error = NULL; guint registration_id; - g_debug ("Bus acquired, creating skeleton"); + g_info ("Bus acquired, creating skeleton"); registration_id = g_dbus_connection_register_object (connection, "/org/freedesktop/portal/desktop", (GDBusInterfaceInfo *) &access_interface_info, @@ -114,7 +114,7 @@ on_name_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) { - g_debug ("Name acquired"); + g_info ("Name acquired"); } static void @@ -122,7 +122,7 @@ on_name_lost (GDBusConnection *connection, const gchar *name, gpointer user_data) { - g_debug ("Name lost"); + g_info ("Name lost"); } int diff --git a/tests/test-portal.c b/tests/test-portal.c index 35789061..234c612d 100644 --- a/tests/test-portal.c +++ b/tests/test-portal.c @@ -1,4 +1,4 @@ -/* +/* vi:set et sw=2 sts=2 cin cino=t0,f0,(0,{s,>2s,n-s,^-s,e-s: * Copyright © 2018-2021 Collabora Ltd. * * This program is free software; you can redistribute it and/or @@ -226,7 +226,7 @@ count_successful_exit_cb (PortalFlatpak *proxy, { gsize *times_exited_p = user_data; - g_debug ("Process %u exited with wait status %u", pid, wait_status); + g_info ("Process %u exited with wait status %u", pid, wait_status); g_assert_true (WIFEXITED (wait_status)); g_assert_cmpuint (WEXITSTATUS (wait_status), ==, 0); (*times_exited_p) += 1; diff --git a/tests/test-repo.sh b/tests/test-repo.sh index 926072ab..55403259 100644 --- a/tests/test-repo.sh +++ b/tests/test-repo.sh @@ -24,7 +24,7 @@ set -euo pipefail skip_without_bwrap skip_revokefs_without_fuse -echo "1..44" +echo "1..45" #Regular repo setup_repo @@ -192,7 +192,7 @@ port=$(cat httpd-port) if ${FLATPAK} ${U} install -y http://127.0.0.1:${port}/nonexistent.flatpakref &> install-error-log; then assert_not_reached "Should not be able to install a nonexistent flatpakref" fi -assert_file_has_content install-error-log "Server returned status 404: Not Found" +assert_file_has_content install-error-log "Server returned status 404" ok "install fails gracefully for 404 URLs" @@ -208,7 +208,7 @@ GPGKey=${FL_GPG_BASE64} EOF if [ x${USE_COLLECTIONS_IN_CLIENT-} == xyes ]; then - echo "DeployCollectionID=org.test.Collection.Flatpakref" >> repos/flatpakref/flatpakref-repo.flatpakrepo + echo "DeploySideloadCollectionID=org.test.Collection.Flatpakref" >> repos/flatpakref/flatpakref-repo.flatpakrepo fi cat << EOF > org.test.Hello.flatpakref @@ -221,6 +221,10 @@ GPGKey=${FL_GPG_BASE64} RuntimeRepo=http://127.0.0.1:$(cat httpd-port)/flatpakref/flatpakref-repo.flatpakrepo EOF +if [ x${USE_COLLECTIONS_IN_CLIENT-} == xyes ]; then + echo "DeploySideloadCollectionID=org.test.Collection.Flatpakref" >> org.test.Hello.flatpakref +fi + ${FLATPAK} ${U} uninstall -y org.test.Platform org.test.Hello >&2 # Ensure that only one remote is added even though the URL in the flatpakref @@ -239,6 +243,14 @@ assert_remote_has_config allthegoodstuff xa.title "The Remote Title" ok "install flatpakref uses RuntimeRepo metadata for remote" +if [ x${USE_COLLECTIONS_IN_CLIENT-} == xyes ]; then + assert_remote_has_config allthegoodstuff collection-id "org.test.Collection.Flatpakref" +else + assert_remote_has_no_config allthegoodstuff collection-id +fi + +ok "install flatpakref sets collection-id on remote if available" + ${FLATPAK} ${U} uninstall -y org.test.Platform org.test.Hello >&2 if ${FLATPAK} ${U} install -y test-missing-gpg-repo org.test.Platform &> install-error-log; then diff --git a/tests/testlib.c b/tests/testlib.c index 822fbf09..41f27ac9 100644 --- a/tests/testlib.c +++ b/tests/testlib.c @@ -1,4 +1,4 @@ -/* +/* vi:set et sw=2 sts=2 cin cino=t0,f0,(0,{s,>2s,n-s,^-s,e-s: * Copyright © 2018-2021 Collabora Ltd. * * This program is free software; you can redistribute it and/or diff --git a/tests/testlib.h b/tests/testlib.h index 25b096bd..f3b9188a 100644 --- a/tests/testlib.h +++ b/tests/testlib.h @@ -22,11 +22,6 @@ #include <gio/gio.h> #include <libglnx.h> -#ifndef g_assert_no_errno -#define g_assert_no_errno(expr) \ - g_assert_cmpstr ((expr) >= 0 ? NULL : g_strerror (errno), ==, NULL) -#endif - char *assert_mkdtemp (char *tmpl); extern char *isolated_test_dir; diff --git a/tests/testlibrary.c b/tests/testlibrary.c index 405d0c5b..fd09d758 100644 --- a/tests/testlibrary.c +++ b/tests/testlibrary.c @@ -2382,7 +2382,7 @@ make_bundle (void) argv[2] = arg2; argv[4] = file; - g_debug ("Making dir %s", path); + g_info ("Making dir %s", path); g_mkdir_with_parents (path, S_IRWXU | S_IRWXG | S_IRWXO); run_test_subprocess (argv, RUN_TEST_SUBPROCESS_DEFAULT); @@ -3568,6 +3568,27 @@ add_new_remote3 (FlatpakTransaction *transaction, return TRUE; } +static gboolean +ready_check_get_op (FlatpakTransaction *transaction) +{ + g_autoptr(GError) error = NULL; + g_autofree char *app = NULL; + g_autoptr(FlatpakTransactionOperation) op = NULL; + + app = g_strdup_printf ("app/org.test.Hello/%s/master", + flatpak_get_default_arch ()); + + op = flatpak_transaction_get_operation_for_ref (transaction, NULL, app, &error); + g_assert_no_error (error); + g_assert_nonnull (op); + + g_assert_cmpint (flatpak_transaction_operation_get_operation_type (op), ==, FLATPAK_TRANSACTION_OPERATION_INSTALL); + g_assert_cmpstr (flatpak_transaction_operation_get_ref (op), ==, app); + g_assert_cmpstr (flatpak_transaction_operation_get_remote (op), ==, "test-without-runtime-repo"); + + return TRUE; +} + /* Test that installing a flatpakref causes both the origin remote and the * runtime remote to be created, even if they already exist in another * installation */ @@ -3622,6 +3643,7 @@ test_transaction_flatpakref_remote_creation (void) g_assert_true (res); g_signal_connect (transaction, "add-new-remote", G_CALLBACK (add_new_remote3), NULL); + g_signal_connect (transaction, "ready", G_CALLBACK (ready_check_get_op), NULL); res = flatpak_transaction_run (transaction, NULL, &error); g_assert_no_error (error); diff --git a/tests/try-syscall.c b/tests/try-syscall.c index df350542..221fe324 100644 --- a/tests/try-syscall.c +++ b/tests/try-syscall.c @@ -1,4 +1,4 @@ -/* +/* vi:set et sw=2 sts=2 cin cino=t0,f0,(0,{s,>2s,n-s,^-s,e-s: * Copyright 2021 Simon McVittie * SPDX-License-Identifier: LGPL-2.0-or-later * @@ -24,11 +24,11 @@ #include <sys/types.h> #if defined(_MIPS_SIM) -# if _MIPS_SIM == _MIPS_SIM_ABI32 +# if _MIPS_SIM == _ABIO32 # define MISSING_SYSCALL_BASE 4000 -# elif _MIPS_SIM == _MIPS_SIM_ABI64 +# elif _MIPS_SIM == _ABI64 # define MISSING_SYSCALL_BASE 5000 -# elif _MIPS_SIM == _MIPS_SIM_NABI32 +# elif _MIPS_SIM == _ABIN32 # define MISSING_SYSCALL_BASE 6000 # else # error "Unknown MIPS ABI" @@ -71,6 +71,10 @@ */ #define WRONG_POINTER ((char *) 1) +#ifndef PR_GET_CHILD_SUBREAPER +#define PR_GET_CHILD_SUBREAPER 37 +#endif + int main (int argc, char **argv) { diff --git a/tests/update-test-matrix b/tests/update-test-matrix index 04e65316..4449cc50 100755 --- a/tests/update-test-matrix +++ b/tests/update-test-matrix @@ -37,3 +37,4 @@ TEST_MATRIX_SOURCE=( ) "${tests_srcdir}/expand-test-matrix.sh" --automake "${TEST_MATRIX_SOURCE[*]}" > "${tests_srcdir}/Makefile-test-matrix.am.inc" +"${tests_srcdir}/expand-test-matrix.sh" --meson "${TEST_MATRIX_SOURCE[*]}" > "${tests_srcdir}/test-matrix/meson.build" |