61b9df60db6907d9b87c87b9b39a53cab4badbab
[libguestfs.git] / regressions / rhbz602997.sh
1 #!/bin/bash -
2 # libguestfs
3 # Copyright (C) 2011 Red Hat 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 2 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, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19 # https://bugzilla.redhat.com/show_bug.cgi?id=602997
20 # Fix part-get-bootable to work with missing/unordered partitions.
21
22 set -e
23 export LANG=C
24
25 guestfish=../fish/guestfish
26
27 rm -f test.img test.output
28
29 $guestfish > test.output <<EOF
30 sparse test.img 100M
31 run
32 part-init /dev/sda mbr
33 # Create an unordered layout.
34 # This places part 2 in front of part 1.
35 part-add /dev/sda p 1001 2000
36 part-add /dev/sda p 1 1000
37 #part-list /dev/sda
38 part-set-bootable /dev/sda 1 true
39 part-get-bootable /dev/sda 1
40 part-get-bootable /dev/sda 2
41 EOF
42
43 if [ "$(cat test.output)" != "true
44 false" ]; then
45     echo "rhbz602997.sh: Unexpected output from test:"
46     cat test.output
47     echo "[end of output]"
48     exit 1
49 fi
50
51 $guestfish > test.output <<EOF
52 sparse test.img 100M
53 run
54 part-init /dev/sda mbr
55 part-add /dev/sda p 1 1000
56 part-add /dev/sda p 1001 2000
57 part-add /dev/sda p 2001 3000
58 part-del /dev/sda 2
59 #part-list /dev/sda
60 part-get-bootable /dev/sda 3
61 ping-daemon
62 EOF
63
64 if [ "$(cat test.output)" != "false" ]; then
65     echo "rhbz602997.sh: Unexpected output from test:"
66     cat test.output
67     echo "[end of output]"
68     exit 1
69 fi
70
71 rm -f test.img test.output