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
33 debug_to_file (guestfs_h *g,
38 const char *buf, size_t buf_len,
39 const uint64_t *array, size_t array_len)
43 fwrite (buf, 1, buf_len, fp);
47 main (int argc, char *argv[])
50 const char *filename = "test.log";
53 debugfp = fopen (filename, "w");
54 if (debugfp == NULL) {
59 g = guestfs_create ();
61 fprintf (stderr, "failed to create handle\n");
65 if (guestfs_set_event_callback
67 GUESTFS_EVENT_LIBRARY|GUESTFS_EVENT_APPLIANCE|GUESTFS_EVENT_TRACE,
71 if (guestfs_set_verbose (g, 1) == -1)
74 if (guestfs_set_trace (g, 1) == -1)
77 if (guestfs_add_drive_opts (g, "/dev/null",
78 GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
79 GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,
83 if (guestfs_launch (g) == -1)