Skip to contentSkip to conversation

- fix swap sanity tests in blkid, and blkid tests

PATCH In review Eric Sandeen 2 participants 3 messages May 12, 2008 – May 13, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 - fix swap sanity tests in blkid, and blkid tests

Swap is actually native-endian on disk, and with the latest swapspace sanity checks I added we need to have native swapspace examples in the blkid tests, so re-mkswap them during testing.

One one other required change, though; mkswap requires at least 10 pages of swap, so the image needs to be increased to 10x64k if mkswap is to succeed...

Maybe it'd be better to just dd it out on the fly?

Addresses-redhat-bugzilla: 445786

---

lib/blkid/probe.c +1 -2
Index: e2fsprogs-1.41/lib/blkid/probe.c
===================================================================
@@ -845,8 +845,7 @@ static int probe_swap1(struct blkid_prob
 
 	/* check for wrong version or zeroed pagecount, for sanity */
 	if (!memcmp(id->bim_magic, "SWAPSPACE2", id->bim_len) &&
-			(blkid_le32(sws->sws_version) != 1 ||
-			 sws->sws_lastpage == 0))
+			(sws->sws_version != 1 || sws->sws_lastpage == 0))
 		return 1;
 
 	/* arbitrary sanity check.. is there any garbage down there? */
lib/blkid/test_probe.in +6 -0
Index: e2fsprogs-1.41/lib/blkid/test_probe.in
===================================================================
@@ -20,6 +20,12 @@ do
 		continue
 	fi
 	bunzip2 < $SRCDIR/tests/$i.img.bz2 > tests/tmp/test.img.$$
+	# swap is native-endian, so regenerate before testing
+	if [ "$i" == "swap0" ]; then
+		mkswap -v0 tests/tmp/test.img.$$ > /dev/null
+	elif [ "$i" == "swap1" ]; then
+		mkswap -v1 -L SWAP-TEST -U 8ff8e77f-8553-485e-8656-58be67a81666 tests/tmp/test.img.$$ >/dev/null
+	fi
 	./tst_probe tests/tmp/test.img.$$ > tests/$i.out
 	/bin/rm -f tests/tmp/test.img.$$ tests/$i.ok tests/$i.failed
 	cmp -s tests/$i.out $SRCDIR/tests/$i.results
#1 lore raw
Quoted 5 lines · Eric Sandeen

One one other required change, though; mkswap requires at least 10 pages of swap, so the image needs to be increased to 10x64k if mkswap is to succeed...

Maybe it'd be better to just dd it out on the fly?

Probably, yes. Little point in bunzipping bytes that you are just going to overwrite...

lib/blkid/test_probe.in do · line 28

Quoted 7 lines
lib/blkid/test_probe.in +6 -0
 	bunzip2 < $SRCDIR/tests/$i.img.bz2 > tests/tmp/test.img.$$
+	# swap is native-endian, so regenerate before testing
+	if [ "$i" == "swap0" ]; then
+		mkswap -v0 tests/tmp/test.img.$$ > /dev/null
+	elif [ "$i" == "swap1" ]; then
+		mkswap -v1 -L SWAP-TEST -U 8ff8e77f-8553-485e-8656-58be67a81666 tests/tmp/test.img.$$ >/dev/null
+	fi

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#2 lore raw
Quoted 9 lines · Andreas Dilger
Quoted 5 lines · Eric Sandeen

One one other required change, though; mkswap requires at least 10 pages of swap, so the image needs to be increased to 10x64k if mkswap is to succeed...

Maybe it'd be better to just dd it out on the fly?

Probably, yes. Little point in bunzipping bytes that you are just going to overwrite...

It's just that right now it iterates over existing files, so that's how it finds swap0 and swap1 to test...

*shrug*

Could make them bzipped sparse files... :)

Quoted 14 lines

lib/blkid/test_probe.in do · line 28

Quoted 7 lines
lib/blkid/test_probe.in +6 -0
 	bunzip2 < $SRCDIR/tests/$i.img.bz2 > tests/tmp/test.img.$$
+	# swap is native-endian, so regenerate before testing
+	if [ "$i" == "swap0" ]; then
+		mkswap -v0 tests/tmp/test.img.$$ > /dev/null
+	elif [ "$i" == "swap1" ]; then
+		mkswap -v1 -L SWAP-TEST -U 8ff8e77f-8553-485e-8656-58be67a81666 tests/tmp/test.img.$$ >/dev/null
+	fi

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.