WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xm-test: 10_block_attach_detach_multiple_

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xm-test: 10_block_attach_detach_multiple_devices fixed
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 06 Aug 2009 05:35:13 -0700
Delivery-date: Thu, 06 Aug 2009 05:35:43 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1249475784 -3600
# Node ID 1136d7b74c26a745dfb86f0b61ba7a05d8b47ef8
# Parent  8f2ee72433ccaaa4be35a6d915341c664ec80a12
xm-test: 10_block_attach_detach_multiple_devices fixed

This patch fixes and (re-)enables test 10 of the block-create suite.
The tests by random attach and detach devices to / from a domU and
checks if everything is ok.

Signed-off-by: Andreas Florath <xen@xxxxxxxxxxxx>
---
 tools/xm-test/tests/block-create/10_block_attach_dettach_multiple_devices.py | 
  71 +++++-----
 tools/xm-test/tests/block-create/Makefile.am                                 | 
   1 
 2 files changed, 40 insertions(+), 32 deletions(-)

diff -r 8f2ee72433cc -r 1136d7b74c26 
tools/xm-test/tests/block-create/10_block_attach_dettach_multiple_devices.py
--- 
a/tools/xm-test/tests/block-create/10_block_attach_dettach_multiple_devices.py  
    Wed Aug 05 12:06:24 2009 +0100
+++ 
b/tools/xm-test/tests/block-create/10_block_attach_dettach_multiple_devices.py  
    Wed Aug 05 13:36:24 2009 +0100
@@ -1,40 +1,42 @@
 #!/usr/bin/python
 
 # Copyright (C) International Business Machines Corp., 2005
-# Author: Murillo F. Bernardes <mfb@xxxxxxxxxx>
+# Copyright (C) flonatel GmbH & Co. KG, 2009
+# Authors: Murillo F. Bernardes <mfb@xxxxxxxxxx>
+#          Andreas Florath <xen@xxxxxxxxxxxx>
+
+# Block devices are by random attached to and detached from the domU. 
 
 import re
 import random
 from xen.util import blkif
 
-from os import path.basename
+from os.path import basename
 
 from XmTestLib import *
 from XmTestLib.block_utils import *
 
 def availableRamdisks():
-    i = 0
-    while os.access("/dev/ram%d" % i, os.F_OK ):
-        i += 1
-
-    return i
+    i=0
+    while os.access("/dev/ram%d" % i, os.F_OK):
+        i+=1
+    return i-1
 
 def attach(phy, devname):
     block_attach(domain, "phy:%s" % phy, devname)
     run = console.runCmd("cat /proc/partitions")
     if not re.search(basename(devname), run["output"]):
-        return -2, "Failed to attach block device: /proc/partitions does not 
show that!"
-
+        return -2, "Failed to attach block device: " \
+                   + "/proc/partitions does not show that!"
     return 0, None
 
 
 def detach(devname):
     block_detach(domain, devname)
-
     run = console.runCmd("cat /proc/partitions")
     if re.search(basename(devname), run["output"]):
-        return -2, "Failed to detach block device: /proc/partitions still 
showing that!"
-
+        return -2, "Failed to detach block device: " \
+                   + "/proc/partitions still showing that!"
     return 0, None
     
 if ENABLE_HVM_SUPPORT:
@@ -58,34 +60,39 @@ except ConsoleError, e:
 except ConsoleError, e:
     saveLog(console.getHistory())
     FAIL(str(e))
-    
 
-ramdisks = availableRamdisks()-1
-print "ramdisks=%d" % ramdisks
-i = 0 
-devices = []
+ramdisk_cnt = availableRamdisks()
 
-while i < ramdisks or devices:
-    op = random.randint(0,1) # 1 = attach, 0 = detach
-    if (not devices or op) and i < ramdisks:
-        i += 1
-    devname = "/dev/xvda%d" % i
-    phy = "/dev/ram%d" % i
-    print "Attaching %s to %s" % (devname, phy)
-    status, msg = attach( phy, devname )
+detached = range(0, ramdisk_cnt)
+attached = []
+
+def attach_device():
+    n = random.choice(detached)
+    status, msg = attach("ram%d" % n, "xvda%d" % n)
     if status:
         FAIL(msg)
-    else:
-        devices.append(devname)
+    detached.remove(n)
+    attached.append(n)
 
-    elif devices:
-        devname = random.choice(devices)
-    devices.remove(devname)
-    print "Detaching %s" % devname
-    status, msg = detach(devname)
+def detach_device():
+    n = random.choice(attached)
+    status, msg = detach("xvda%d" % n)
     if status:
         FAIL(msg)
+    detached.append(n)
+    attached.append(n)
 
+# First attach some
+for i in xrange(0, ramdisk_cnt/2):
+    attach_device()
+
+for i in xrange(0, ramdisk_cnt*5):
+    op = random.randint(0,1) # 1 = attach, 0 = detach
+    if op:
+        detach_device()
+    else:
+        attach_device()
+    
 # Close the console
 domain.closeConsole()
 
diff -r 8f2ee72433cc -r 1136d7b74c26 
tools/xm-test/tests/block-create/Makefile.am
--- a/tools/xm-test/tests/block-create/Makefile.am      Wed Aug 05 12:06:24 
2009 +0100
+++ b/tools/xm-test/tests/block-create/Makefile.am      Wed Aug 05 13:36:24 
2009 +0100
@@ -9,6 +9,7 @@ TESTS = 01_block_attach_device_pos.test 
        07_block_attach_baddevice_neg.test \
        08_block_attach_bad_filedevice_neg.test \
        09_block_attach_and_dettach_device_check_data_pos.test \
+       10_block_attach_dettach_multiple_devices.test \
        11_block_attach_shared_dom0.test \
        12_block_attach_shared_domU.test
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xm-test: 10_block_attach_detach_multiple_devices fixed, Xen patchbot-unstable <=