Version 1.5.23.
[libguestfs.git] / regressions / rhbz501893.c
1 /* Regression test for RHBZ#501893.
2  * Test that String parameters are checked for != NULL.
3  * Copyright (C) 2009-2010 Red Hat Inc.
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
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19
20 #include <config.h>
21
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <assert.h>
25
26 #include "guestfs.h"
27
28 int
29 main (int argc, char *argv[])
30 {
31   guestfs_h *g = guestfs_create ();
32
33   /* Call some non-daemon functions that have a String parameter, but
34    * setting that parameter to NULL.  Previously this would cause a
35    * segfault inside libguestfs.  After this bug was fixed, this
36    * turned into an error message.
37    */
38
39   assert (guestfs_add_drive (g, NULL) == -1);
40   assert (guestfs_config (g, NULL, NULL) == -1);
41
42   /* This optional argument must not be NULL. */
43
44   assert (guestfs_add_drive_opts (g, "/dev/null",
45                                   GUESTFS_ADD_DRIVE_OPTS_FORMAT, NULL,
46                                   -1) == -1);
47
48   /* These can be safely set to NULL, should be no error. */
49
50   assert (guestfs_set_path (g, NULL) == 0);
51   assert (guestfs_set_append (g, NULL) == 0);
52   assert (guestfs_set_qemu (g, NULL) == 0);
53
54   guestfs_close (g);
55   exit (EXIT_SUCCESS);
56 }