tests: Split regressions -> various subdirectories of tests/
[libguestfs.git] / tests / md / test-list-md-devices.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 # Test guestfish list-md-devices command
20
21 set -e
22
23 output=$(
24 ../../fish/guestfish <<EOF
25 # Add 2 empty disks
26 sparse md-test1.img 100M
27 sparse md-test2.img 100M
28 run
29
30 # list-md-devices should return nothing
31 list-md-devices
32
33 # Create a raid1 based on the 2 disks
34 md-create test "/dev/sda /dev/sdb" level:raid1
35 EOF
36 )
37
38 # Ensure list-md-devices above returned nothing
39 if [ ! -z "$output" ]; then
40     echo "$0: error: output of list-md-devices with no MD devices did not match expected output"
41     echo $output
42     exit 1;
43 fi
44
45 # Ensure list-md-devices now returns the newly created md device
46 output=$(
47 ../../fish/guestfish -a md-test1.img -a md-test2.img <<EOF
48 run
49 list-md-devices
50 EOF
51 )
52
53 if [ "$output" != "/dev/md127" ]; then
54     echo "$0: error: output of list-md-devices did not match expected output"
55     echo "$output"
56     exit 1
57 fi
58
59 rm -f md-test1.img md-test2.img