All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add some simple end-to-end tests for btrfs-convert.
@ 2014-05-21 17:20 Adam Buchbinder
  2014-05-28 17:30 ` David Sterba
  2014-05-30 18:26 ` Julien Muchembled
  0 siblings, 2 replies; 4+ messages in thread
From: Adam Buchbinder @ 2014-05-21 17:20 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dave, Adam Buchbinder

These use the system's mke2fs, and don't require loop devices
or root privileges.

They don't pick up anything with the default flags right now,
but they do pick up some sanitizer issues when the tools are
compiled with any of -fsanitize={address,memory,thread}.

Signed-off-by: Adam Buchbinder <abuchbinder@google.com>
---
 Makefile               |  2 +-
 tests/convert-tests.sh | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 tests/convert-tests.sh

diff --git a/Makefile b/Makefile
index da05197..8f002f3 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ libbtrfs_objects = send-stream.o send-utils.o rbtree.o btrfs-list.o crc32c.o \
 libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \
 	       crc32c.h list.h kerncompat.h radix-tree.h extent-cache.h \
 	       extent_io.h ioctl.h ctree.h btrfsck.h
-TESTS = fsck-tests.sh
+TESTS = fsck-tests.sh convert-tests.sh
 
 INSTALL = install
 prefix ?= /usr/local
diff --git a/tests/convert-tests.sh b/tests/convert-tests.sh
new file mode 100644
index 0000000..87369c5
--- /dev/null
+++ b/tests/convert-tests.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+#
+# convert ext2/3/4 images to btrfs images, and make sure the results are
+# clean.
+#
+
+here=`pwd`
+
+_fail()
+{
+	echo "$*" | tee -a convert-tests-results.txt
+	exit 1
+}
+
+rm -f convert-tests-results.txt
+rm -f test.img
+
+test(){
+	echo "     [TEST]    $1"
+        shift
+        echo "creating ext image with: $*" >> convert-tests-results.txt
+	# 256MB is the smallest acceptable btrfs image.
+	dd if=/dev/zero of=$here/test.img bs=1024 count=$((256*1024)) \
+		>> convert-tests-results.txt 2>&1 || _fail "dd failed"
+	$* -F $here/test.img >> convert-tests-results.txt 2>&1 \
+		|| _fail "filesystem create failed"
+	$here/btrfs-convert $here/test.img >> convert-tests-results.txt 2>&1 \
+		|| _fail "btrfs-convert failed"
+	$here/btrfsck $here/test.img >> convert-tests-results.txt 2>&1 \
+		|| _fail "btrfsck detected errors"
+}
+
+test "ext2, 4k blocksize" mke2fs -b 4096
+test "ext3, 4k blocksize" mke2fs -j -b 4096
+test "ext4, 4k blocksize" mke2fs -t ext4 -b 4096
-- 
1.9.1.423.g4596e3a


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add some simple end-to-end tests for btrfs-convert.
  2014-05-21 17:20 [PATCH] Add some simple end-to-end tests for btrfs-convert Adam Buchbinder
@ 2014-05-28 17:30 ` David Sterba
  2014-05-30 18:26 ` Julien Muchembled
  1 sibling, 0 replies; 4+ messages in thread
From: David Sterba @ 2014-05-28 17:30 UTC (permalink / raw)
  To: Adam Buchbinder; +Cc: linux-btrfs

On Wed, May 21, 2014 at 10:20:27AM -0700, Adam Buchbinder wrote:
> These use the system's mke2fs, and don't require loop devices
> or root privileges.

Nice, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add some simple end-to-end tests for btrfs-convert.
  2014-05-21 17:20 [PATCH] Add some simple end-to-end tests for btrfs-convert Adam Buchbinder
  2014-05-28 17:30 ` David Sterba
@ 2014-05-30 18:26 ` Julien Muchembled
  2014-06-12  9:21   ` David Sterba
  1 sibling, 1 reply; 4+ messages in thread
From: Julien Muchembled @ 2014-05-30 18:26 UTC (permalink / raw)
  To: Adam Buchbinder, linux-btrfs; +Cc: dave

Le 05/21/14 19:20, Adam Buchbinder a écrit :
> +	# 256MB is the smallest acceptable btrfs image.
> +	dd if=/dev/zero of=$here/test.img bs=1024 count=$((256*1024)) \
> +		>> convert-tests-results.txt 2>&1 || _fail "dd failed"

What about using a sparse file to speed up the test and be nicer with the underlying storage ?
For example:
  truncate -s 256M $here/test.img

Because this does not reset test.img with zeros, one may want to the
  rm -f test.img
line at the beginning of the test function.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add some simple end-to-end tests for btrfs-convert.
  2014-05-30 18:26 ` Julien Muchembled
@ 2014-06-12  9:21   ` David Sterba
  0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2014-06-12  9:21 UTC (permalink / raw)
  To: Julien Muchembled; +Cc: Adam Buchbinder, linux-btrfs

On Fri, May 30, 2014 at 08:26:02PM +0200, Julien Muchembled wrote:
> Le 05/21/14 19:20, Adam Buchbinder a écrit :
> > +	# 256MB is the smallest acceptable btrfs image.
> > +	dd if=/dev/zero of=$here/test.img bs=1024 count=$((256*1024)) \
> > +		>> convert-tests-results.txt 2>&1 || _fail "dd failed"
> 
> What about using a sparse file to speed up the test and be nicer with the underlying storage ?
> For example:
>   truncate -s 256M $here/test.img
> 
> Because this does not reset test.img with zeros, one may want to the
>   rm -f test.img
> line at the beginning of the test function.

Yes, good idea. Patches welcome. Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-12  9:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-21 17:20 [PATCH] Add some simple end-to-end tests for btrfs-convert Adam Buchbinder
2014-05-28 17:30 ` David Sterba
2014-05-30 18:26 ` Julien Muchembled
2014-06-12  9:21   ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.