Received: from [140.186.70.92] (port=59084 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pt6jE-0006ZC-6R for qemu-devel@nongnu.org; Fri, 25 Feb 2011 18:06:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pt6ih-0007U9-QM for qemu-devel@nongnu.org; Fri, 25 Feb 2011 18:05:12 -0500 Received: from e4.ny.us.ibm.com ([32.97.182.144]:54439) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pt6ih-0007U0-Lo for qemu-devel@nongnu.org; Fri, 25 Feb 2011 18:05:07 -0500 Received: from d01dlp01.pok.ibm.com (d01dlp01.pok.ibm.com [9.56.224.56]) by e4.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p1PMSsxK006682 for ; Fri, 25 Feb 2011 17:28:56 -0500 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 69AF038C8036 for ; Fri, 25 Feb 2011 17:47:53 -0500 (EST) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p1PMlqll2724024 for ; Fri, 25 Feb 2011 17:47:52 -0500 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p1PMlqig020733 for ; Fri, 25 Feb 2011 19:47:52 -0300 From: Chunqiang Tang Date: Fri, 25 Feb 2011 17:37:44 -0500 Message-Id: <1298673486-3573-4-git-send-email-ctang@us.ibm.com> In-Reply-To: <1298673486-3573-1-git-send-email-ctang@us.ibm.com> References: <1298673486-3573-1-git-send-email-ctang@us.ibm.com> Subject: [Qemu-devel] [PATCH 04/26] FVD: add fully automated test-vdi.sh List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Chunqiang Tang This patch is part of the Fast Virtual Disk (FVD) proposal. See http://wiki.qemu.org/Features/FVD. test-vdi.sh drives 'qemu-io --auto' to perform fully automated testing for VDI. Signed-off-by: Chunqiang Tang --- test-vdi.sh | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 83 insertions(+), 0 deletions(-) create mode 100755 test-vdi.sh diff --git a/test-vdi.sh b/test-vdi.sh new file mode 100755 index 0000000..b0bfe65 --- /dev/null +++ b/test-vdi.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +# Drive 'qemu-io --auto' to test the VDI image format. +# +# Copyright IBM, Corp. 2010 +# +# Authors: +# Chunqiang Tang +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING.LIB file in the top-level directory. + +if [ $USER != "root" ]; then + echo "This command must be run by root in order to mount tmpfs." + exit 1 +fi + +QEMU_DIR=. +QEMU_IMG=$QEMU_DIR/qemu-img +QEMU_IO=$QEMU_DIR/qemu-io + +if [ ! -e $QEMU_IMG ]; then + echo "$QEMU_IMG does not exist." + exit 1; +fi + +if [ ! -e $QEMU_IO ]; then + echo "$QEMU_IO does not exist." + exit 1; +fi + +DATA_DIR=/var/ramdisk +TRUTH_IMG=$DATA_DIR/truth.raw +TEST_IMG=$DATA_DIR/test.vdi +CMD_LOG=./test-vdi.log + +parallel=10 +round=1000 +fail_prob=0.1 +cancel_prob=0 +flush_prob=0 +aio_flush_prob=0 +instant_qemubh=true +seed=$RANDOM$RANDOM +count=0 + +function invoke() { + echo "$*" >> $CMD_LOG + $* + ret=$? + if [ $? -ne 0 ]; then + echo "Exit with error code $?: $*" + exit $ret + fi +} + +mount | grep $DATA_DIR > /dev/null +if [ $? -ne 0 ]; then + echo "Create tmpfs at $DATA_DIR to store testing images." + if [ ! -e $DATA_DIR ]; then mkdir -p $DATA_DIR ; fi + invoke "mount -t tmpfs none $DATA_DIR -o size=400M" + if [ $? -ne 0 ]; then exit 1; fi +fi + +/bin/rm -f $CMD_LOG +touch $CMD_LOG + +while [ -t ]; do +for io_size in 3145728; do + count=$[$count + 1] + echo "Round $count" >> $CMD_LOG + + # VDI image is about 100M + img_size=$[(104857600 + ($RANDOM$RANDOM$RANDOM % 10485760)) / 512 * 512] + + invoke "/bin/rm -rf $TRUTH_IMG $TEST_IMG" + invoke "dd if=/dev/zero of=$TRUTH_IMG count=0 bs=1 seek=$img_size" + invoke "$QEMU_IMG create -f vdi $TEST_IMG $img_size" + + invoke "$QEMU_IO --auto --seed=$seed --truth=$TRUTH_IMG --format=vdi --test="blksim:$TEST_IMG" --verify_write=true --compare_before=false --compare_after=true --round=$round --parallel=$parallel --io_size=$io_size --fail_prob=$fail_prob --cancel_prob=$cancel_prob --aio_flush_prob=$aio_flush_prob --flush_prob=$flush_prob --instant_qemubh=$instant_qemubh" + + seed=$[$seed + 1] +done; done -- 1.7.0.4