mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-14 16:26:17 +01:00
Merge branch 'issue1906' into 'master'
gutils test: Don't assume that every Unix OS implements os-release(5) Closes #1906 See merge request GNOME/glib!1159
This commit is contained in:
commit
b50447b0ab
@ -520,15 +520,30 @@ test_desktop_special_dir (void)
|
|||||||
static void
|
static void
|
||||||
test_os_info (void)
|
test_os_info (void)
|
||||||
{
|
{
|
||||||
#if defined (G_OS_UNIX) || defined (G_OS_WIN32)
|
|
||||||
gchar *name;
|
gchar *name;
|
||||||
|
gchar *contents = NULL;
|
||||||
|
|
||||||
|
/* Whether this is implemented or not, it must not crash */
|
||||||
name = g_get_os_info (G_OS_INFO_KEY_NAME);
|
name = g_get_os_info (G_OS_INFO_KEY_NAME);
|
||||||
g_assert (name != NULL);
|
g_test_message ("%s: %s",
|
||||||
g_free (name);
|
G_OS_INFO_KEY_NAME,
|
||||||
|
name == NULL ? "(null)" : name);
|
||||||
|
|
||||||
|
#if defined (G_OS_WIN32) || defined (__APPLE__)
|
||||||
|
/* These OSs have a special case so NAME should always succeed */
|
||||||
|
g_assert_nonnull (name);
|
||||||
|
#elif defined (G_OS_UNIX)
|
||||||
|
if (g_file_get_contents ("/etc/os-release", &contents, NULL, NULL) ||
|
||||||
|
g_file_get_contents ("/usr/lib/os-release", &contents, NULL, NULL))
|
||||||
|
g_assert_nonnull (name);
|
||||||
|
else
|
||||||
|
g_test_skip ("os-release(5) API not implemented on this platform");
|
||||||
#else
|
#else
|
||||||
g_test_skip ("g_get_os_info() not supported on this platform");
|
g_test_skip ("g_get_os_info() not supported on this platform");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
g_free (name);
|
||||||
|
g_free (contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
Loading…
Reference in New Issue
Block a user