build: Set TMPDIR for local testing.
[libguestfs.git] / resize / test-virt-resize.sh
1 #!/bin/bash -
2 # libguestfs virt-resize 2.0 test script
3 # Copyright (C) 2010-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., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 export LANG=C
20 set -e
21
22 # Test expanding.
23 #
24 # This exercises a number of interesting codepaths including resizing
25 # LV content, handling GPT, and using qcow2 as a target.
26
27 ../fish/guestfish -N bootrootlv:/dev/VG/LV:ext2:ext4:400M:32M:gpt </dev/null
28
29 qemu-img create -f qcow2 test2.img 500M
30 ./virt-resize -d --expand /dev/sda2 --lv-expand /dev/VG/LV test1.img test2.img
31
32 # Test shrinking in a semi-realistic scenario.  Although the disk
33 # image created above contains no data, we will nevertheless use
34 # similar operations to ones that might be used by a real admin.
35
36 ../fish/guestfish -a test1.img <<EOF
37 run
38 resize2fs-size /dev/VG/LV 190M
39 lvresize /dev/VG/LV 190
40 pvresize-size /dev/sda2 200M
41 fsck ext4 /dev/VG/LV
42 EOF
43
44 rm -f test2.img; truncate -s 300M test2.img
45 ./virt-resize -d --shrink /dev/sda2 test1.img test2.img
46
47 rm -f test1.img test2.img