Commit Graph
793 Commits
Author SHA1 Message Date
bbhtt b9ec9cab24 tests: Add test for NoRuntime extra-data app
(cherry picked from commit 79cb10e880)
2026-04-10 12:36:10 -04:00
Sebastian Wick 2bf787c496 tests: Add test-extra-data.sh to test extra-data installation
[smcv: Remove OCI test because #3790 was only solved in 1.17.x,
only keep libostree test]

(cherry picked from commit e9e713fa0d)
2026-04-10 12:36:10 -04:00
Sebastian Wick 8ebffc2ad3 tests/test-run-custom: Test --bind-fd and --ro-bind-fd 2026-04-08 19:07:46 -04:00
Sebastian Wick ab8ca4d6a0 tests/test-run-custom: Test --usr-path, --usr-fd, --app-path, --app-fd 2026-04-08 19:07:46 -04:00
Sebastian Wick ec36a48446 tests/test-run.sh: Only test for trigger results if we have the deps
If the binaries are not available in the environment, the trigger will
not do anything. The tests will not know about this and fail. So only
test for the results of the triggers if they have the dependencies they
require.

(cherry picked from commit 78b3c47c13)
2025-12-15 18:52:28 +01:00
Mary Strodl 4c5693b892 common: support reinstall option on bundle installations
Fixes #2489

Adds and wires up a `reinstall` option to
`flatpak_dir_install_bundle`. Previously, bundle install
transactions would silently drop the reinstall flag.

(backported from commit 919d2922bf)
2025-12-01 11:04:56 -05:00
Simon Chopin a13fc5b72f testlib: add expected argument to fcntl(F_DUPFD)
The F_DUPFD and its relative F_DUPFD_CLOEXEC both expect an int argument
as extra argument, being the minimal value for the new FD. This argument
must be within the accepted range (see ulimit -H -n).

This was detected in Ubuntu during testing against the latest glibc,
stracing resulted in:

107244 fcntl(1, F_DUPFD_CLOEXEC, 1847846346272) = -1 EINVAL (Invalid argument)

On the system in question (ppc64el machine running Ubuntu Questing), the
relevant limit is 524288.

For the fix we use 3 as a reasonable floor value, as in the first one
after stderr. It also happens to be the one used in revokefs/main.c.

Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/2121039
(cherry picked from commit 7399dea960)
2025-11-14 08:39:37 +05:30
Owen W. Taylor a2aad56cd7 tests: Add tests for https OCI remotes 2025-05-08 16:08:21 +00:00
Owen W. TaylorandSebastian Wick c75ba1c7e1 common: Implement /etc/containers/certs.d for OCI registries
Docker and podman can be configured to use mutual TLS authentication
to the registry by dropping files into system-wide and user
directories. Implement this in a largely compatible way.

(Because of the limitations of our underlying libraries, we
can't support multiple certificates within the same host config,
but I don't expect anybody actually needs that.)

The certs.d handling is extended so that certificates are separately
looked up when downloading the look-aside index. This is mostly
to simplify our tests, so we can use one web server for both -
in actual operation, we expect the indexes to be unauthenticated.

Also for testing purposes, FLATPAK_CONTAINER_CERTS_D is supported
to override the standard search path.

Co-authored-by: Sebastian Wick <sebastian.wick@redhat.com>
2025-05-08 16:08:21 +00:00
Owen W. Taylor f439e83f2a tests/oci-registry: Add support for SSL to client and server 2025-05-08 16:08:21 +00:00
Sebastian Wick 59c2186703 tests/oci-registry-server.py: Always get bytes for the response
And sent the Content-Length header.
2025-05-08 16:08:21 +00:00
Owen W. Taylor 199f7ccac5 tests/oci-registry-server.py: Convert to argparse 2025-05-08 16:08:21 +00:00
Sebastian Wick 5945a18d97 tests/oci-registry-server.py: Clean up Python style 2025-05-08 16:08:21 +00:00
Owen W. Taylor 05e2b083ed tests/oci-registry-client.py: Convert to argparse 2025-05-08 16:08:21 +00:00
Owen W. Taylor 34acb5799e tests/oci-registry-client.py: Parse URL parameter 2025-05-08 16:08:21 +00:00
Owen W. Taylor 82706e6d28 tests/oci-registry-client.py: Drop python2 compatibility 2025-05-08 16:08:21 +00:00
Sebastian Wick 7c722875b7 tests: Do not redirect stdout twice 2025-02-14 15:09:01 +01:00
Owen W. TaylorandSebastian Wick 73dd78f775 Add FLATPAK_DATA_DIR environment variable
Now that we read remotes from $datadir/flatpaks/remotes.d as well as
/etc/flatpaks/remotes.d, we should have a mechanism to redirect this, as
we do for almost all other filesystem path locations.

To avoid an explosion of new variables, we introduce FLATPAK_DATA_DIR to
represent configuration that ships with the operating system.

This is useful:
 - To fix sandboxing of tests
 - When installing using flatpak into a chroot, so that we read
   the chroot's configuration rather than the host.

It also is used when reading triggers, but the current
FLATPAK_TRIGGERSDIR is left for compatibility.

Co-authored-by: Sebastian Wick <sebastian.wick@redhat.com>
2024-12-18 16:32:02 +00:00
Simon McVittie 4025a96213 tests: Install missing test data
Without this, "as-installed" tests via `ginsttest-runner` will fail,
for example in Debian's autopkgtest framework.

Fixes: 1d56bd37 "context: Implement device lists for usb"
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-11-28 16:52:36 +00:00
Hubert Figuière 1d56bd377e context: Implement device lists for usb
Signed-off-by: Hubert Figuière <hub@figuiere.net>
2024-10-16 14:11:56 -03:00
19b447f49a flatpak: Add USB enumerables / hidden lists
Add '--usb' and '--nousb' to the FlatpakContext option group.

Map these parameters to either the enumarable list, or the hidden
list, of a new "USB Devices" group in the metadata key file. It looks
like this:

```
[USB Devices]
hidden-devices=cls:01:*;
enumerable-devices=vnd:0fd9+dev:0080;vnd:0fd9+dev:0080;
```

Flatpak itself does not use these values, they're meant to be used
by e.g. XDG Desktop Portal to filter which devices the app can see
through the USB portal.

Hidden devices must always take precedence over enumerable devices.

This is heavily inspired by https://github.com/flatpak/flatpak/pull/4083

Co-Authored-By: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
Co-Authored-By: Ryan Gonzalez <rymg19@gmail.com>
Signed-off-by: Hubert Figuière <hub@figuiere.net>
2024-10-16 14:11:56 -03:00
Simon McVittie 3498ecf9ab app, common, tests: Avoid deprecated g_qsort_with_data()
For historical reasons g_qsort_with_data() "only" works with up to 2**31
items, so it won't necessarily work for pathologically large arrays
and therefore is deprecated.

One advantage of g_qsort_with_data() and its replacement g_sort_array()
is that GLib guarantees that they are a stable sort (will not permute
items that already compare equal), which is not a guarantee for glibc's
qsort() and qsort_r(). However, I don't think it's actually relevant
whether we are doing a stable sort in any of these places: most of the
time we are sorting an array of unique items (often the keys of a hash
table, which are necessarily unique), therefore the compare function
will not compare equal in any case.

Another advantage of the GLib functions is that they are portable,
unlike qsort_r(). However, Flatpak is Linux-only, so we can freely use
useful functions like qsort_r().

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-10-15 13:53:07 +01:00
Cajus Pollmeier fb37012475 Add support for KDE search completion
KDE krunner supports DBus plugins that allow search completion
comparable to the already supported gnome-shell searchprovider.

Exporting the contents of the runner directory enables us to enable
search results from within flatpack applications.
2024-10-07 09:31:47 -05:00
Georges Basile Stavracas Neto 8ec21a28f2 portal: Add 'sandboxed-a11y-own-names' option
In context of the previous commit, this allows Flatpak apps to spawn
subsandboxes with `--a11y-own-name=DBUS_NAME`, where `DBUS_NAME` must
have the app id as prefix.

For example, `org.webkitgtk.MiniBrowser` would be able to spawn a Web
process using the Flatpak portal, and by passing
`org.webkitgtk.MiniBrowser.Sandboxed.WebProcess0`, this Web process
would be able to own this name in the a11y bus. This allows the Web
process and the main WebKit process to connect their a11y trees across
sandboxes.
2024-08-29 14:11:50 -03:00
Simon McVittie 17cd5a24e6 tests: Constify test data where it's easy to do so
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-08-22 15:17:13 -03:00
Simon McVittie 5964b13f1e Constify arrays of program arguments
These are passed to non-const-correct APIs which still need a cast, but
at least we can declare the array in a way that reduces mistakes.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-08-22 15:17:13 -03:00
Simon McVittie 0d61023710 test-run: Make it more obvious that we are setting G_DEBUG empty
shellcheck warning SC1007.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-08-22 16:08:33 +01:00
Alexander Larsson 2cdd1e1e5a Add test coverage for --persist
This adds three "positive" tests: the common case --persist=.persist, the
deprecated spelling --persist=/.persist, and the less common special case
--persist=. as used by Steam.

It also adds "negative" tests for CVE-2024-42472: if the --persist
directory is a symbolic link or contains path segment "..", we want that
to be rejected.

Reproduces: CVE-2024-42472, GHSA-7hgv-f2j8-xw87
[smcv: Add "positive" tests]
[smcv: Exercise --persist=..]
[smcv: Assert that --persist with a symlink produces expected message]
Co-authored-by: Simon McVittie <smcv@collabora.com>
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-08-12 19:33:25 +01:00
Sebastian Wick 5fc86a865c tests: Add an address sanitizer suppression file
There are two places where we deliberately leak some memory. There are
some cases which look like leaks in libostree but it's not impossible
that we made a mistake in flatpak.

Two other cases seem like issues in flatpak that I couldn't figure out.
2024-08-03 11:12:31 -05:00
Sebastian Wick dad0160eee tests/build: Add address sanitizer log file path
Logging into files means we don't mess up the test TAP output and
anything that requires a specific format.
2024-08-03 11:12:31 -05:00
Sebastian Wick 6519993de8 tests/build: Stop sharing the same environment for all tests
This allows us to pass different environments to different tests.
2024-08-03 11:12:31 -05:00
Sebastian Wick efa48c1c21 dir: Use same mechanism for get_system/user_default_base_dir_location
Also add the same missing valgrind suppression for the system dir
location.
2024-08-03 11:12:31 -05:00
triallax c9cdfb4265 tests: improve shell portability
I was trying to get the `flatpak` for Chimera Linux template to run
tests. However, due to Chimera Linux using core utilities based on
FreeBSD's, some stuff used in the test shell scripts didn't work there
and caused issues. While I eventually gave that endeavour up, I wanted
to upstream the upstreamable changes I had anyway.
2024-05-13 14:10:14 -05:00
Simon McVittie 07522238d9 testlibrary: Make use of assert_cmpstr_free_lhs(), etc.
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-25 17:23:25 +01:00
Simon McVittie ba367cb659 tests: Add macros to assert that a copied string has a desired value
Suggested by Patrick during review of #5691.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-25 17:23:25 +01:00
Simon McVittie 0982a4a93f tests: Fix a misleading comment
Arguably bwrap should exit with status 127 if it can't find the
executable, but right now it exits 1, so we accept any nonzero status.
The implementation was correct, but the comment was wrong.

Fixes: 84984e49 "test-run: Add a reproducer for CVE-2024-32462"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-18 20:06:35 -03:00
Simon McVittie 84984e4948 test-run: Add a reproducer for CVE-2024-32462
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-17 18:11:22 +01:00
Simon McVittie f16e064fd9 tests: Make sure FUSERMOUNT gets set for "as-installed" tests
Otherwise, tests for OCI and the update portal fail with:

    /usr/libexec/installed-tests/Flatpak/libtest.sh: line 611: FUSERMOUNT: unbound variable

Fixes: 2cb17b4e "Do not hard-code fusermount, add option or auto-detect instead"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-04-08 15:55:20 +01:00
Chris Williams be862f4989 tests: Add a test for a leftover eol-rebase symlink
This tests the fix in the previous commit.
2024-03-27 14:24:59 +00:00
Chris Williams 886462b811 tests: Check appdata name parsing via flatpak info
Add a basic test for the extraction of appdata name and summary values
that are displayed in the flatpak UI. Also use the new developer name
syntax in the test app. This tests the fix made in previous commit.
2024-03-12 08:31:08 -05:00
Pablo Correa Gómez 2cb17b4eb8 Do not hard-code fusermount, add option or auto-detect instead
The hard-coding is not appropriate. According to libfuse 3.0.0 release
notes: "The fusermount and mount.fuse binaries have been renamed to
fusermount3 and mount.fuse3 to allow co-installation of libfuse 2.x
and 3.x". Some distributions seem to install a symlink, but this is
not upstream's default behavior.

In addition, fusermount might be provided from non-distro sources. So
a build-time option takes precedence over auto-detection logic.

Fixes #5104

Fixes #5694
2024-02-19 12:05:05 +00:00
Simon McVittie 8e63eda867 Remove Autotools build system
As discussed in #5695, I think we're reaching a point where removing
Autotools is preferable to fixing it.

1.14.x continues to use Autotools, so platforms whose Meson version is
too old can stay on that branch until it becomes unsupported. We have
a very conservative Meson dependency (Ubuntu 20.04).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-16 19:30:32 +00:00
Simon McVittie 4b159b11eb httpcache: Free the GError before exiting
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-15 20:33:06 +00:00
Simon McVittie dfe995a457 testlibrary: Don't leak list of subpaths
flatpak_deploy_data_get_subpaths() returns a new array (of unowned
strings) and flatpak_dir_new_deploy_data() doesn't take ownership.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-15 20:33:06 +00:00
Simon McVittie 955e9ceed3 test_list_remote_related_refs: Don't leak list of subpaths
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-15 20:33:06 +00:00
Simon McVittie 7dc71e1fed testlibrary: Don't leak strings retrieved from remote
All of these getters are (transfer full) (but note that
flatpak_remote_get_name() isn't).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-15 20:33:06 +00:00
Simon McVittie 6636592d2d testlibrary: Don't leak an array of related refs
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-15 20:33:06 +00:00
Simon McVittie 88a919a32e testlibrary: Don't leak icon data 2024-02-15 20:33:06 +00:00
Simon McVittie 5cd581d0ae testlibrary: Don't leak FlatpakInstance
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-15 20:33:06 +00:00
Simon McVittie 843eca7958 testlibrary: Don't leak several installed references
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-15 20:33:06 +00:00