3 # Copyright (C) 2011 Red Hat Inc.
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.
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.
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.
19 # Test LUKS devices appear in the output of list-dm-devices.
23 [ -n "$SKIP_TEST_LUKS_SH" ] && {
24 echo "test-luks-list.sh skipped (environment variable set)"
28 rm -f test1.img test.output
30 ../fish/guestfish --keys-from-stdin > test.output <<'EOF'
33 part-init /dev/sda mbr
34 part-add /dev/sda p 64 1048575
35 part-add /dev/sda p 1048576 -64
37 # Create LUKS device with key "key0" in slot 0.
38 luks-format /dev/sda1 0
41 # Create some unrelated LVs.
44 lvcreate LV1 /dev/VG 100
45 lvcreate LV2 /dev/VG 200
46 lvcreate LV3 /dev/VG 100
48 # Open the device as 'lukstest'.
49 luks-open /dev/sda1 lukstest
52 # List devices, '/dev/mapper/lukstest' should appear.
57 luks-close /dev/mapper/lukstest
59 # List devices, '/dev/mapper/lukstest' should not appear.
63 # Open the device again.
64 luks-open /dev/sda1 lukstest
67 # Check no LVs appear in list-dm-devices output.
71 # Check LUKS device doesn't appear in any of the other lists.
73 list-devices | sed 's,^/dev/[hv]d,/dev/sd,'
75 list-partitions | sed 's,^/dev/[hv]d,/dev/sd,'
81 pvs | sed 's,^/dev/[hv]d,/dev/sd,'
85 # Expected vs actual output.
86 if [ "$(cat test.output)" != "\
105 echo "test-luks-list.sh: Unexpected output from test:"
107 echo "[end of output]"
111 rm -f test1.img test.output