summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorColin Watson <cjwatson@ubuntu.com>2009-06-16 18:09:45 +0100
committerJim Meyering <meyering@redhat.com>2009-06-16 19:32:38 +0200
commite28012ecdbbc509320a287566f998eca4121b243 (patch)
treef821e01362415e8a0bc93e8f49a6c7a41ca0f40e /tests
parentebb2720c5dc4ae50f41b137cf2a2826e4ccbacce (diff)
downloadparted-e28012ecdbbc509320a287566f998eca4121b243.tar.gz
linux-swap: generate UUIDs for fresh swap spaces
* libparted/fs/linux_swap/linux_swap.c: Generate a UUID when creating a fresh swap space. * tests/t2100-mkswap.sh: Test that two fresh swap spaces get different UUIDs, and that 'check' preserves the swap UUID.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/t2100-mkswap.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/t2100-mkswap.sh b/tests/t2100-mkswap.sh
index 420c250..cde1639 100755
--- a/tests/t2100-mkswap.sh
+++ b/tests/t2100-mkswap.sh
@@ -27,6 +27,7 @@ test_description='create linux-swap partitions'
######################################################################
N=1M
dev=loop-file
+dev2=loop-file-2
test_expect_success \
'create a file to simulate the underlying device' \
'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
@@ -52,4 +53,46 @@ test_expect_success \
'od -t x1 -An -j450 -N1 $dev > out && echo " 82" > exp'
test_expect_success 'expect it to be 82, not 83' 'compare out exp'
+test_expect_success \
+ 'create another file to simulate the underlying device' \
+ 'dd if=/dev/null of=$dev2 bs=1 seek=$N 2> /dev/null'
+
+test_expect_success \
+ 'label another test disk' \
+ 'parted -s $dev2 mklabel msdos > out 2>&1'
+test_expect_success 'expect no output' 'compare out /dev/null'
+
+test_expect_success \
+ 'create another partition' \
+ 'parted -s $dev2 mkpart primary 0 1 > out 2>&1'
+test_expect_success 'expect no output' 'compare out /dev/null'
+
+test_expect_success \
+ 'create another linux-swap file system' \
+ 'parted -s $dev2 mkfs 1 "linux-swap(new)" > out 2>&1'
+test_expect_success 'expect no output' 'compare out /dev/null'
+
+# partition starts at offset 16384; swap UUID is 1036 bytes in
+test_expect_success \
+ 'extract UUID 1' \
+ 'od -t x1 -An -j17420 -N16 $dev > uuid1'
+test_expect_success \
+ 'extract UUID 2' \
+ 'od -t x1 -An -j17420 -N16 $dev2 > uuid2'
+test_expect_failure \
+ 'two linux-swap file systems have different UUIDs' \
+ 'compare uuid1 uuid2'
+
+test_expect_success \
+ 'check linux-swap file system' \
+ 'parted -s $dev2 check 1 > out 2>&1'
+test_expect_success 'expect no output' 'compare out /dev/null'
+
+test_expect_success \
+ 'extract new UUID 2' \
+ 'od -t x1 -An -j17420 -N16 $dev2 > uuid2-new'
+test_expect_success \
+ 'check preserves linux-swap UUID' \
+ 'compare uuid2 uuid2-new'
+
test_done