OSDN Git Service

source test-lib.sh (not init.sh) from each test
[android-x86/external-parted.git] / tests / t5000-tags.sh
1 #!/bin/sh
2
3 # Copyright (C) 2007,2008 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="test bios_grub flag in gpt labels"
19
20 : ${srcdir=.}
21 . $srcdir/test-lib.sh
22
23 dev=loop-file
24
25 test_expect_success \
26     "setup: create zeroed device" \
27     '{ dd if=/dev/zero bs=1024 count=64; } > $dev'
28
29 test_expect_success \
30     'create gpt label' \
31     'parted -s $dev mklabel gpt >out 2>&1'
32
33 test_expect_success \
34     'add a partition' \
35     'parted -s $dev mkpart primary 0 1 >>out 2>&1'
36
37 test_expect_success \
38     'print the table (before manual modification)' \
39     'parted -s $dev print >>out 2>&1'
40
41 # Using bios_boot_magic='\x48\x61' looks nicer, but isn't portable.
42 # dash's builtin printf doesn't recognize such \xHH hexadecimal escapes.
43 bios_boot_magic='\110\141\150\41\111\144\157\156\164\116\145\145\144\105\106\111'
44
45 printf "$bios_boot_magic" | dd of=$dev bs=1024 seek=1 conv=notrunc
46
47 test_expect_success \
48     'print the table (after manual modification)' \
49     'parted -s $dev print >>out 2>&1'
50
51 pwd=`pwd`
52
53 fail=0
54 {
55   cat <<EOF
56 Model:  (file)
57 Disk .../$dev: 65.5kB
58 Sector size (logical/physical): 512B/512B
59 Partition Table: gpt
60
61 Number  Start   End     Size    File system  Name     Flags
62  1      17.4kB  48.6kB  31.2kB               primary       
63
64 Model:  (file)
65 Disk .../$dev: 65.5kB
66 Sector size (logical/physical): 512B/512B
67 Partition Table: gpt
68
69 Number  Start   End     Size    File system  Name     Flags    
70  1      17.4kB  48.6kB  31.2kB               primary  bios_grub
71
72 EOF
73 } > exp || fail=1
74
75 test_expect_success \
76     'prepare actual and expected output' \
77     'test $fail = 0 &&
78      mv out o2 && sed "s,^Disk .*/$dev:,Disk .../$dev:," o2 > out'
79
80 test_expect_success 'check for expected output' '$compare out exp'
81
82 test_done