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

« back to all changes in this revision

Viewing changes to test/polkit/polkitunixnetgrouptest.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
#include <string.h>
 
25
 
 
26
 
 
27
static void
 
28
test_new (void)
 
29
{
 
30
  PolkitUnixNetgroup *netgroup;
 
31
  const char *netgroup_name;
 
32
 
 
33
  netgroup = POLKIT_UNIX_NETGROUP (polkit_unix_netgroup_new ("testgroup"));
 
34
  g_assert (netgroup);
 
35
 
 
36
  netgroup_name = polkit_unix_netgroup_get_name (netgroup);
 
37
  g_assert_cmpstr (netgroup_name, ==, "testgroup");
 
38
 
 
39
  g_object_unref (netgroup);
 
40
}
 
41
 
 
42
 
 
43
static void
 
44
test_set_name (void)
 
45
{
 
46
  PolkitUnixNetgroup *netgroup;
 
47
  const char *netgroup_name;
 
48
  char new_name_buf [] = "foo";
 
49
 
 
50
  netgroup = POLKIT_UNIX_NETGROUP (polkit_unix_netgroup_new ("testgroup"));
 
51
 
 
52
  polkit_unix_netgroup_set_name (netgroup, new_name_buf);
 
53
  netgroup_name = polkit_unix_netgroup_get_name (netgroup);
 
54
  g_assert_cmpstr (netgroup_name, ==, "foo");
 
55
 
 
56
  memcpy(new_name_buf, "bar", 3);
 
57
  netgroup_name = polkit_unix_netgroup_get_name (netgroup);
 
58
  g_assert_cmpstr (netgroup_name, ==, "foo");
 
59
 
 
60
  polkit_unix_netgroup_set_name (netgroup, new_name_buf);
 
61
  netgroup_name = polkit_unix_netgroup_get_name (netgroup);
 
62
  g_assert_cmpstr (netgroup_name, ==, "bar");
 
63
 
 
64
  g_object_unref (netgroup);
 
65
}
 
66
 
 
67
 
 
68
int
 
69
main (int argc, char *argv[])
 
70
{
 
71
  g_type_init ();
 
72
  g_test_init (&argc, &argv, NULL);
 
73
  g_test_add_func ("/PolkitUnixNetgroup/new", test_new);
 
74
  g_test_add_func ("/PolkitUnixNetgroup/set_name", test_set_name);
 
75
  return g_test_run ();
 
76
}