~ubuntu-branches/ubuntu/wily/policykit-1/wily

« back to all changes in this revision

Viewing changes to test/polkittesthelper.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 "polkittesthelper.h"
 
23
#include <stdlib.h>
 
24
 
 
25
 
 
26
/* TODO: Log handling with unit tests is horrible. Figure out a way to always
 
27
 *       show logs, without munging up test output. For now, we hide them
 
28
 *       unless --verbose is used with g_test_message(...).
 
29
 */
 
30
 
 
31
void
 
32
polkit_test_log_handler (const gchar *log_domain,
 
33
                         GLogLevelFlags log_level,
 
34
                         const gchar *message,
 
35
                         gpointer user_data)
 
36
{
 
37
  g_test_message("%s", message);
 
38
}
 
39
 
 
40
/**
 
41
 * Send all future log messages to g_test_message(...).
 
42
 *
 
43
 * Logs will only be shown when test programs are run with --verbose.
 
44
 */
 
45
void
 
46
polkit_test_redirect_logs (void)
 
47
{
 
48
  g_log_set_default_handler (polkit_test_log_handler, NULL);
 
49
}
 
50
 
 
51
/**
 
52
 * Get absolute path to test data.
 
53
 *
 
54
 * Requires POLKIT_TEST_DATA environment variable to point to root data dir.
 
55
 *
 
56
 * @param relpath Relative path to test data
 
57
 * @return Full path to data as string. Free with g_free().
 
58
 */
 
59
gchar *
 
60
polkit_test_get_data_path (const gchar *relpath)
 
61
{
 
62
  const gchar *root = getenv ("POLKIT_TEST_DATA");
 
63
  if (root == NULL)
 
64
    return NULL;
 
65
 
 
66
  return g_strconcat(root, "/", relpath, NULL);
 
67
}
 
68