Previously untested, and as always happens they were quite buggy.
This adds a test of the new functionality of default keys.
---
tests/luks/Makefile.am | 3 +-
tests/luks/test-key-option.sh | 65 +++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/tests/luks/Makefile.am b/tests/luks/Makefile.am
index bb8ef54ee..30c817f87 100644
--- a/tests/luks/Makefile.am
+++ b/tests/luks/Makefile.am
@@ -19,7 +19,8 @@ include $(top_srcdir)/subdir-rules.mk
TESTS = \
test-luks.sh \
- test-luks-list.sh
+ test-luks-list.sh \
+ test-key-option.sh
TESTS_ENVIRONMENT = $(top_builddir)/run --test
diff --git a/tests/luks/test-key-option.sh b/tests/luks/test-key-option.sh
new file mode 100755
index 000000000..756339899
--- /dev/null
+++ b/tests/luks/test-key-option.sh
@@ -0,0 +1,65 @@
+#!/bin/bash -
+# libguestfs
+# Copyright (C) 2019 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# Test the --key option. It is handled by common code so we only need
+# to test one tool (guestfish).
+
+set -e
+
+$TEST_FUNCTIONS
+skip_if_skipped
+skip_unless_feature_available luks
+
+d=test-key-option.img
+rm -f $d
+
+# Create a test disk
+guestfish --keys-from-stdin <<EOF
+sparse $d 1G
+run
+part-disk /dev/sda mbr
+
+pvcreate /dev/sda1
+vgcreate VG /dev/sda1
+
+# Create some LVs which will contain the LUKS devices.
+lvcreate LV1 VG 64
+lvcreate LV2 VG 64
+lvcreate LV3 VG 64
+lvcreate LV4 VG 64
+
+# Create the LUKS devices, give each a different key.
+luks-format /dev/VG/LV1 0
+keylv1
+luks-format /dev/VG/LV2 0
+keylv2
+luks-format /dev/VG/LV3 0
+keylv3
+luks-format /dev/VG/LV4 0
+keylv4
+EOF
+
+# Try to open the devices from the guestfish command line.
+guestfish -a $d \
+ --key /dev/VG/LV1:key:keylv1 \
+ --key /dev/VG/LV2:key:badkey --key /dev/VG/LV2:key:keylv2 \
+ --key :key:keylv3 \
+ --key :key:keylv4 \
+ run : echo-daemon ok
+
+rm $d
--
2.23.0