3
# Copyright (C) 2007, 2009 Free Software Foundation, Inc.
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
test_description='create linux-swap partitions'
23
require_512_byte_sector_size_
25
######################################################################
26
# When creating a partition of type linux-swap(v1) in a DOS partition
27
# table, ensure that the proper file system type (0x82) is used.
28
# Some releases, e.g. parted-1.8.8 would mistakenly use 0x83.
29
######################################################################
34
'create a file to simulate the underlying device' \
35
'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
38
'label the test disk' \
39
'parted -s $dev mklabel msdos > out 2>&1'
40
test_expect_success 'expect no output' 'compare out /dev/null'
43
'create a partition' \
44
'parted -s $dev mkpart primary 0 1 > out 2>&1'
45
test_expect_success 'expect no output' 'compare out /dev/null'
48
'create a linux-swap file system' \
49
'parted -s $dev mkfs 1 "linux-swap(v1)" > out 2>&1'
50
test_expect_success 'expect no output' 'compare out /dev/null'
52
# Extract the byte at offset 451. It must be 0x82, not 0x83.
54
'extract byte 451 (fs-type)' \
55
'od -t x1 -An -j450 -N1 $dev > out && echo " 82" > exp'
56
test_expect_success 'expect it to be 82, not 83' 'compare out exp'
59
'create another file to simulate the underlying device' \
60
'dd if=/dev/null of=$dev2 bs=1 seek=$N 2> /dev/null'
63
'label another test disk' \
64
'parted -s $dev2 mklabel msdos > out 2>&1'
65
test_expect_success 'expect no output' 'compare out /dev/null'
68
'create another partition' \
69
'parted -s $dev2 mkpart primary 0 1 > out 2>&1'
70
test_expect_success 'expect no output' 'compare out /dev/null'
73
'create another linux-swap file system' \
74
'parted -s $dev2 mkfs 1 "linux-swap(v1)" > out 2>&1'
75
test_expect_success 'expect no output' 'compare out /dev/null'
77
# partition starts at offset 16384; swap UUID is 1036 bytes in
80
'od -t x1 -An -j17420 -N16 $dev > uuid1'
83
'od -t x1 -An -j17420 -N16 $dev2 > uuid2'
85
'two linux-swap file systems have different UUIDs' \
89
'check linux-swap file system' \
90
'parted -s $dev2 check 1 > out 2>&1'
91
test_expect_success 'expect no output' 'compare out /dev/null'
94
'extract new UUID 2' \
95
'od -t x1 -An -j17420 -N16 $dev2 > uuid2-new'
97
'check preserves linux-swap UUID' \
98
'compare uuid2 uuid2-new'
100
test_expect_success \
101
'create a linux-swap file system via alias' \
102
'parted -s $dev mkfs 1 linux-swap > out 2>&1'
103
test_expect_success 'expect no output' 'compare out /dev/null'