~network-manager/network-manager/ubuntu.hardy.07

« back to all changes in this revision

Viewing changes to test/test-common/test-common.c

* merge 0.7~~svn20080905t025540+eni0 snapshot to hardy branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* NetworkManager -- Forget about your network
2
 
 *
3
 
 * Dan Williams <dcbw@redhat.com>
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation; either version 2 of the License, or
8
 
 * (at your option) any later version.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License along
16
 
 * with this program; if not, write to the Free Software Foundation, Inc.,
17
 
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
 
 *
19
 
 * (C) Copyright 2005 Red Hat, Inc.
20
 
 */
21
 
 
22
 
 
23
 
#include <glib.h>
24
 
#include <stdlib.h>
25
 
#include <stdio.h>
26
 
 
27
 
#include "test-common.h"
28
 
 
29
 
 
30
 
void
31
 
test_result (const char *progname,
32
 
             const char *test,
33
 
             TestResult result,
34
 
             const char *format,
35
 
             ...)
36
 
{
37
 
        va_list args;
38
 
        char *  errmsg = NULL;
39
 
        char *  full_msg = NULL;
40
 
        char *  result_string = NULL;
41
 
 
42
 
        if (format)
43
 
        {
44
 
                errmsg = g_malloc0 (257);
45
 
                va_start (args, format);
46
 
                vsnprintf (errmsg, 256, format, args);
47
 
                va_end (args);
48
 
        }
49
 
 
50
 
        if (result == TEST_FAIL)
51
 
                result_string = "FAIL";
52
 
        else
53
 
                result_string = "SUCCEED";
54
 
 
55
 
        full_msg = g_strdup_printf ("%s: (%s) %s %s\n", progname, test, result_string, errmsg ? errmsg : "");
56
 
        fprintf (stderr, "%s", full_msg);
57
 
        g_free (full_msg);
58
 
        g_free (errmsg);
59
 
 
60
 
        if (result == TEST_FAIL)
61
 
                exit (-1);
62
 
}
63