~ubuntu-branches/ubuntu/precise/parted/precise

« back to all changes in this revision

Viewing changes to tests/t2100-mkswap.sh

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2010-02-06 16:39:19 UTC
  • mfrom: (1.1.5 upstream)
  • mto: (7.3.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 48.
  • Revision ID: james.westby@ubuntu.com-20100206163919-nsxr2vtchk0ecabf
Tags: upstream-2.1
ImportĀ upstreamĀ versionĀ 2.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
# Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 
4
 
 
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.
 
9
 
 
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.
 
14
 
 
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/>.
 
17
 
 
18
test_description='create linux-swap partitions'
 
19
 
 
20
: ${srcdir=.}
 
21
. $srcdir/test-lib.sh
 
22
 
 
23
require_512_byte_sector_size_
 
24
 
 
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
######################################################################
 
30
N=1M
 
31
dev=loop-file
 
32
dev2=loop-file-2
 
33
test_expect_success \
 
34
    'create a file to simulate the underlying device' \
 
35
    'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
 
36
 
 
37
test_expect_success \
 
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'
 
41
 
 
42
test_expect_success \
 
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'
 
46
 
 
47
test_expect_success \
 
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'
 
51
 
 
52
# Extract the byte at offset 451.  It must be 0x82, not 0x83.
 
53
test_expect_success \
 
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'
 
57
 
 
58
test_expect_success \
 
59
    'create another file to simulate the underlying device' \
 
60
    'dd if=/dev/null of=$dev2 bs=1 seek=$N 2> /dev/null'
 
61
 
 
62
test_expect_success \
 
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'
 
66
 
 
67
test_expect_success \
 
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'
 
71
 
 
72
test_expect_success \
 
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'
 
76
 
 
77
# partition starts at offset 16384; swap UUID is 1036 bytes in
 
78
test_expect_success \
 
79
    'extract UUID 1' \
 
80
    'od -t x1 -An -j17420 -N16 $dev > uuid1'
 
81
test_expect_success \
 
82
    'extract UUID 2' \
 
83
    'od -t x1 -An -j17420 -N16 $dev2 > uuid2'
 
84
test_expect_failure \
 
85
    'two linux-swap file systems have different UUIDs' \
 
86
    'compare uuid1 uuid2'
 
87
 
 
88
test_expect_success \
 
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'
 
92
 
 
93
test_expect_success \
 
94
    'extract new UUID 2' \
 
95
    'od -t x1 -An -j17420 -N16 $dev2 > uuid2-new'
 
96
test_expect_success \
 
97
    'check preserves linux-swap UUID' \
 
98
    'compare uuid2 uuid2-new'
 
99
 
 
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'
 
104
 
 
105
test_done