[Pkg-libvirt-commits] [libguestfs] 83/233: tests: Add a regression test for parsing LIBGUESTFS_BACKEND/LIBGUESTFS_ATTACH_METHOD (RHBZ#1055452).

Hilko Bengen bengen at moszumanska.debian.org
Wed Feb 19 21:11:19 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch experimental
in repository libguestfs.

commit ecd31806a491c735878e9e54540a5c11ca1adce9
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Mon Jan 20 10:13:18 2014 +0000

    tests: Add a regression test for parsing LIBGUESTFS_BACKEND/LIBGUESTFS_ATTACH_METHOD (RHBZ#1055452).
---
 .gitignore                      |  1 +
 tests/regressions/Makefile.am   | 15 +++++++++-
 tests/regressions/rhbz1055452.c | 63 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 78 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 28e5591..26d5549 100644
--- a/.gitignore
+++ b/.gitignore
@@ -492,6 +492,7 @@ Makefile.in
 /tests/regressions/rhbz914931
 /tests/regressions/rhbz1044014
 /tests/regressions/rhbz1044014.out
+/tests/regressions/rhbz1055452
 /tests/rsync/rsyncd.pid
 /tests/syslinux/extlinux-guest.img
 /tests/syslinux/syslinux-guest.img
diff --git a/tests/regressions/Makefile.am b/tests/regressions/Makefile.am
index 5bdea3f..7ae306c 100644
--- a/tests/regressions/Makefile.am
+++ b/tests/regressions/Makefile.am
@@ -36,6 +36,7 @@ TESTS = \
 	rhbz957772.sh \
 	rhbz975797.sh \
 	rhbz1001875.sh \
+	rhbz1055452 \
 	test-noexec-stack.pl
 
 if HAVE_LIBVIRT
@@ -53,7 +54,8 @@ TESTS_ENVIRONMENT = \
 check_PROGRAMS = \
 	rhbz501893 \
 	rhbz790721 \
-	rhbz914931
+	rhbz914931 \
+	rhbz1055452
 
 if HAVE_LIBVIRT
 check_PROGRAMS += rhbz1044014
@@ -106,6 +108,17 @@ rhbz1044014_LDADD = \
         $(top_builddir)/gnulib/lib/libgnu.la
 endif
 
+rhbz1055452_SOURCES = rhbz1055452.c
+rhbz1055452_CPPFLAGS = \
+	-I$(top_srcdir)/src -I$(top_builddir)/src \
+	-DGUESTFS_PRIVATE=1
+rhbz1055452_CFLAGS = \
+	-pthread \
+	$(WARN_CFLAGS) $(WERROR_CFLAGS) \
+	$(GPROF_CFLAGS) $(GCOV_CFLAGS)
+rhbz1055452_LDADD = \
+	$(top_builddir)/src/libguestfs.la
+
 EXTRA_DIST = \
 	$(TESTS) \
 	$(tests_not_run) \
diff --git a/tests/regressions/rhbz1055452.c b/tests/regressions/rhbz1055452.c
new file mode 100644
index 0000000..4a1c115
--- /dev/null
+++ b/tests/regressions/rhbz1055452.c
@@ -0,0 +1,63 @@
+/* libguestfs
+ * Copyright (C) 2014 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.
+ */
+
+/* Regression test for RHBZ#1055452.  Check parsing of
+ * LIBGUESTFS_BACKEND/LIBGUESTFS_ATTACH_METHOD environment variables.
+ *
+ * We have to write this in C so that we can call
+ * guestfs_parse_environment.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "guestfs.h"
+
+int
+main (int argc, char *argv[])
+{
+  guestfs_h *g;
+  const char *var[] = { "LIBGUESTFS_BACKEND", "LIBGUESTFS_ATTACH_METHOD", NULL };
+  const char *value[] = { "appliance", "direct", NULL };
+  size_t i, j;
+
+  for (i = 0; var[i] != NULL; ++i) {
+    for (j = 0; value[j] != NULL; ++j) {
+      setenv (var[i], value[j], 1);
+
+      g = guestfs_create_flags (GUESTFS_CREATE_NO_ENVIRONMENT);
+      if (!g) {
+        perror ("guestfs_create_flags");
+        exit (EXIT_FAILURE);
+      }
+
+      if (guestfs_parse_environment (g) == -1)
+        exit (EXIT_FAILURE);
+
+      guestfs_close (g);
+
+      unsetenv (var[i]);
+    }
+  }
+
+  exit (EXIT_SUCCESS);
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list