Commit Graph

19480 Commits

Author SHA1 Message Date
Philip Withnall
3026efbc0f docs: Fix some minor wording problems in the gio documentation
And some missing apostrophes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-19 12:17:49 +00:00
Philip Withnall
30ed95216a docs: Fix capitalisation of ‘ETag’
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-19 12:17:32 +00:00
Philip Withnall
7bac53d41f docs: Improve formatting of literals in gio documentation
There was no distinction between literals which need to be typed, and
normal words in the prose.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-19 12:16:48 +00:00
Philip Withnall
04af8f12f0 Merge branch 'master' into 'master'
GTlsConnection: add ALPN support

See merge request GNOME/glib!520
2018-12-19 12:01:50 +00:00
Philip Withnall
0953338704 Merge branch 'tpm-keys-in-pem-files' into 'master'
gtlscertificate: Add support for TPM keys in PEM files

See merge request GNOME/glib!522
2018-12-19 11:53:17 +00:00
Philip Withnall
46900e55e7 Merge branch 'mcatanzaro/g-assert-error-doc' into 'master'
Improve documentation of g_assert_error()

See merge request GNOME/glib!549
2018-12-19 09:29:26 +00:00
Michael Gratton
1d62b3b452 Merge branch 'wip/1615-gdbus-codgen-nullable' into 'master'
gdbus-codegen: Add missing nullable and optional g-i annotations to generated code

Closes #1615

See merge request GNOME/glib!526
2018-12-19 07:25:19 +00:00
Michael Gratton
613f63f4a1 gdbus-codegen: Add missing nullable and optional g-i annotations to generated code
Fixes #1615
2018-12-19 18:00:25 +11:00
Michael Catanzaro
0618d67411 Improve documentation of g_assert_error()
This macro is intended for use in tests, but recommends as an
alternative to use a macro that is not intended for use in tests.
Fix it.
2018-12-19 02:29:14 +00:00
Scott Hutton
9032e8897d Implement support for ALPN in GTlsConnection, GDtlsConnection 2018-12-18 16:32:55 -08:00
Philip Withnall
26f783576d Merge branch 'docs-fixes' into 'master'
Various minor docs fixes

See merge request GNOME/glib!536
2018-12-18 15:35:07 +00:00
Matthias Clasen
4e776d9167 Merge branch 'no-free-check' into 'master'
Do not check for NULL when calling free()

See merge request GNOME/glib!547
2018-12-18 13:51:50 +00:00
Emmanuele Bassi
84d013ed46 Do not check for NULL when calling free()
The C standard guarantees that `free()` is `NULL`-safe.
2018-12-18 13:27:43 +00:00
Philip Withnall
8aff74e213 Merge branch 'wip/kalev/recursive-mutex-locker' into 'master'
Add GRecMutexLocker

See merge request GNOME/glib!528
2018-12-18 12:18:40 +00:00
Kalev Lember
e7e40ba1cf tests: Update GMutexLocker tests
Spawn a thread and assert that the mutex actually got locked and then
unlocked again, same as we do in GRecMutexLocker tests.
2018-12-18 12:24:17 +01:00
Kalev Lember
8c2e71bba0 Add GRecMutexLocker
This is the same as GMutexLocker, just for recursive mutexes.
2018-12-18 12:24:17 +01:00
Fredrik Ternerot
a437a50694 gtlscertificate: Allow any type of private key in PEM files
Allow any type of private key in PEM files by treating PEM guards ending
with "PRIVATE KEY-----" as a private key instead of looking for a
pre-defined set of PEM guards. This enables the possibility for custom
GTlsBackend to add support for new key types.

Test cases have been expanded to ensure PEM parsing works for private
key when either header or footer is missing.

Encrypted PKCS#8 is still rejected. Test case has been added for this to
ensure behaviour is the same before and after this change.
2018-12-18 11:43:08 +01:00
Fredrik Ternerot
73ca761a8d tests/tls-certificate: Add PEM files containing CRLF
Add test case to ensure correct parsing of PEM files containing CRLF
(\r\n) line endings.
2018-12-18 11:41:45 +01:00
Fredrik Ternerot
c7ee522172 tests/tls-certificate: Change to g_assert_null/nonnull
Use g_assert_null/g_assert_nonnull instead of g_assert since
g_assert can be compiled out with G_DISABLE_ASSERT.
2018-12-18 11:40:26 +01:00
Philip Withnall
2a64176b83 Merge branch 'g-alignof' into 'master'
gmacros: Add G_ALIGNOF superseding _g_alignof macro

Closes #1055

See merge request GNOME/glib!538
2018-12-18 10:29:22 +00:00
Philip Withnall
79dc99b9f0 Merge branch 'wip/add-shebang-to-test-script' into 'master'
spawn: add shebang line to script

See merge request GNOME/glib!546
2018-12-18 09:59:26 +00:00
Tapasweni Pathak
58bbdcf6c0 gmacros: Add G_ALIGNOF superseding _g_alignof macro 2018-12-18 13:59:23 +05:30
Ray Strode
3ab7a6544c spawn: add shebang line to script
downstream tools get confused when the script is missing a shebang
line, and having a shebang line doesn't hurt, so add one.
2018-12-17 16:19:31 -05:00
Philip Withnall
70eb076ac3 Merge branch '1601-appinfo-test-again' into 'master'
Support isolating directories for unit tests

Closes #538 and #1601

See merge request GNOME/glib!505
2018-12-17 17:51:37 +00:00
Philip Withnall
7a79984068 gutils: Drop fallback handling for NULL homedirs in XDG getters
It’s not possible for g_build_home_dir() to return NULL. The fallback
code here seems to originate from commit 1607e3f1 in 2005 (bug 169348),
where it was added with the explanation “Guard against g_home_dir being
NULL”.

The XDG Base Directory specification doesn’t have anything to say about
what to do when $HOME is unset:

https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

It’s all a bit moot, though, becaause since commit 9cbfb560
(bug 773435), g_{get,build}_home_dir() cannot return NULL. So just drop
the fallback.

See discussion on
https://gitlab.gnome.org/GNOME/glib/merge_requests/505#note_386109.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
1947834b70 tests: Disable debug output from desktop-app-info subprocess
The `apps` subprocess is spawned by desktop-app-info to interpret the
forest of .desktop files, and its output is provided on stdout. If debug
output is mixed up with that output, tests which parse the output fail.

Disable the debug output from the subprocess to prevent this.

The new debug output appeared as a result of recent changes to the
desktop file dir monitoring code in gdesktopappinfo.c.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
f8421059e9 tests: Add some debug output to desktop-app-info test
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
1ea4ba8d6e tests: Use static appinfo .desktop file when not launching
The appinfo-test.desktop file is set up with an Exec= path which points
to the compiled and installed appinfo-test utility. When running the
tests uninstalled, however, this might not be present, which causes
loading appinfo-test.desktop to fail.

Split appinfo-test.desktop in two: keep the existing
appinfo-test.desktop for tests which need to launch appinfo-test, and
add a new appinfo-test-static.desktop for tests which don’t launch
anything (and, for example, just inspect GAppInfo properties).
appinfo-test-static.desktop uses an Exec= line which should always be
present (`true`) so it should never fail to load.

Allow the tests using appinfo-test-static.desktop to be run uninstalled
or installed. Allow the tests using appinfo-test.desktop to be skipped
if loading appinfo-test.desktop fails, which is an indicator that the
test is running uninstalled.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
60c2533f44 tests: Port appinfo test from g_assert() to g_assert_*()
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
707c3f2495 tests: Isolate directories in mimeapps test
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
d23c893a0f tests: Isolate directories in appmonitor test
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
914e7c6014 tests: Isolate directories in desktop-app-info test
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
797a8b0930 tests: Isolate directories in appinfo test
This is essentially a reversion of commit
a39b847ddf, plus the addition of the new
G_TEST_OPTIONS_ISOLATE_XDG_DIRS option.

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

https://gitlab.gnome.org/GNOME/glib/issues/1601
2018-12-17 17:16:04 +00:00
Philip Withnall
99bc33b632 gdesktopappinfo: Reload the desktop dirs if the $XDG_CONFIG_HOME changes
This causes the desktop directory cache to be correctly reloaded between
unit tests if G_TEST_OPTION_ISOLATE_DIRS is in use.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
e97bf89dd4 gcontenttype: Improve the formatting of some code in a docs comment
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
b06fa34bb1 gcontenttype: Add g_content_type_{get,set}_mime_dirs() API
This allows the list of directories which contain MIME data to be set,
separately from the list of directories returned by
g_get_user_data_home() and g_get_system_data_dirs().

While the latter are overridden for a unit test, we don’t have access to
the system MIME registry, which can sometimes be useful for tests which
need to know about standard MIME associations from shared-mime-info.

Allow g_content_type_set_mime_dirs() to be used from unit tests to allow
them to use the system MIME registry again, or to allow them to be
pointed to another custom registry.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:04 +00:00
Philip Withnall
df2f13f89b gcontenttype: Improve formatting of gcontenttype section documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:03 +00:00
Philip Withnall
b6f7f37427 xdgmime: Add xdg_mime_set_dirs() method to override XDG envvars
In order to make xdgmime properly relocatable so that unit tests can use
it without it reading and modifying the user’s actual xdgmime files, and
without the need to call setenv() (and get tied up with thread safety
problems), add a xdg_mime_set_dirs() method to allow the dirs to be
overridden. They will still default to the values of $XDG_DATA_HOME and
$XDG_DATA_DIRS.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:03 +00:00
Philip Withnall
b4de2e3297 glib.supp: Add various one-time allocations to the suppression file
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:03 +00:00
Philip Withnall
b76372685d gutils: Split out building of g_get_home_dir() path
Otherwise we can have problems calling g_get_home_dir() from within a
g_build_*_dir() function elsewhere in gutils.c:
 • There will be a deadlock due to trying to recursively acquire the
   g_utils_global lock.
 • A stale g_home_dir value may be used if a test harness has called
   g_set_user_dirs() in the interim.

Fix that by splitting the code to find/construct the home path out of
g_get_home_dir() into g_build_home_dir(), the same way it’s split for
the other g_get_*() functions. Call g_build_home_dir() from any call
site where the g_utils_global lock is held.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:03 +00:00
Philip Withnall
528d537da8 tests: Port desktop-app-info to use g_assert_*()
g_assert() is for runtime code, and can be compiled out. g_assert_*()
cannot be compiled out, and give more helpful failure messages for
specific types.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:03 +00:00
Philip Withnall
13730c27c0 gtestutils: Add XDG directory isolation
Add a new G_TEST_OPTIONS_ISOLATE_XDG_DIRS option for g_test_init() which
automatically creates a temporary set of XDG directories, and a
temporary home directory, and overrides the g_get_user_data_dir() (etc.)
functions for the duration of the unit test with the temporary values.

This is intended to better isolate unit tests from the user’s actual
data and home directory. It works with g_test_subprocess(), but does not
work with subprocesses spawned manually by the test — each unit test’s
code will need to be amended to correctly set the XDG_* environment
variables in the environment of any spawned subprocess.

“Why not solve that by setting the XDG environment variables for the
whole unit test process tree?” I hear you say. Setting environment
variables is not thread safe and they would need to be re-set for each
unit test, once worker threads have potentially been spawned.

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

https://gitlab.gnome.org/GNOME/glib/issues/538
2018-12-17 17:16:03 +00:00
Philip Withnall
91defdb34e gutils: Add internal API to override XDG directories
Add a new internal function, g_set_user_dirs(), which will safely
override the values returned by g_get_user_data_dir() and friends, and
the value returned by g_get_home_dir().

This is intended to be used by unit tests, and will be hooked up to them
in a following commit.

This can be called as many times as needed by the current process. It’s
thread-safe. It does not modify the environment, so none of the changes
are propagated to any subsequently spawned subprocesses.

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

https://gitlab.gnome.org/GNOME/glib/issues/538
2018-12-17 17:16:03 +00:00
Philip Withnall
b87dfb4960 gutils: Don’t read directory globals outside the lock
While it is currently OK to read the global variables backing functions
like g_get_user_data_dir() without the g_utils_global lock held (since
such a read is always preceeded by a critical section where the variable
is set to its final value), upcoming changes will allow those variables
to be changed. If they are changed from one thread while another thread
is calling (for example) g_get_user_data_dir(), the final read from the
second thread could race with the first thread.

Avoid that by only reading the global variables with the lock held.

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

https://gitlab.gnome.org/GNOME/glib/issues/538
2018-12-17 17:16:03 +00:00
Philip Withnall
8da50ac40c gutils: Refactor g_get_home_dir() to use a global variable
While this might seem like a regression, it means that the home
directory can be overridden by GLib internal code, which will be done in
an upcoming commit. This brings g_get_home_dir() inline with functions
like g_get_user_data_dir().

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

https://gitlab.gnome.org/GNOME/glib/issues/538
2018-12-17 17:16:03 +00:00
Philip Withnall
2c8ae9f175 gtestutils: Forbid test paths from containing dots
In order to make some guarantees in an upcoming commit that test path
components won’t clash with file system names used by GLib, add a
restriction that test path components cannot start with a dot.

This is an API break, but one which anyone is unlikely to have hit. If
it is an issue, we can relax the restriction to be a warning.

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

https://gitlab.gnome.org/GNOME/glib/issues/538
2018-12-17 17:16:03 +00:00
Philip Withnall
592365239a tests: Drop extraneous newlines from g_test_message() calls in mimeapps
g_test_message() adds a newline already.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:03 +00:00
Philip Withnall
d4f804576a tests: Use g_assert_*() in mimeapps test rather than g_assert()
g_assert() can be compiled out with G_DISABLE_ASSERT, which renders the
test useless. The g_assert_*() functions provide more helpful feedback
on failure too.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-17 17:16:03 +00:00
Philip Withnall
8ddfbb308b tests: Fix indentation of a block in the appinfo test
No functional changes.

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

https://gitlab.gnome.org/GNOME/glib/issues/538
2018-12-17 17:16:03 +00:00
Philip Withnall
46f47641c5 tests: Avoid chdir() call at the start of appinfo tests
By encoding the path to the appinfo-test binary in the .desktop files,
we can avoid a chdir() call in the tests, which was a bit ugly.

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

https://gitlab.gnome.org/GNOME/glib/issues/538
2018-12-17 17:16:03 +00:00