public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] KVM test: Image copy test v2
@ 2010-12-29 14:35 Lucas Meneghel Rodrigues
  2010-12-29 14:35 ` [PATCH 1/2] KVM-test: Add mount utility functions Lucas Meneghel Rodrigues
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-12-29 14:35 UTC (permalink / raw)
  To: autotest; +Cc: kvm, Lucas Meneghel Rodrigues

This is a respin of Amos's patch for image_copy test. In this
version, small cleanups and consistency fixes were made, specially
with regards to using utils.system instead of functions on the
commands API.

Amos Kong (2):
  KVM-test: Add mount utility functions
  KVM-test: Add image_copy subtest to prepare images

 client/tests/kvm/kvm_utils.py          |   55 ++++++++++++++++++++++++++++++++
 client/tests/kvm/tests/image_copy.py   |   46 ++++++++++++++++++++++++++
 client/tests/kvm/tests_base.cfg.sample |    9 +++++
 3 files changed, 110 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/tests/image_copy.py

-- 
1.7.2.3


^ permalink raw reply	[flat|nested] 5+ messages in thread
* [PATCH 1/2] KVM-test: Add mount utility functions
@ 2010-12-22 13:27 Amos Kong
  0 siblings, 0 replies; 5+ messages in thread
From: Amos Kong @ 2010-12-22 13:27 UTC (permalink / raw)
  To: autotest; +Cc: kvm

Add mount and umount function, you can assign source, mount_point, type
and permission.

Signed-off-by: Amos Kong <akong@redhat.com>
---
 client/tests/kvm/kvm_utils.py |   55 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index 5496e06..175b128 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -1456,3 +1456,58 @@ class KojiDownloader(object):
                 rpm_paths.append(r)
 
         return rpm_paths
+
+def umount(src, mount_point, type):
+    """
+    Umount the src mounted in mount_point.
+
+    @src: mount source
+    @mount_point: mount point
+    @type: file system type
+    """
+
+    mount_string = "%s %s %s" % (src, mount_point, type)
+    if mount_string in file("/etc/mtab").read():
+        umount_cmd = "umount %s" % mount_point
+        s, o = commands.getstatusoutput(umount_cmd)
+        if s != 0:
+            logging.error("Fail to umount: %s" % o)
+            return False
+        else:
+            return True
+    else:
+        logging.debug("%s is not mount in %s" % (src, mount_point))
+        return True
+
+def mount(src, mount_point, type, perm="rw"):
+    """
+    Mount the src into mount_point of the host.
+
+    @src: mount source
+    @mount_point: mount point
+    @type: file system type
+    @perm: mount premission
+    """
+    umount(src, mount_point, type)
+    mount_string = "%s %s %s %s" % (src, mount_point, type, perm)
+
+    if mount_string in file("/etc/mtab").read():
+        logging.debug("%s is already mounted in %s with %s" % \
+                      (src, mount_point, perm))
+        return True
+
+    mount_cmd = "mount -t %s %s %s -o %s" % (type, src, mount_point, perm)
+    logging.debug(mount_cmd)
+    s, o = commands.getstatusoutput(mount_cmd)
+    if s != 0:
+        logging.error("Fail to mount: %s " % o)
+        return False
+
+    logging.debug("Verify the mount through /etc/mtab")
+    if mount_string in file("/etc/mtab").read():
+        logging.debug("%s is successfully mounted" % src)
+        return True
+    else:
+        logging.error("Mounting verification failed: %s" % \
+                      file("/etc/mtab").read())
+        return False

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-12-29 15:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-29 14:35 [PATCH 0/2] KVM test: Image copy test v2 Lucas Meneghel Rodrigues
2010-12-29 14:35 ` [PATCH 1/2] KVM-test: Add mount utility functions Lucas Meneghel Rodrigues
2010-12-29 14:35 ` [PATCH 2/2] KVM-test: Add image_copy subtest to prepare images Lucas Meneghel Rodrigues
2010-12-29 15:24 ` [PATCH 0/2] KVM test: Image copy test v2 Lucas Meneghel Rodrigues
  -- strict thread matches above, loose matches on Subject: below --
2010-12-22 13:27 [PATCH 1/2] KVM-test: Add mount utility functions Amos Kong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox