Files
libguestfs/tests/c-api/test-event-string.c
Richard W.M. Jones e6c89f9631 utils: Rename ‘guestfs-internal-frontend.h’ to ‘guestfs-utils.h’.
The reason it's not just ‘utils.h’ is because Pino is worried that we
might pick up /usr/include/utils.h from a rogue library.
2017-07-10 17:01:59 +01:00

69 lines
1.8 KiB
C

/* libguestfs
* Copyright (C) 2013 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* Test guestfs_event_to_string. */
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include "guestfs.h"
#include "guestfs-utils.h"
int
main (int argc, char *argv[])
{
uint64_t events;
char *str;
events = 0;
str = guestfs_event_to_string (events);
assert (str != NULL);
assert (STREQ (str, ""));
free (str);
events = GUESTFS_EVENT_CLOSE;
str = guestfs_event_to_string (events);
assert (str != NULL);
assert (STREQ (str, "close"));
free (str);
events = GUESTFS_EVENT_CLOSE | GUESTFS_EVENT_PROGRESS;
str = guestfs_event_to_string (events);
assert (str != NULL);
assert (STREQ (str, "close,progress"));
free (str);
events = GUESTFS_EVENT_CLOSE | GUESTFS_EVENT_SUBPROCESS_QUIT | GUESTFS_EVENT_ENTER;
str = guestfs_event_to_string (events);
assert (str != NULL);
assert (STREQ (str, "close,enter,subprocess_quit"));
free (str);
events = GUESTFS_EVENT_ALL;
str = guestfs_event_to_string (events);
assert (str != NULL);
free (str);
exit (EXIT_SUCCESS);
}