[Pkg-libvirt-commits] [libguestfs] 41/87: 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:10:08 UTC 2014


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

bengen pushed a commit to branch debian
in repository libguestfs.

commit bba93e6f18ae895d0e9856890108ea282fa49fd9
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).
    
    (cherry picked from commit ecd31806a491c735878e9e54540a5c11ca1adce9)
---
 .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 cbb5829..ea42d28 100644
--- a/.gitignore
+++ b/.gitignore
@@ -475,6 +475,7 @@ Makefile.in
 /tests/regressions/rhbz501893
 /tests/regressions/rhbz790721
 /tests/regressions/rhbz914931
+/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 1b0fb69..97bc64e 100644
--- a/tests/regressions/Makefile.am
+++ b/tests/regressions/Makefile.am
@@ -34,6 +34,7 @@ TESTS = \
 	rhbz957772.sh \
 	rhbz975797.sh \
 	rhbz1001875.sh \
+	rhbz1055452 \
 	test-noexec-stack.pl
 
 tests_not_run = \
@@ -47,7 +48,8 @@ TESTS_ENVIRONMENT = \
 check_PROGRAMS = \
 	rhbz501893 \
 	rhbz790721 \
-	rhbz914931
+	rhbz914931 \
+	rhbz1055452
 
 rhbz501893_SOURCES = rhbz501893.c
 rhbz501893_CPPFLAGS = \
@@ -79,6 +81,17 @@ rhbz914931_CFLAGS = \
 rhbz914931_LDADD = \
 	$(top_builddir)/src/libguestfs.la
 
+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