render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
9119d9
From 1dee234295fb074de471990fb700c8255a03c263 Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <1dee234295fb074de471990fb700c8255a03c263@dist-git>
9119d9
From: Peter Krempa <pkrempa@redhat.com>
9119d9
Date: Fri, 21 Nov 2014 15:04:04 +0100
9119d9
Subject: [PATCH] test: virstoragetest: Add testing of network disk details
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1164528
9119d9
9119d9
To be able to fully test parsing of networked storage strings we need to
9119d9
add a few fields for: hostname, protocol and auth string.
9119d9
9119d9
(cherry picked from commit e650f30b93cb7318406fb0b88a621d8898289800)
9119d9
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 tests/virstoragetest.c | 22 +++++++++++++++++++---
9119d9
 1 file changed, 19 insertions(+), 3 deletions(-)
9119d9
9119d9
diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
9119d9
index 05e48f3..ee6f576 100644
9119d9
--- a/tests/virstoragetest.c
9119d9
+++ b/tests/virstoragetest.c
9119d9
@@ -279,6 +279,9 @@ struct _testFileData
9119d9
     const char *path;
9119d9
     int type;
9119d9
     int format;
9119d9
+    const char *secret;
9119d9
+    const char *hostname;
9119d9
+    int protocol;
9119d9
 };
9119d9
 
9119d9
 enum {
9119d9
@@ -306,7 +309,10 @@ static const char testStorageChainFormat[] =
9119d9
     "encryption: %d\n"
9119d9
     "relPath:%s\n"
9119d9
     "type:%d\n"
9119d9
-    "format:%d\n";
9119d9
+    "format:%d\n"
9119d9
+    "protocol:%s\n"
9119d9
+    "hostname:%s\n"
9119d9
+    "secret:%s\n";
9119d9
 
9119d9
 static int
9119d9
 testStorageChain(const void *args)
9119d9
@@ -369,7 +375,10 @@ testStorageChain(const void *args)
9119d9
                         data->files[i]->expEncrypted,
9119d9
                         NULLSTR(data->files[i]->pathRel),
9119d9
                         data->files[i]->type,
9119d9
-                        data->files[i]->format) < 0 ||
9119d9
+                        data->files[i]->format,
9119d9
+                        virStorageNetProtocolTypeToString(data->files[i]->protocol),
9119d9
+                        NULLSTR(data->files[i]->hostname),
9119d9
+                        NULLSTR(data->files[i]->secret)) < 0 ||
9119d9
             virAsprintf(&actual,
9119d9
                         testStorageChainFormat, i,
9119d9
                         NULLSTR(elt->path),
9119d9
@@ -378,7 +387,10 @@ testStorageChain(const void *args)
9119d9
                         !!elt->encryption,
9119d9
                         NULLSTR(elt->relPath),
9119d9
                         elt->type,
9119d9
-                        elt->format) < 0) {
9119d9
+                        elt->format,
9119d9
+                        virStorageNetProtocolTypeToString(elt->protocol),
9119d9
+                        NULLSTR(elt->nhosts ? elt->hosts[0].name : NULL),
9119d9
+                        NULLSTR(elt->auth ? elt->auth->username : NULL)) < 0) {
9119d9
             VIR_FREE(expect);
9119d9
             VIR_FREE(actual);
9119d9
             goto cleanup;
9119d9
@@ -830,6 +842,8 @@ mymain(void)
9119d9
         .path = "blah",
9119d9
         .type = VIR_STORAGE_TYPE_NETWORK,
9119d9
         .format = VIR_STORAGE_FILE_RAW,
9119d9
+        .protocol = VIR_STORAGE_NET_PROTOCOL_NBD,
9119d9
+        .hostname = "example.org",
9119d9
     };
9119d9
     TEST_CHAIN(11, absqcow2, VIR_STORAGE_FILE_QCOW2,
9119d9
                (&qcow2, &nbd), EXP_PASS,
9119d9
@@ -849,6 +863,8 @@ mymain(void)
9119d9
         .path = "blah",
9119d9
         .type = VIR_STORAGE_TYPE_NETWORK,
9119d9
         .format = VIR_STORAGE_FILE_RAW,
9119d9
+        .protocol = VIR_STORAGE_NET_PROTOCOL_NBD,
9119d9
+        .hostname = "example.org",
9119d9
     };
9119d9
     TEST_CHAIN(12, absqcow2, VIR_STORAGE_FILE_QCOW2,
9119d9
                (&qcow2, &nbd2), EXP_PASS,
9119d9
-- 
9119d9
2.1.3
9119d9