2 * Copyright (C) 2011 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program 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
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 /* Test that we can use the new event API to capture all debugging
30 #include "ignore-value.h"
35 debug_to_file (guestfs_h *g,
40 const char *buf, size_t buf_len,
41 const uint64_t *array, size_t array_len)
45 ignore_value (fwrite (buf, 1, buf_len, fp));
49 main (int argc, char *argv[])
52 const char *filename = "test.log";
55 debugfp = fopen (filename, "w");
56 if (debugfp == NULL) {
61 g = guestfs_create ();
63 fprintf (stderr, "failed to create handle\n");
67 if (guestfs_set_event_callback
69 GUESTFS_EVENT_LIBRARY|GUESTFS_EVENT_APPLIANCE|GUESTFS_EVENT_TRACE,
73 if (guestfs_set_verbose (g, 1) == -1)
76 if (guestfs_set_trace (g, 1) == -1)
79 if (guestfs_add_drive_opts (g, "/dev/null",
80 GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
81 GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,
85 if (guestfs_launch (g) == -1)