From patchwork Fri Jul 29 01:59:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 1018802 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6T1tg2O006771 for ; Fri, 29 Jul 2011 01:55:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756338Ab1G2Bzj (ORCPT ); Thu, 28 Jul 2011 21:55:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33002 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756228Ab1G2Bzj (ORCPT ); Thu, 28 Jul 2011 21:55:39 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6T1tb4Q030168 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 28 Jul 2011 21:55:37 -0400 Received: from [127.0.0.1] (dhcp-8-167.nay.redhat.com [10.66.8.167]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p6T1tZ5a017806; Thu, 28 Jul 2011 21:55:36 -0400 Subject: [PATCH] KVM-test: Add new subtest: floppy To: autotest@test.kernel.org, lmr@redhat.com, kvm@vger.kernel.org From: Amos Kong Date: Fri, 29 Jul 2011 09:59:13 +0800 Message-ID: <20110729015913.8949.49367.stgit@t> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 29 Jul 2011 01:56:33 +0000 (UTC) This test does some basic operation on the virtual floppy, it supports both Linux and Windows guests. Signed-off-by: Amos Kong --- 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 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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: