[Pkg-libvirt-commits] [SCM] Libguestfs Debian packaging branch, experimental, updated. debian/1%1.21.40-1

Richard W.M. Jones rjones at redhat.com
Sat Jun 1 11:04:28 UTC 2013


The following commit has been merged in the experimental branch:
commit f003c50c520f9515f433b0043a69ebd5154060ed
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Wed May 1 09:34:39 2013 +0100

    tests/c-api: Remove global guestfs handle.
    
    This will allow us to parallelize these tests.

diff --git a/generator/tests_c_api.ml b/generator/tests_c_api.ml
index faf4cd7..371ee70 100644
--- a/generator/tests_c_api.ml
+++ b/generator/tests_c_api.ml
@@ -102,7 +102,7 @@ let rec generate_tests () =
 
   pr "\
 size_t
-perform_tests (void)
+perform_tests (guestfs_h *g)
 {
   size_t test_num = 0;
   size_t nr_failed = 0;
@@ -113,7 +113,7 @@ perform_tests (void)
     fun i test_name ->
       pr "  test_num++;\n";
       pr "  next_test (g, test_num, nr_tests, \"%s\");\n" test_name;
-      pr "  if (%s () == -1) {\n" test_name;
+      pr "  if (%s (g) == -1) {\n" test_name;
       pr "    printf (\"FAIL: %%s\\n\", \"%s\");\n" test_name;
       pr "    nr_failed++;\n";
       pr "  }\n";
@@ -148,7 +148,7 @@ static int
 
   pr "\
 static int
-%s (void)
+%s (guestfs_h *g)
 {
   if (%s_skip ()) {
     skipped (\"%s\", \"environment variable set\");
@@ -195,28 +195,28 @@ static int
 and generate_one_test_body name i test_name init test =
   (match init with
    | InitNone ->
-     pr "  if (init_none () == -1)\n";
+     pr "  if (init_none (g) == -1)\n";
      pr "    return -1;\n"
    | InitEmpty ->
-     pr "  if (init_empty () == -1)\n";
+     pr "  if (init_empty (g) == -1)\n";
      pr "    return -1;\n"
    | InitPartition ->
-     pr "  if (init_partition () == -1)\n";
+     pr "  if (init_partition (g) == -1)\n";
      pr "    return -1;\n"
    | InitGPT ->
-     pr "  if (init_gpt () == -1)\n";
+     pr "  if (init_gpt (g) == -1)\n";
      pr "    return -1;\n"
    | InitBasicFS ->
-     pr "  if (init_basic_fs () == -1)\n";
+     pr "  if (init_basic_fs (g) == -1)\n";
      pr "    return -1;\n"
    | InitBasicFSonLVM ->
-     pr "  if (init_basic_fs_on_lvm () == -1)\n";
+     pr "  if (init_basic_fs_on_lvm (g) == -1)\n";
      pr "    return -1;\n"
    | InitISOFS ->
-     pr "  if (init_iso_fs () == -1)\n";
+     pr "  if (init_iso_fs (g) == -1)\n";
      pr "    return -1;\n"
    | InitScratchFS ->
-     pr "  if (init_scratch_fs () == -1)\n";
+     pr "  if (init_scratch_fs (g) == -1)\n";
      pr "    return -1;\n"
   );
 
diff --git a/tests/c-api/tests-main.c b/tests/c-api/tests-main.c
index 984fa0b..69d567e 100644
--- a/tests/c-api/tests-main.c
+++ b/tests/c-api/tests-main.c
@@ -38,21 +38,19 @@
 
 #include "tests.h"
 
-guestfs_h *g;
-
 int
-init_none (void)
+init_none (guestfs_h *g)
 {
   /* XXX At some point in the distant past, InitNone and InitEmpty
    * became folded together as the same thing.  Really we should make
    * InitNone do nothing at all, but the tests may need to be checked
    * to make sure this is OK.
    */
-  return init_empty ();
+  return init_empty (g);
 }
 
 int
-init_empty (void)
+init_empty (guestfs_h *g)
 {
   if (guestfs_blockdev_setrw (g, "/dev/sda") == -1)
     return -1;
@@ -67,9 +65,9 @@ init_empty (void)
 }
 
 int
-init_partition (void)
+init_partition (guestfs_h *g)
 {
-  if (init_empty () == -1)
+  if (init_empty (g) == -1)
     return -1;
 
   if (guestfs_part_disk (g, "/dev/sda", "mbr") == -1)
@@ -79,9 +77,9 @@ init_partition (void)
 }
 
 int
-init_gpt (void)
+init_gpt (guestfs_h *g)
 {
-  if (init_empty () == -1)
+  if (init_empty (g) == -1)
     return -1;
 
   if (guestfs_part_disk (g, "/dev/sda", "gpt") == -1)
@@ -91,9 +89,9 @@ init_gpt (void)
 }
 
 int
-init_basic_fs (void)
+init_basic_fs (guestfs_h *g)
 {
-  if (init_partition () == -1)
+  if (init_partition (g) == -1)
     return -1;
 
   if (guestfs_mkfs (g, "ext2", "/dev/sda1") == -1)
@@ -106,11 +104,11 @@ init_basic_fs (void)
 }
 
 int
-init_basic_fs_on_lvm (void)
+init_basic_fs_on_lvm (guestfs_h *g)
 {
   const char *pvs[] = { "/dev/sda1", NULL };
 
-  if (init_partition () == -1)
+  if (init_partition (g) == -1)
     return -1;
 
   if (guestfs_pvcreate (g, "/dev/sda1") == -1)
@@ -132,9 +130,9 @@ init_basic_fs_on_lvm (void)
 }
 
 int
-init_iso_fs (void)
+init_iso_fs (guestfs_h *g)
 {
-  if (init_empty () == -1)
+  if (init_empty (g) == -1)
     return -1;
 
   if (guestfs_mount_ro (g, "/dev/sdd", "/") == -1)
@@ -144,9 +142,9 @@ init_iso_fs (void)
 }
 
 int
-init_scratch_fs (void)
+init_scratch_fs (guestfs_h *g)
 {
-  if (init_empty () == -1)
+  if (init_empty (g) == -1)
     return -1;
 
   if (guestfs_mount (g, "/dev/sdb1", "/") == -1)
@@ -427,6 +425,7 @@ main (int argc, char *argv[])
   int fd;
   size_t nr_failed ;
   int close_sentinel = 1;
+  guestfs_h *g;
 
   setbuf (stdout, NULL);
 
@@ -530,7 +529,7 @@ main (int argc, char *argv[])
     exit (EXIT_FAILURE);
   }
 
-  nr_failed = perform_tests ();
+  nr_failed = perform_tests (g);
 
   /* Check close callback is called. */
   guestfs_set_event_callback (g, incr, GUESTFS_EVENT_CLOSE, 0, &close_sentinel);
diff --git a/tests/c-api/tests.h b/tests/c-api/tests.h
index aa3b1d6..1226790 100644
--- a/tests/c-api/tests.h
+++ b/tests/c-api/tests.h
@@ -19,18 +19,17 @@
 #ifndef TESTS_H_
 #define TESTS_H_
 
-extern guestfs_h *g;
 extern size_t nr_tests;
 
-extern int init_none (void);
-extern int init_empty (void);
-extern int init_partition (void);
-extern int init_gpt (void);
-extern int init_basic_fs (void);
-extern int init_basic_fs_on_lvm (void);
-extern int init_iso_fs (void);
-extern int init_scratch_fs (void);
-extern size_t perform_tests (void);
+extern int init_none (guestfs_h *g);
+extern int init_empty (guestfs_h *g);
+extern int init_partition (guestfs_h *g);
+extern int init_gpt (guestfs_h *g);
+extern int init_basic_fs (guestfs_h *g);
+extern int init_basic_fs_on_lvm (guestfs_h *g);
+extern int init_iso_fs (guestfs_h *g);
+extern int init_scratch_fs (guestfs_h *g);
+extern size_t perform_tests (guestfs_h *g);
 extern void no_test_warnings (void);
 extern int is_string_list (char **ret, size_t n, ...);
 extern int is_device_list (char **ret, size_t n, ...);

-- 
Libguestfs Debian packaging



More information about the Pkg-libvirt-commits mailing list