summaryrefslogtreecommitdiff
path: root/glib/tests/gutils-user-database.c
blob: 89a0e0b0f487e7dd92da4b21e3cc16ad768ebc57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * Copyright © 2020 Red Hat, Inc.
 *
 * Author: Jakub Jelen <jjelen@redhat.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * See the included COPYING file for more information.
 */

#include <glib.h>

/* The function g_get_user_database_entry() is called from the
 * g_get_real_name(), g_get_user_name() and g_build_home_dir()
 * functions. These two calls are here just to invoke the code
 * paths. The real-test is the ld_preload used to inject the
 * NULL in place of pw->pw_name.
 */
static void
test_get_user_database_entry (void)
{
  const gchar *r = NULL;

  r = g_get_user_name ();
  g_assert_nonnull (r);

  r = g_get_real_name ();
  g_assert_nonnull (r);
}

int
main (int argc, char *argv[])
{
  g_test_init (&argc, &argv, NULL);

  g_test_add_func ("/gutils/get_user_database_entry", test_get_user_database_entry);

  return g_test_run ();
}