~youscribe/parted/3.1

« back to all changes in this revision

Viewing changes to tests/t0100-print.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
# the most basic 'print' test
 
3
# Copyright (C) 2007, 2009-2012 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
. "${srcdir=.}/init.sh"; path_prepend_ ../parted
 
19
ss=$sector_size_
 
20
 
 
21
ss=$sector_size_
 
22
dev=loop-file
 
23
 
 
24
{
 
25
  cat <<EOF
 
26
Model:  (file)
 
27
Disk .../$dev: 8s
 
28
Sector size (logical/physical): ${ss}B/${ss}B
 
29
Partition Table: msdos
 
30
Disk Flags:
 
31
 
 
32
Number  Start  End  Size  Type  File system  Flags
 
33
 
 
34
EOF
 
35
} > exp || framework_failure
 
36
 
 
37
# Using msdos_magic='\x55\xaa' looks nicer, but isn't portable.
 
38
# dash's builtin printf doesn't recognize such \xHH hexadecimal escapes.
 
39
msdos_magic='\125\252'
 
40
 
 
41
# The extra 3KB+ zero bytes at the end are to avoid triggering a failure
 
42
# on linux-2.6.8 that's probably related to opening with O_DIRECT.
 
43
# Note that the minimum number of appended zero bytes required to avoid
 
44
# the failure was 3465.  Here, we append a little more to make the resulting
 
45
# file have a total size of exactly 8 sectors.
 
46
# setup: create the most basic partition table, manually
 
47
{ dd if=/dev/zero  bs=510 count=1; printf "$msdos_magic"
 
48
  dd if=/dev/zero bs=$(expr 8 '*' $ss - 510) count=1; } > $dev || fail=1
 
49
 
 
50
# print the empty table
 
51
parted -s $dev unit s print >out 2>&1 || fail=1
 
52
 
 
53
# prepare actual and expected output
 
54
sed 's/ $//' out > k && mv k out || fail=1 # Remove trailing blank.
 
55
mv out o2 && sed "s,^Disk .*/$dev:,Disk .../$dev:," o2 > out || fail=1
 
56
 
 
57
# check for expected output
 
58
compare exp out || fail=1
 
59
 
 
60
Exit $fail