From: Amos Kong <akong@redhat.com>
To: autotest@test.kernel.org, lmr@redhat.com, kvm@vger.kernel.org
Subject: [PATCH] KVM-test: Add new subtest: floppy
Date: Fri, 29 Jul 2011 09:59:13 +0800 [thread overview]
Message-ID: <20110729015913.8949.49367.stgit@t> (raw)
This test does some basic operation on the virtual floppy,
it supports both Linux and Windows guests.
Signed-off-by: Amos Kong <akong@redhat.com>
---
client/tests/kvm/tests/floppy.py | 62 ++++++++++++++++++++++++++++++++
client/tests/kvm/tests_base.cfg.sample | 23 ++++++++++++
2 files changed, 85 insertions(+), 0 deletions(-)
create mode 100644 client/tests/kvm/tests/floppy.py
diff --git a/client/tests/kvm/tests/floppy.py b/client/tests/kvm/tests/floppy.py
new file mode 100644
index 0000000..ee84df7
--- /dev/null
+++ b/client/tests/kvm/tests/floppy.py
@@ -0,0 +1,62 @@
+import logging, time
+from autotest_lib.client.common_lib import error
+
+
+@error.context_aware
+def run_floppy(test, params, env):
+ """
+ Test virtual floppy of guest:
+
+ 1)Create a floppy disk image on host
+ 2)start the guest with this floppy image.
+ 3)make a file system on guest virtual floppy
+ 4)calculate md5sum value of a file and copy it into floppy.
+ 5)verify whether the md5sum is match
+
+ @param test: kvm test object
+ @param params: Dictionary with the test parameters
+ @param env: Dictionary with test environment.
+ """
+ vm = env.get_vm(params["main_vm"])
+ vm.create()
+ timeout = int(params.get("login_timeout", 360))
+ session = vm.wait_for_login(timeout=timeout)
+
+ dest_dir = params.get("mount_dir")
+ # If mount_dir specified, treat guest as a Linux OS
+ # Some Linux distribution does not load floppy at boot and Windows
+ # needs time to load and init floppy driver
+ if dest_dir:
+ status = session.cmd("modprobe floppy")
+ else:
+ time.sleep(20)
+
+ error.context("Formating floppy disk before using it")
+ format_cmd = params.get("format_floppy_cmd")
+ session.cmd(format_cmd, timeout=120)
+ logging.info("Floppy disk formatted successfully")
+
+ source_file = params.get("source_file")
+ dest_file = params.get("dest_file")
+
+ if dest_dir:
+ error.context("Mounting floppy")
+ session.cmd("mount /dev/fd0 %s" % dest_dir)
+ error.context("Testing floppy")
+ session.cmd(params.get("test_floppy_cmd"))
+
+ try:
+ error.context("Copying file to the floppy")
+ session.cmd("%s %s %s" % (params.get("copy_cmd"), source_file,
+ dest_file))
+ logging.info("Succeed to copy file '%s' into floppy disk" % source_file)
+
+ error.context("Checking if the file is unchanged after copy")
+ session.cmd("%s %s %s" % (params.get("diff_file_cmd"), source_file,
+ dest_file))
+ finally:
+ clean_cmd = "%s %s" % (params.get("clean_cmd"), dest_file)
+ session.cmd(clean_cmd)
+ if dest_dir:
+ session.cmd("umount %s" % dest_dir)
+ session.close()
diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
index d597b52..8a816c6 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -1115,6 +1115,11 @@ variants:
image_snapshot = yes
only Linux
+ - floppy: install setup image_copy unattended_install.cdrom
+ type = floppy
+ floppy = "images/test_floppy.img"
+ pre_cmd = "dd if=/dev/zero of=images/test_floppy.img bs=512 count=2880"
+
# NICs
variants:
@@ -1221,6 +1226,16 @@ variants:
image_name_stg27 = storage27
list_volume_command = cd /dev && \ls vd*
re_str = "[vhs]d[a-z][^0-9]"
+ floppy:
+ format_floppy_cmd = mkfs -t ext3 /dev/fd0
+ test_floppy_cmd = (dd if=/dev/urandom of=/mnt/test_floppy bs=1M count=1) && (rm -f /mnt/test_floppy)
+ format_floppy_cmd = mkfs -t ext3 /dev/fd0
+ source_file = /etc/passwd
+ dest_file = /mnt/passwd
+ clean_cmd = rm -f
+ mount_dir = /mnt/
+ diff_file_cmd = diff
+ copy_cmd = cp
variants:
- CustomGuestLinux:
@@ -2232,6 +2247,14 @@ variants:
pre_cmd = del diskpart.script && (echo select disk 1 >> diskpart.script && echo create partition primary >> diskpart.script && echo assign >> diskpart.script) && echo select disk 0 >> diskpart.script && echo exit >> diskpart.script && diskpart /s diskpart.script
max_disk:
pre_cmd = del diskpart.script && (for /L %i in (1 1 23) do echo select disk %i >> diskpart.script && echo create partition primary >> diskpart.script && echo assign >> diskpart.script) && echo select disk 0 >> diskpart.script && echo exit >> diskpart.script && diskpart /s diskpart.script
+ floppy:
+ format_floppy_cmd = echo n|format A: /Q /V:test_floppy
+ source_file = C:\Windows\System32\cmd.exe
+ dest_file = A:\cmd.exe
+ clean_cmd = del
+ diff_file_cmd = fc
+ test_floppy_cmd = "chkdsk A:"
+ copy_cmd = copy
variants:
- CustomGuestWindows:
next reply other threads:[~2011-07-29 1:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-29 1:59 Amos Kong [this message]
2011-08-02 22:22 ` [Autotest] [PATCH] KVM-test: Add new subtest: floppy Lucas Meneghel Rodrigues
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110729015913.8949.49367.stgit@t \
--to=akong@redhat.com \
--cc=autotest@test.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=lmr@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox