Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LrwFm-0005UO-2b for qemu-devel@nongnu.org; Thu, 09 Apr 2009 11:33:22 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LrwFh-0005RL-E4 for qemu-devel@nongnu.org; Thu, 09 Apr 2009 11:33:21 -0400 Received: from [199.232.76.173] (port=54044 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LrwFh-0005R7-9o for qemu-devel@nongnu.org; Thu, 09 Apr 2009 11:33:17 -0400 Received: from verein.lst.de ([213.95.11.210]:58612) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1LrwFf-0000TX-SC for qemu-devel@nongnu.org; Thu, 09 Apr 2009 11:33:16 -0400 Date: Thu, 9 Apr 2009 17:33:14 +0200 From: Christoph Hellwig Subject: Re: [Qemu-devel] [PATCH] qemu-io: Verify read data by patterns Message-ID: <20090409153314.GB22492@lst.de> References: <1239284776-2115-1-git-send-email-kwolf@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1239284776-2115-1-git-send-email-kwolf@redhat.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf On Thu, Apr 09, 2009 at 03:46:16PM +0200, Kevin Wolf wrote: > This patch adds a -P option to read and readv which allows to compare the read > data to a given pattern. This can be used to verify data written by write -P. Very good, I was doing this manually in my WIP testsuite, but having qemu-io do this is even better. > " -q, -- quite mode, do not show I/O statistics\n" > @@ -207,8 +208,10 @@ read_f(int argc, char **argv) > char *buf; > int64_t offset; > int count, total; > + int pattern = 0; > + int use_pattern = 0; > > - while ((c = getopt(argc, argv, "Cpqv")) != EOF) { > + while ((c = getopt(argc, argv, "CpP:qv")) != EOF) { > switch (c) { > case 'C': > Cflag = 1; > @@ -216,6 +219,10 @@ read_f(int argc, char **argv) > case 'p': > pflag = 1; > break; > + case 'P': > + use_pattern = 1; Following the conventions this variable would be called Pflag, but I'm not dead set on this. (The conventions come from the original xfs_io tool) > + if (use_pattern) { > + void* cmp_buf = malloc(count); > + memset(cmp_buf, pattern, count); > + if (memcmp(buf, cmp_buf, count)) { > + printf("Pattern verification failed at offset %lld, %d bytes\n", > + (long long) offset, count); > + } Can we keep the line shorter than 80 characters?