~ubuntu-branches/ubuntu/trusty/policykit-1/trusty

« back to all changes in this revision

Viewing changes to test/polkit/polkitunixgrouptest.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2012-01-06 12:28:54 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20120106122854-ib9s0ej8akqiy0lb
Tags: 0.104-1
* New upstream release.
  - Add support for netgroups. (LP: #724052)
* debian/rules: Disable systemd support, continue to work with ConsokeKit.
* 05_revert-admin-identities-unix-group-wheel.patch: Refresh to apply
  cleanly.
* debian/libpolkit-gobject-1-0.symbols: Add new symbols from this new
  release.
* debian/rules: Do not let test failures fail the build. The new test suite
  also runs a test against the system D-BUS/ConsoleKit, which can't work on
  buildds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2011 Google Inc.
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Lesser General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General
 
15
 * Public License along with this library; if not, write to the
 
16
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 
17
 * Boston, MA 02111-1307, USA.
 
18
 *
 
19
 * Author: Nikki VonHollen <vonhollen@google.com>
 
20
 */
 
21
 
 
22
#include "glib.h"
 
23
#include <polkit/polkit.h>
 
24
 
 
25
 
 
26
static void
 
27
test_new (void)
 
28
{
 
29
  PolkitUnixGroup *group;
 
30
 
 
31
  group = POLKIT_UNIX_GROUP (polkit_unix_group_new (0));
 
32
  g_assert (group);
 
33
 
 
34
  gint group_gid = polkit_unix_group_get_gid (group);
 
35
  g_assert_cmpint (group_gid, ==, 0);
 
36
 
 
37
  g_object_unref (group);
 
38
}
 
39
 
 
40
 
 
41
static void
 
42
test_new_for_name (void)
 
43
{
 
44
  GError *error = NULL;
 
45
  PolkitUnixGroup *group;
 
46
 
 
47
  group = POLKIT_UNIX_GROUP (polkit_unix_group_new_for_name ("root", &error));
 
48
  g_assert (group);
 
49
  g_assert_no_error (error);
 
50
 
 
51
  gint group_gid = polkit_unix_group_get_gid (group);
 
52
  g_assert_cmpint (group_gid, ==, 0);
 
53
 
 
54
  g_object_unref (group);
 
55
}
 
56
 
 
57
 
 
58
static void
 
59
test_set_gid (void)
 
60
{
 
61
  PolkitUnixGroup *group;
 
62
  group = POLKIT_UNIX_GROUP (polkit_unix_group_new (0));
 
63
 
 
64
  polkit_unix_group_set_gid (group, 5);
 
65
 
 
66
  gint group_gid = polkit_unix_group_get_gid (group);
 
67
  g_assert_cmpint (group_gid, ==, 5);
 
68
 
 
69
  g_object_unref (group);
 
70
}
 
71
 
 
72
 
 
73
int
 
74
main (int argc, char *argv[])
 
75
{
 
76
  g_type_init ();
 
77
  g_test_init (&argc, &argv, NULL);
 
78
  g_test_add_func ("/PolkitUnixGroup/new", test_new);
 
79
  g_test_add_func ("/PolkitUnixGroup/new_for_name", test_new_for_name);
 
80
  g_test_add_func ("/PolkitUnixGroup/set_gid", test_set_gid);
 
81
  return g_test_run ();
 
82
}