~youscribe/parted/3.1

« back to all changes in this revision

Viewing changes to tests/t2300-dos-label-extended-bootcode.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
# Ensure parted preserves bootcode in extended partition.
 
3
 
 
4
# Copyright (C) 2009-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
 
 
21
require_512_byte_sector_size_
 
22
 
 
23
dev=loop-file
 
24
bootcode_size=446
 
25
 
 
26
# Create the test file
 
27
dd if=/dev/zero of=$dev bs=1M count=4 || fail=1
 
28
 
 
29
# Create msdos label
 
30
parted -s $dev mklabel msdos > out 2>&1 || fail=1
 
31
compare /dev/null out || fail=1 # Expect no output
 
32
 
 
33
# Create extended partition
 
34
parted -s $dev mkpart extended 2048s 8191s > out 2>&1 || fail=1
 
35
compare /dev/null out || fail=1 # Expect no output
 
36
 
 
37
# Create logical partition
 
38
parted -s $dev mkpart logical 4096s 8191s > out 2>&1 || fail=1
 
39
compare /dev/null out || fail=1 # Expect no output
 
40
 
 
41
# Install fake bootcode
 
42
printf %0${bootcode_size}d 0 > in || fail=1
 
43
dd if=in of=$dev bs=1c seek=1M count=$bootcode_size \
 
44
  conv=notrunc > /dev/null 2>&1 || fail=1
 
45
 
 
46
# Save fake bootcode for later comparison
 
47
dd if=$dev of=before bs=1 skip=1M count=$bootcode_size || fail=1
 
48
 
 
49
# Do something to the label
 
50
parted -s $dev rm 5 > out 2>&1 || fail=1
 
51
compare /dev/null out || fail=1 # Expect no output
 
52
 
 
53
# Extract the bootcode for comparison
 
54
dd if=$dev of=after bs=1 skip=1M count=$bootcode_size || fail=1
 
55
 
 
56
# Expect bootcode has not changed
 
57
compare before after || fail=1
 
58
 
 
59
Exit $fail