From nobody Thu Jul 10 00:00:22 2025
Delivered-To: importer@patchew.org
Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28
as permitted sender) client-ip=209.132.183.28;
envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com;
Authentication-Results: mx.zohomail.com;
spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as
permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com;
dmarc=fail(p=none dis=none) header.from=canonical.com
Return-Path:
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by
mx.zohomail.com
with SMTPS id 1521644035468530.6199865323512;
Wed, 21 Mar 2018 07:53:55 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com
[10.5.11.15])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id BE33B83F42;
Wed, 21 Mar 2018 14:53:53 +0000 (UTC)
Received: from colo-mx.corp.redhat.com
(colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21])
by smtp.corp.redhat.com (Postfix) with ESMTPS id 969C1749D0;
Wed, 21 Mar 2018 14:53:53 +0000 (UTC)
Received: from lists01.pubmisc.prod.ext.phx2.redhat.com
(lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33])
by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6276D4CA99;
Wed, 21 Mar 2018 14:53:53 +0000 (UTC)
Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com
[10.5.11.13])
by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP
id w2LErpNN026473 for ;
Wed, 21 Mar 2018 10:53:52 -0400
Received: by smtp.corp.redhat.com (Postfix)
id E93B05F7D7; Wed, 21 Mar 2018 14:53:51 +0000 (UTC)
Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com
[10.5.110.38])
by smtp.corp.redhat.com (Postfix) with ESMTPS id B9A1B5F7CE
for ; Wed, 21 Mar 2018 14:53:37 +0000 (UTC)
Received: from youngberry.canonical.com (youngberry.canonical.com
[91.189.89.112]) (using TLSv1 with cipher AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id 8ACCC33BCA
for ; Wed, 21 Mar 2018 14:53:35 +0000 (UTC)
Received: from 1.general.paelzer.uk.vpn ([10.172.196.172]
helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa
(TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76)
(envelope-from )
id 1eyf7O-0004Tj-Bp; Wed, 21 Mar 2018 14:53:34 +0000
From: Christian Ehrhardt
To: libvir-list@redhat.com,
=?UTF-8?q?Guido=20G=C3=BCnther?= ,
Jamie Strandboge
Date: Wed, 21 Mar 2018 15:53:28 +0100
Message-Id:
<1521644008-3735-6-git-send-email-christian.ehrhardt@canonical.com>
In-Reply-To:
<1521644008-3735-1-git-send-email-christian.ehrhardt@canonical.com>
References:
<1521644008-3735-1-git-send-email-christian.ehrhardt@canonical.com>
X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207
matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com
[10.5.110.38]); Wed, 21 Mar 2018 14:53:35 +0000 (UTC)
X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com
[10.5.110.38]);
Wed, 21 Mar 2018 14:53:35 +0000 (UTC) for IP:'91.189.89.112'
DOMAIN:'youngberry.canonical.com' HELO:'youngberry.canonical.com'
FROM:'christian.ehrhardt@canonical.com' RCPT:''
X-RedHat-Spam-Score: -5.01 (RCVD_IN_DNSWL_HI,
T_RP_MATCHES_RCVD) 91.189.89.112 youngberry.canonical.com
91.189.89.112 youngberry.canonical.com
X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13
X-loop: libvir-list@redhat.com
Cc: Christian Ehrhardt
Subject: [libvirt] [PATCH v3 5/5] virt-aa-helper: test: check for expected
profile content
X-BeenThere: libvir-list@redhat.com
X-Mailman-Version: 2.1.12
Precedence: junk
List-Id: Development discussions about the libvirt library & tools
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Sender: libvir-list-bounces@redhat.com
Errors-To: libvir-list-bounces@redhat.com
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]);
Wed, 21 Mar 2018 14:53:54 +0000 (UTC)
X-ZohoMail: RSF_0 Z_629925259 SPT_0
Content-Type: text/plain; charset="utf-8"
So far the virt-aa-helper tests only checked the return code and thereby
catched aborts like issues failing to parse the XML. But there is one
category of virt-aa-helper issues so far untested - not generating the
expected rule.
This adds a basic grep based checks after each test to match against the
rule that is expected to be added by the test.
Signed-off-by: Christian Ehrhardt
---
tests/virt-aa-helper-test | 86 +++++++++++++++++++++++++++----------------=
----
1 file changed, 50 insertions(+), 36 deletions(-)
diff --git a/tests/virt-aa-helper-test b/tests/virt-aa-helper-test
index 7c839e4..2ddad20 100755
--- a/tests/virt-aa-helper-test
+++ b/tests/virt-aa-helper-test
@@ -108,6 +108,9 @@ testme() {
outstr=3D"$2"
args=3D"$3"
input=3D""
+ checkrule=3D"$5"
+
+ tmpout=3D$(mktemp)
=20
if [ -n "$4" ]; then
input=3D"$4"
@@ -127,13 +130,24 @@ testme() {
echo "': " >$output
set +e
if [ -n "$input" ]; then
- LD_LIBRARY_PATH=3D"$ld_library_path" $exe $extra_args $args < $inp=
ut >$output 2>&1
+ LD_LIBRARY_PATH=3D"$ld_library_path" $exe $extra_args $args < $inp=
ut >"$tmpout" 2>&1
else
- LD_LIBRARY_PATH=3D"$ld_library_path" $exe $extra_args $args >$outp=
ut 2>&1
+ LD_LIBRARY_PATH=3D"$ld_library_path" $exe $extra_args $args >"$tmp=
out" 2>&1
fi
rc=3D"$?"
+ cat "$tmpout" >"$output"
+
+ rule_missing=3D0
+ if [ -n "$checkrule" ]; then
+ if ! grep -q "$checkrule" "$tmpout"; then
+ echo "FAIL: missing rule '$checkrule'" >"$output"
+ rule_missing=3D1
+ fi
+ fi
+ rm "$tmpout"
+
set -e
- if [ "$rc" =3D "$expected" ]; then
+ if [ "$rc" =3D "$expected" ] && [ $rule_missing -eq 0 ]; then
echo "pass" >$output
else
echo "FAIL: exited with '$rc'" >$output
@@ -234,19 +248,19 @@ testme "1" "-c with invalid domain name char *" "-c -=
u $valid_uuid" "$test_xml"
=20
echo "Expected pass:" >$output
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" "$template_xml" >=
"$test_xml"
-testme "0" "create (x86_64)" "-c -u $valid_uuid" "$test_xml"
+testme "0" "create (x86_64)" "-c -u $valid_uuid" "$test_xml" "$disk1.*rwk,=
$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,arch=3D'x86=
_64',arch=3D'i686',g" "$template_xml" > "$test_xml"
-testme "0" "create (i686)" "-c -u $valid_uuid" "$test_xml"
+testme "0" "create (i686)" "-c -u $valid_uuid" "$test_xml" "$disk1.*rwk,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,arch=3D'x86=
_64',arch=3D'ppc',g" "$template_xml" > "$test_xml"
-testme "0" "create (ppc)" "-c -u $valid_uuid" "$test_xml"
+testme "0" "create (ppc)" "-c -u $valid_uuid" "$test_xml" "$disk1.*rwk,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,,g" "$tem=
plate_xml" > "$test_xml"
-testme "0" "create multiple disks" "-c -u $valid_uuid" "$test_xml"
+testme "0" "create multiple disks" "-c -u $valid_uuid" "$test_xml" "$disk1=
.*rwk,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###',${disk1}'/> "$test_xml"
-testme "0" "create (readonly)" "-c -u $valid_uuid" "$test_xml"
+testme "0" "create (readonly)" "-c -u $valid_uuid" "$test_xml" "$disk1.*rk=
,$"
=20
if [ "$test_hostdev" =3D "yes" ]; then
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,=
,,g" "$template_xml" > "$test_xml"
@@ -257,73 +271,73 @@ if [ "$test_hostdev" =3D "yes" ]; then
fi
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$nonexistent,g" "$template_=
xml" > "$test_xml"
-testme "0" "create (non-existent disk)" "-c -u $valid_uuid" "$test_xml"
+testme "0" "create (non-existent disk)" "-c -u $valid_uuid" "$test_xml" "$=
nonexistent.*rwk,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$relative_disk1,g" "$templa=
te_xml" > "$test_xml"
-testme "0" "create (relative path)" "-c -u $valid_uuid" "$test_xml"
+testme "0" "create (relative path)" "-c -u $valid_uuid" "$test_xml" "$disk=
1.*rwk,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk2,g" "$template_xml" >=
"$test_xml"
-testme "0" "replace" "-r -u $valid_uuid" "$test_xml"
+testme "0" "replace" "-r -u $valid_uuid" "$test_xml" "$disk2.*rwk,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$nonexistent,g" "$template_=
xml" > "$test_xml"
-testme "0" "replace (non-existent disk)" "-r -u $valid_uuid" "$test_xml"
+testme "0" "replace (non-existent disk)" "-r -u $valid_uuid" "$test_xml" "=
$nonexistent.*rwk,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" "$template_xml" >=
"$test_xml"
-testme "0" "replace (adding disk)" "-r -u $valid_uuid -f $disk2" "$test_xm=
l"
+testme "0" "replace (adding disk)" "-r -u $valid_uuid -f $disk2" "$test_xm=
l" "$disk2.*rwk,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" "$template_xml" >=
"$test_xml"
-testme "0" "replace (adding non-existent disk)" "-r -u $valid_uuid -f $non=
existent" "$test_xml"
+testme "0" "replace (adding non-existent disk)" "-r -u $valid_uuid -f $non=
existent" "$test_xml" "$nonexistent.*rwk,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" "$template_xml" >=
"$test_xml"
-testme "0" "replace (appending disk)" "-r -u $valid_uuid -F $disk2" "$test=
_xml"
+testme "0" "replace (appending disk)" "-r -u $valid_uuid -F $disk2" "$test=
_xml" "$disk2.*rwk,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" "$template_xml" >=
"$test_xml"
-testme "0" "replace (appending non-existent disk)" "-r -u $valid_uuid -F $=
nonexistent" "$test_xml"
+testme "0" "replace (appending non-existent disk)" "-r -u $valid_uuid -F $=
nonexistent" "$test_xml" "$nonexistent.*rwk,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,=
,g" "$template_xml" > "$test_xml"
testme "0" "disk (empty cdrom)" "-r -u $valid_uuid" "$test_xml"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,=
,g" "$template_xml" > "$test_xml"
-testme "0" "serial" "-r -u $valid_uuid" "$test_xml"
+testme "0" "serial" "-r -u $valid_uuid" "$test_xml" "$tmpdir/serial.log.*r=
w,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,=
,g" "$template_=
xml" > "$test_xml"
testme "0" "serial (pty)" "-r -u $valid_uuid" "$test_xml"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,=
,g" "$template_xml" > "$test_xml"
-testme "0" "serial (dev)" "-r -u $valid_uuid" "$test_xml"
+testme "0" "serial (dev)" "-r -u $valid_uuid" "$test_xml" "/dev/ttyS0.*rw,=
$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,=
,g" "$template_xml" > "$test_xml"
-mkfifo "$tmpdir/serial.pipe.in" "$tmpdir/serial.pipe.out"
+mkfifo "$tmpdir/serial.pipe.in" "$tmpdir/serial.pipe.out" "$tmpdir/serial.=
pipe.in.*rw,$"
testme "0" "serial (pipe)" "-r -u $valid_uuid" "$test_xml"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,=
,g" "$template_xml" > "$test_xml"
touch "$tmpdir/console.log"
-testme "0" "console" "-r -u $valid_uuid" "$test_xml"
+testme "0" "console" "-r -u $valid_uuid" "$test_xml" "$tmpdir/console.log.=
*rw,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,=
,g" "$templat=
e_xml" > "$test_xml"
testme "0" "console (pty)" "-r -u $valid_uuid" "$test_xml"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,=
,g" "$template_xml" > "$test_xml"
mkfifo "$tmpdir/console.pipe.in" "$tmpdir/console.pipe.out"
-testme "0" "console (pipe)" "-r -u $valid_uuid" "$test_xml"
+testme "0" "console (pipe)" "-r -u $valid_uuid" "$test_xml" "$tmpdir/conso=
le.pipe.out.*rw,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,=
,g" "$template_xml" > "$test_xml"
-testme "0" "parallel (pty)" "-r -u $valid_uuid" "$test_xml"
+testme "0" "parallel (pty)" "-r -u $valid_uuid" "$test_xml" "/dev/pts/0.*r=
w,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,=
,g" "$template_xml" > "$test_xml"
mkfifo "$tmpdir/parallel.pipe.in" "$tmpdir/parallel.pipe.out"
-testme "0" "parallel (pipe)" "-r -u $valid_uuid" "$test_xml"
+testme "0" "parallel (pipe)" "-r -u $valid_uuid" "$test_xml" "$tmpdir/para=
llel.pipe.in.*rw,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,=
,g" "$template_xml" > "$test_xml"
touch "$tmpdir/guestfwd"
-testme "0" "channel (unix)" "-r -u $valid_uuid" "$test_xml"
+testme "0" "channel (unix)" "-r -u $valid_uuid" "$test_xml" "$tmpdir/guest=
fwd.*rw,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,=
,g" "$te=
mplate_xml" > "$test_xml"
testme "0" "channel (pty)" "-r -u $valid_uuid" "$test_xml"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,$tmpdir/kernel,g" "$template_xml" > "$test_xml"
touch "$tmpdir/kernel"
-testme "0" "kernel" "-r -u $valid_uuid" "$test_xml"
+testme "0" "kernel" "-r -u $valid_uuid" "$test_xml" "$tmpdir/kernel.*r,$"
=20
testfw "ovmf (old path)" "/usr/share/ovmf/OVMF.fd"
testfw "OVMF (new path)" "/usr/share/OVMF/OVMF_CODE.fd"
@@ -333,37 +347,37 @@ testfw "qemu-efi" "/usr/share/qemu-efi/QEMU_EFI.fd"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,$tmpdir/initrd,g" "$template_xml" > "$test_xml"
touch "$tmpdir/initrd"
-testme "0" "initrd" "-r -u $valid_uuid" "$test_xml"
+testme "0" "initrd" "-r -u $valid_uuid" "$test_xml" "$tmpdir/initrd.*r,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,/boot/kernel,g" "$template_xml" > "$test_xml"
-testme "0" "kernel in /boot" "-r -u $valid_uuid" "$test_xml"
+testme "0" "kernel in /boot" "-r -u $valid_uuid" "$test_xml" "/boot/kernel=
.*r,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,/boot/initrd,g" "$template_xml" > "$test_xml"
-testme "0" "initrd in /boot" "-r -u $valid_uuid" "$test_xml"
+testme "0" "initrd in /boot" "-r -u $valid_uuid" "$test_xml" "/boot/initrd=
.*r,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,/vmlinuz,g" "$template_xml" > "$test_xml"
-testme "0" "kernel is /vmlinuz" "-r -u $valid_uuid" "$test_xml"
+testme "0" "kernel is /vmlinuz" "-r -u $valid_uuid" "$test_xml" "/vmlinuz.=
*r,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,/initrd/ramdisk,g" "$template_xml" > "$test_xml"
-testme "0" "initrd is /initrd/ramdisk" "-r -u $valid_uuid" "$test_xml"
+testme "0" "initrd is /initrd/ramdisk" "-r -u $valid_uuid" "$test_xml" "/i=
nitrd/ramdisk.*r,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,/initrd.img,g" "$template_xml" > "$test_xml"
-testme "0" "initrd is /initrd.img" "-r -u $valid_uuid" "$test_xml"
+testme "0" "initrd is /initrd.img" "-r -u $valid_uuid" "$test_xml" "/initr=
d.img.*r,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,g" "$template_xml" > "$test_xml"
-testme "0" "sdl Xauthority" "-r -u $valid_uuid" "$test_xml"
+testme "0" "sdl Xauthority" "-r -u $valid_uuid" "$test_xml" "/home/myself/=
.Xauthority.*r,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" "$template_xml" >=
"$test_xml"
-testme "0" "hugepages" "-r -u $valid_uuid -F /run/hugepages/kvm/\*\*" "$te=
st_xml"
+testme "0" "hugepages" "-r -u $valid_uuid -F /run/hugepages/kvm/\*\*" "$te=
st_xml" "/run/hugepages/kvm/.*rwk,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,,g" "$template_xml" > "$=
test_xml"
-testme "0" "vnc socket" "-r -u $valid_uuid" "$test_xml"
+testme "0" "vnc socket" "-r -u $valid_uuid" "$test_xml" "/var/lib/libvirt/=
qemu/myself.vnc.*rw,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,=
,g" "$template_xml" > "$test_xml"
-testme "0" "input dev passthrough" "-r -u $valid_uuid" "$test_xml"
+testme "0" "input dev passthrough" "-r -u $valid_uuid" "$test_xml" "$disk2=
.*rw,$"
=20
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,524=
288,1048576,g" -e "s,,$disk25242=
880,g" "$template_xml" > "$=
test_xml"
-testme "0" "nvdimm" "-r -u $valid_uuid" "$test_xml"
+testme "0" "nvdimm" "-r -u $valid_uuid" "$test_xml" "$disk2.*rw,$"
=20
testme "0" "help" "-h"
=20
--=20
2.7.4
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list