[libvirt] [PATCH] tests: add test file for smartcard database

Anya Harter aharter at redhat.com
Fri Jun 15 14:45:05 UTC 2018


Add test case explicitly defining a smartcard host certificates
database via the following xml:

    <smartcard mode='host-certificates'>
      <database>/tmp/foo</database>
    </smartcard>

This case is not currently covered in the test suite.

Signed-off-by: Anya Harter <aharter at redhat.com>
---
 .../smartcard-host-certificates-database.args | 28 +++++++++++++++
 .../smartcard-host-certificates-database.xml  | 21 +++++++++++
 tests/qemuxml2argvtest.c                      |  2 ++
 .../smartcard-host-certificates-database.xml  | 35 +++++++++++++++++++
 tests/qemuxml2xmltest.c                       |  1 +
 5 files changed, 87 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/smartcard-host-certificates-database.args
 create mode 100644 tests/qemuxml2argvdata/smartcard-host-certificates-database.xml
 create mode 100644 tests/qemuxml2xmloutdata/smartcard-host-certificates-database.xml

diff --git a/tests/qemuxml2argvdata/smartcard-host-certificates-database.args b/tests/qemuxml2argvdata/smartcard-host-certificates-database.args
new file mode 100644
index 0000000000..bc159f234d
--- /dev/null
+++ b/tests/qemuxml2argvdata/smartcard-host-certificates-database.args
@@ -0,0 +1,28 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot c \
+-device usb-ccid,id=ccid0,bus=usb.0,port=1 \
+-usb \
+-device ccid-card-emulated,backend=certificates,cert1=cert1,cert2=cert2,\
+cert3=cert3,db=/tmp/foo,id=smartcard0,bus=ccid0.0 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/smartcard-host-certificates-database.xml b/tests/qemuxml2argvdata/smartcard-host-certificates-database.xml
new file mode 100644
index 0000000000..fa35645736
--- /dev/null
+++ b/tests/qemuxml2argvdata/smartcard-host-certificates-database.xml
@@ -0,0 +1,21 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i686</emulator>
+    <smartcard mode='host-certificates'>
+      <certificate>cert1</certificate>
+      <certificate>cert2</certificate>
+      <certificate>cert3</certificate>
+      <database>/tmp/foo</database>
+    </smartcard>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index f44cac9fef..194a8d2bab 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1404,6 +1404,8 @@ mymain(void)
             QEMU_CAPS_CCID_EMULATED);
     DO_TEST("smartcard-host-certificates",
             QEMU_CAPS_CCID_EMULATED);
+    DO_TEST("smartcard-host-certificates-database",
+            QEMU_CAPS_CCID_EMULATED);
     DO_TEST("smartcard-passthrough-tcp",
             QEMU_CAPS_CCID_PASSTHRU);
     DO_TEST("smartcard-passthrough-spicevmc",
diff --git a/tests/qemuxml2xmloutdata/smartcard-host-certificates-database.xml b/tests/qemuxml2xmloutdata/smartcard-host-certificates-database.xml
new file mode 100644
index 0000000000..55d54a4355
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/smartcard-host-certificates-database.xml
@@ -0,0 +1,35 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i686</emulator>
+    <controller type='usb' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
+    <controller type='ccid' index='0'/>
+    <smartcard mode='host-certificates'>
+      <certificate>cert1</certificate>
+      <certificate>cert2</certificate>
+      <certificate>cert3</certificate>
+      <database>/tmp/foo</database>
+      <address type='ccid' controller='0' slot='0'/>
+    </smartcard>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <memballoon model='virtio'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </memballoon>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index f5805c7f50..4449954ad4 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1163,6 +1163,7 @@ mymain(void)
 
     DO_TEST("smartcard-host", NONE);
     DO_TEST("smartcard-host-certificates", NONE);
+    DO_TEST("smartcard-host-certificates-database", NONE);
     DO_TEST("smartcard-passthrough-tcp", NONE);
     DO_TEST("smartcard-passthrough-spicevmc", NONE);
     DO_TEST("smartcard-controller", NONE);
-- 
2.17.1




More information about the libvir-list mailing list