Commit Graph

42 Commits

Author SHA1 Message Date
Simon McVittie
69f347e58a run: Support parsing non-local X11 addresses
We still don't support rewriting XAUTHORITY for these, but at least we
understand them now.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-11 15:25:50 +01:00
Simon McVittie
c3395a0e83 run: Treat DISPLAY=unix:42 the same as :42
xauth and xcb both treat this as a request to use AF_UNIX.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-11 15:25:50 +01:00
Simon McVittie
18db8e8713 run: Factor out parsing X11 displays into a helper function
This allows it to be unit-tested.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-11 15:25:50 +01:00
Simon McVittie
3d5725f9d3 testcommon: Use unusual architectures where it doesn't matter
If we use x86_64 and i386 in places where any architecture would do,
it's harder to recognise whether the test is assuming every machine
is x86 and would fail elsewhere (e.g. as fixed in #4142). When just
parsing abstract strings where any syntactically valid architecture
would do, let's use rare/niche architectures that none of the maintainers
are running on, so that hard-coding x86_64 or i386 stands out more.

I've used mips64 and m68k because they happen to be the same length as
x86_64 and i386, avoiding re-indentation.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-05-25 10:31:38 +02:00
Simon McVittie
bd5c2762cf testcommon: Assert that parse_datetime succeeds
scan-build detected that ret was written but never read.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-19 09:09:04 +02:00
Simon McVittie
3787db00e0 utils: Add flatpak_str_is_integer()
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-15 18:00:47 +02:00
Simon McVittie
d8a8ac2edb tests: Test flatpak_quote_argv and flatpak_argument_needs_quoting
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-13 14:14:10 +02:00
Simon McVittie
494feacb77 run: Sort environment before serializing it into bwrap arguments
This has no practical effect (assuming environment variables are unique),
but it makes it easier to find an environment variable of interest
in a very long bwrap command-line.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-04-06 16:19:09 +02:00
Alexander Larsson
7b1b706f80 decomposed: Add flatpak_decomposed_id_is_subref_of()
This checks if e.g. `org.app.App.Locale` is a subref of `org.app.App`.
2020-11-16 11:23:10 +01:00
Alexander Larsson
105edb64f5 decomposed: Add flatpak_decomposed_new_from_pref()
This is useful as we have partial refs in the metadata files, like
the app runtime dependency.
2020-11-10 14:32:13 +01:00
Alexander Larsson
3b63c51ce6 decomposed: Add support for FlatpakRefKind 2020-11-05 10:43:10 +01:00
Alexander Larsson
7465ba0f18 Various FlatpakDecomposed API updates
getters now have three forms:
  const char *foo_peek() returns pointer into data and length
  const char* foo_get() returns zero terminated pointer into data
  char *foo_dup() returns allocated zero terminated pointer

Not everything has all of these (as that is not always possible), but
it is clear what each one does.

We also now support storing a collection id for a
FlatpakDecomposed. This is not typically done (as we use the source
remote to define the collecion id and don't expose this concept to the
user). However, for the case when directly listing a local repo (such as
a side-load repo) we need this.

We now validate the arch string. The valid chars are a-z, A-Z, 0-9 and
_. This was't previously verified, but no arches in existance have other
chars.

There is a new flatpak_decomposed_new_from_decomposed() which lets you
modify part of another ref. Say replace the arch or the branch and
keep the rest the same.
2020-11-05 10:43:10 +01:00
Alexander Larsson
472939f538 utils: Add FlatpakDecomposed helper
This is a ref-counted version of a ref string that is guaranteed
to be in the proper form, and is pre-decomposed for efficient partial
matches.
2020-10-29 15:30:35 +01:00
Alexander Larsson
7483a98769 utils: Allow passing sizes to more utils
These now take (optional) string length args:
  flatpak_id_has_subref_suffix()
  flatpak_levenshtein_distance()
  flatpak_is_valid_name()
  flatpak_is_valid_branch()
2020-10-29 15:30:35 +01:00
Kalev Lember
34bb5592c9 common: Allow skewered to camelcase DConf path conversion both ways
commit 6b46d9a0ed that added DConf path
skewering to camelcase conversion only allowed it in one direction
(skewered path1 and camelcase path2).

That turned out to be not enough to allow /org/gnome/sound-juicer/ to
/org/gnome/SoundJuicer/ conversion as the caller had the
flatpak_dconf_path_is_similar() arguments the other way around.

This commit implements it both ways to avoid confusion which way it
should be called.

F: Ignoring D-Conf migrate-path setting /org/gnome/sound-juicer/
2020-10-01 11:15:54 +02:00
Bastien Nocera
6b46d9a0ed common: Allow skewering when converting in app-id for DConf migration
Allow a snake-case in the app-id to convert to a '-' or '_' in the
DConf path to be considered similar enough for DConf migration purposes.

This allows the org.gnome.SoundJuicer app-id to migrate its
/org/gnome/sound-juicer DConf path.

F: Ignoring D-Conf migrate-path setting /org/gnome/sound-juicer/
2020-09-15 08:59:53 +02:00
Phaedrus Leeds
86e150da85 tests: Use g_assert_true() not g_assert()
This way our test assertions can't be accidentally compiled out with
G_DISABLE_ASSERT.
2020-08-17 09:21:30 +02:00
Bastien Nocera
98c4b07322 common: Allow version numbers in app-id for DConf migration
Allow the app-id or the DConf path to finish with a digit and still be
considered similar enough for DConf migration purposes.

This allows the org.gnome.Rhythmbox3 app-id to migrate its
/org/gnome/rhythmbox DConf path.

See https://github.com/flathub/org.gnome.Rhythmbox3/pull/26
2020-03-17 13:12:57 +01:00
Bastien Nocera
a4df2bae2b tests: Better failure output for test_dconf_paths
Output whether we get an unexpected failure or success, and the values
we passed in, to make it easy to pinpoint the failing test.
2020-03-17 13:11:54 +01:00
Philip Withnall
0e53094645 flatpak-appdata: Add support for extracting app content ratings
This will be used in upcoming commits to enforce parental controls on
app installations.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://github.com/flatpak/flatpak/pull/2797
2019-10-03 10:42:04 +02:00
Alexander Larsson
b53f937d7e Fix installable tests when running on a tty
This sets FLATPAK_FANCY_OUTPUT=0 in most tests and then special cases
the test_fancy_output() test in case the installable tests are running
on an actual tty. This was causing failures because the added bold escapes
caused some test cases to not generate the expected output.

Closes: #2907
Approved by: alexlarsson
2019-05-16 15:24:47 +00:00
Matthias Clasen
25696d67e3 Add tests for dconf utilities
Closes: #2880
Approved by: alexlarsson
2019-05-07 06:11:18 +00:00
Alexander Larsson
894151033f tests: Add tests for client-side filtering
Closes: #2869
Approved by: alexlarsson
2019-05-06 13:58:58 +00:00
Ryan Gonzalez
89a6782c55 utils: Add flatpak_strv_merge
Closes: #2775
Approved by: alexlarsson
2019-04-12 08:59:35 +00:00
Matthew Leeds
e8816b7663 Remove extra newlines in variable definiton blocks
Uncrustify has an option "nl_func_var_def_blk" which is supposed to
ensure there's a newline character between the block of variable
definitions and the rest of the function body, but it gets confused and
thinks that the first instance of "g_autoptr" or "g_auto" being used on
a variable is the start of the function body. So this commit removes
those extra newline characters and removes that option in uncrustify.cfg
so they don't get re-added the next time uncrustify is run.

Here's the command I used:

perl -0777 -i -pe 's/\n(\n\s*g_auto\()/\1/g' `git ls-tree --name-only
-r HEAD | grep \\\.[ch]$ | grep -v common/valgrind-private.h |
grep -v app/flatpak-polkit-agent-text-listener\\\.[ch]`

I ran it again with "g_autoptr" in place of "g_auto", and made a few
manual edits to add back the newline when the g_auto* was in the middle
of a function body rather than at the top.

Closes: #2715
Approved by: matthiasclasen
2019-02-25 18:12:30 +00:00
Matthew Leeds
8d962a686f Run uncrustify
I had to make a few manual edits but other than those the changes look
reasonable.

Closes: #2715
Approved by: matthiasclasen
2019-02-25 18:12:30 +00:00
Matthias Clasen
228ee0bd0a appdata: Ignore allowed attributes
We only interested in a few of the attributes of some
tags, but we shouldn't fail if other valid attributes
are present.

Add some of the allowed attributes to the <release> element
in the appdata test and verify that we can still parse it.

The appstream spec is here:
https://www.freedesktop.org/software/appstream/docs/

Closes: #2674
Approved by: matthiasclasen
2019-02-02 00:52:32 +00:00
Matthias Clasen
ac14058d9a Update tests to match new output
Our tests notice the string changes in the previous commit.

Closes: #2624
Approved by: matthiasclasen
2019-01-23 12:45:00 +00:00
Matthias Clasen
1c831c131f Test appdata date parsing
Add a few dates to our appdata testdata,
and verify the results.

Closes: #2619
Approved by: alexlarsson
2019-01-21 08:46:57 +00:00
Matthias Clasen
e7172516a0 Add one more name matching test
This one is from #2615 and does not work.

Closes: #2616
Approved by: alexlarsson
2019-01-21 08:27:09 +00:00
Matthias Clasen
9fccb90f26 Add some tests for name matching
These examples are taken from commit 8f428fd768

Closes: #2616
Approved by: alexlarsson
2019-01-21 08:27:09 +00:00
Simon McVittie
7c3140bb7a testcommon: An i386 Flatpak doesn't support x86_64 apps
The compatible architectures are not symmetric: x86_64 and aarch64 can
run i386 and arm binaries, but i386 and arm cannot usually run x86_64
and aarch64 binaries.

This caused test failures on Debian i386 autobuilders.

Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #2603
Approved by: matthiasclasen
2019-01-16 12:51:32 +00:00
Alexander Larsson
a143161131 tests: Fix tests on intel gpus
We can't assume have-intel-gpu is not true!

Closes: #2589
Approved by: alexlarsson
2019-01-14 16:48:32 +00:00
Matthias Clasen
7a6e52eca8 Add tests for appdata parsing
Closes: #2580
Approved by: alexlarsson
2019-01-14 15:06:41 +00:00
Matthias Clasen
bd6f71a3c8 Update colum tests
We have tests for internal apis now, and they
catch when we change those apis. Yay.

Closes: #2460
Approved by: alexlarsson
2019-01-14 13:35:56 +00:00
Matthias Clasen
4f6f9dda1c Add tests for number parsing
Closes: #2578
Approved by: matthiasclasen
2019-01-12 02:05:05 +00:00
Matthias Clasen
ccd602dd19 Fix a compiler warning
The largest warning ever. Go clang!

Closes: #2498
Approved by: matthiasclasen
2019-01-11 18:32:45 +00:00
Matthias Clasen
0360fa84ef Adapt format_choices tests
The formatting has changed, and our tests catch that. Yay!
Also fix the build with glib master.

Closes: #2498
Approved by: matthiasclasen
2019-01-11 18:32:45 +00:00
Matthias Clasen
9e27fc67fe testcommon: Add another table ellipsization test
This tests the situation when we can't accommodate
the requested width with the available shrinkage.

This used to cause an infinite loop in the table
printer.

Closes: #2498
Approved by: matthiasclasen
2019-01-11 18:32:45 +00:00
Matthias Clasen
b095ca8ac6 datetime tests
Closes: #2498
Approved by: matthiasclasen
2019-01-11 18:32:45 +00:00
Matthias Clasen
16cf081f97 tests: Add tests for app helpers
Link testcommon against libflatpak-app.la and
add tests for some utility functions.

Closes: #2498
Approved by: matthiasclasen
2019-01-11 18:32:44 +00:00
Matthias Clasen
46e1f8f3b0 Add a test for some private utilities
Add another test that links against libflatpak-common.la
and tests functions that are not part of the public
library api.

Closes: #2498
Approved by: matthiasclasen
2019-01-11 18:32:44 +00:00