1/*
2 * Copyright © 2020 Red Hat, Inc.
3 *
4 * Author: Jakub Jelen <jjelen@redhat.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * See the included COPYING file for more information.
12 */
13
14#include <glib.h>
15
16/* The function g_get_user_database_entry() is called from the
17 * g_get_real_name(), g_get_user_name() and g_build_home_dir()
18 * functions. These two calls are here just to invoke the code
19 * paths. The real-test is the ld_preload used to inject the
20 * NULL in place of pw->pw_name.
21 */
22static void
23test_get_user_database_entry (void)
24{
25 const gchar *r = NULL;
26
27 r = g_get_user_name ();
28 g_assert_nonnull (r);
29
30 r = g_get_real_name ();
31 g_assert_nonnull (r);
32}
33
34int
35main (int argc, char *argv[])
36{
37 g_test_init (argc: &argc, argv: &argv, NULL);
38 g_test_bug_base (uri_pattern: "https://gitlab.gnome.org/GNOME/glib/issues");
39
40 g_test_add_func (testpath: "/gutils/get_user_database_entry", test_func: test_get_user_database_entry);
41
42 return g_test_run ();
43}
44

source code of gtk/subprojects/glib/glib/tests/gutils-user-database.c