~youscribe/parted/3.1

« back to all changes in this revision

Viewing changes to tests/t4100-msdos-starting-sector.sh

  • Committer: Guilhem Lettron
  • Date: 2012-10-22 14:37:59 UTC
  • Revision ID: guilhem+ubuntu@lettron.fr-20121022143759-m403kecgz13sknvp
3.1 from tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# Consistency in msdos free space starting sector.
 
3
 
 
4
# Copyright (C) 2008-2012 Free Software Foundation, Inc.
 
5
 
 
6
# This program is free software; you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation; either version 3 of the License, or
 
9
# (at your option) any later version.
 
10
 
 
11
# This program is distributed in the hope that it will be useful,
 
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
# GNU General Public License for more details.
 
15
 
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 
 
19
. "${srcdir=.}/init.sh"; path_prepend_ ../parted
 
20
ss=$sector_size_
 
21
 
 
22
######################################################################
 
23
# parted 1.8.8.1 and earlier was inconsistent when calculating the
 
24
# start sector for free space in msdos type lables.  parted was not
 
25
# consistent in the use of metadata padding for msdos labels.
 
26
######################################################################
 
27
 
 
28
N=4096 # number of sectors
 
29
dev=loop-file
 
30
# create a file to simulate the underlying device
 
31
dd if=/dev/zero of=$dev bs=${ss}c count=$N 2> /dev/null || fail=1
 
32
 
 
33
# label the test disk
 
34
parted -s $dev mklabel msdos > out 2>&1 || fail=1
 
35
# expect no output
 
36
compare /dev/null out || fail=1
 
37
 
 
38
# Test the output of print free with no partitions.
 
39
cat <<EOF > exp || fail=1
 
40
BYT;
 
41
path:${N}s:file:$ss:$ss:msdos::;
 
42
1:32s:4095s:4064s:free;
 
43
EOF
 
44
 
 
45
# create expected output file' 'test $fail = 0'
 
46
 
 
47
# display output of label without partitions
 
48
parted -m -s $dev unit s print free > out 2>&1 || fail=1
 
49
 
 
50
# check for expected output
 
51
sed "2s/^[^:]*:/path:/" < out > k; mv k out
 
52
compare exp out || fail=1
 
53
 
 
54
# Test the output of print free with one partition.
 
55
cat <<EOF > exp || fail=1
 
56
BYT;
 
57
path:${N}s:file:$ss:$ss:msdos::;
 
58
1:32s:2047s:2016s:free;
 
59
1:2048s:4095s:2048s:::;
 
60
EOF
 
61
 
 
62
# create a partition at the end of the label
 
63
parted -s $dev mkpart primary 2048s 4095s || fail=1
 
64
 
 
65
# display output of label with partition
 
66
parted -m -s $dev unit s print free > out 2>&1 || fail=1
 
67
 
 
68
# check for expected output
 
69
sed "2s/^[^:]*:/path:/" < out > k; mv k out
 
70
compare exp out || fail=1
 
71
 
 
72
Exit $fail