1
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
3
* Copyright (C) 2007-2010 David Zeuthen <david@fubar.dk>
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.
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.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
#include <udisks/udisks.h>
31
main (int argc, char *argv[])
39
g_assert_cmpint (argc, ==, 2);
40
switch (strtol (argv[1], NULL, 10))
43
g_print ("Hello Stdout\n"
49
g_printerr ("Hello Stderr\n"
63
/* cause abnormal termination, segfault */
64
g_print ("OK, deliberately causing a segfault\n");
66
const gchar **p = NULL;
69
g_assert_not_reached ();
74
g_print ("OK, deliberately abort()'ing\n");
76
g_assert_not_reached ();
80
/* write binary output to stdout (including NUL bytes) */
83
for (n = 0; n < 100; n++)
85
g_assert_cmpint (fputc (n, stdout), !=, EOF);
86
g_assert_cmpint (fputc (0, stdout), !=, EOF);
93
/* read from stdin.. echo that back */
98
s = g_string_new (NULL);
99
while ((c = fgetc (stdin)) != EOF)
100
g_string_append_c (s, c);
101
g_print ("Woah, you said `%s', partner!\n", s->str);
102
g_string_free (s, TRUE);
108
g_assert_not_reached ();
112
/* stderr is not buffered so force a flush */
113
if (fflush (stdout) != 0)
115
if (fflush (stderr) != 0)