From nobody Wed Feb 11 03:07:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=canonical.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1633629776195410.6213437592078; Thu, 7 Oct 2021 11:02:56 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-411-RMWoz2cBOgaQWHsmgKOY4A-1; Thu, 07 Oct 2021 14:02:53 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AF037882B35; Thu, 7 Oct 2021 18:01:46 +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 7DAAF5CCFF2; Thu, 7 Oct 2021 18:01:43 +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 B02E157DC1; Thu, 7 Oct 2021 18:01:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 197HWhqr020072 for ; Thu, 7 Oct 2021 13:32:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 11E212026D48; Thu, 7 Oct 2021 17:32:43 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0DB962026D46 for ; Thu, 7 Oct 2021 17:32:43 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E7DFF899EC0 for ; Thu, 7 Oct 2021 17:32:42 +0000 (UTC) Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-435-94v3nK9SN26GI-t6nZDUkg-1; Thu, 07 Oct 2021 13:32:41 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 4487840012 for ; Thu, 7 Oct 2021 17:25:50 +0000 (UTC) Received: by mail-wr1-f70.google.com with SMTP id e12-20020a056000178c00b001606927de88so5254949wrg.10 for ; Thu, 07 Oct 2021 10:25:50 -0700 (PDT) Received: from localhost (o5wzrf.static.otenet.gr. [2.84.75.34]) by smtp.gmail.com with ESMTPSA id o26sm9422479wmc.17.2021.10.07.10.25.47 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Oct 2021 10:25:47 -0700 (PDT) X-MC-Unique: RMWoz2cBOgaQWHsmgKOY4A-1 X-MC-Unique: 94v3nK9SN26GI-t6nZDUkg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=JWgwwN+mRE8XO1xwOWJzpi2mvJHkUO/XVP07VASKkw0=; b=zyxP0Ezemk21N+UqaUidHj86Y0IBHqCgwpE2ZLLNF0u8ptGZwKhsjyZN3kL+MVUYTl PkHtGAWWynokYy8INqYnEPVQzbOhN8B1LFD4rB38zAIpNsloq7avkq6b5SBUv1zlmTUN 5j5Df/ODWffy+Vki/C2F1XMD19+/OUjH33LL7NFw0kYVBiR9b3ewDRTs2VZ2DrVKJJL+ /w06YJjxTNbGsmaE8scEjjJ/Rp3l0YxWLvy9D09yCCeZywJ8G2ftnLUqCGhig2h9eC3x FBYQQ8kkA/ceo3XMmRh6rIVwv7TkoXrdbz2+WKoqIKNmWiZJmCENVvx+iZoKzGvjmxNk aJLg== X-Gm-Message-State: AOAM530qEbqQzt6WxSqguHYbEsSEFha3Frs03UoLCTFx+Jr/ZRQlYrve BMcxitFZNXK0VWc1aoUA/d5HRfo0VxYyYjprAjyHSwkGf7mK0hwC5xqc7sRzQKLrUVccJzY/p1x 1H6LRPmVcVfIYChjrMp7M4BfrY4er+mrRYg== X-Received: by 2002:adf:a48e:: with SMTP id g14mr7044557wrb.11.1633627547915; Thu, 07 Oct 2021 10:25:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSiJ/2PTFmog9ZzhBDilJDvzH1xPxrA+WgNM/pM/hDyyKZiIfJAX12k4fhEYDQsxvCsaxpaA== X-Received: by 2002:adf:a48e:: with SMTP id g14mr7044542wrb.11.1633627547681; Thu, 07 Oct 2021 10:25:47 -0700 (PDT) From: Ioanna Alifieraki To: libvir-list@redhat.com, christian.ehrhardt@canonical.com, alejandro.santoyo@canonical.com Subject: [PATCH 4/4] virt-aa-helper: test: add test for new option -P Date: Thu, 7 Oct 2021 20:25:38 +0300 Message-Id: <20211007172539.25224-5-ioanna-maria.alifieraki@canonical.com> In-Reply-To: <20211007172539.25224-1-ioanna-maria.alifieraki@canonical.com> References: <20211007172539.25224-1-ioanna-maria.alifieraki@canonical.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 2 X-Mimecast-Originator: redhat.com X-ZM-MESSAGEID: 1633629777067100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Create a corrupt profile and expect to be removed after the test is run. Signed-off-by: Ioanna Alifieraki Reviewed-by: J=C3=A1n Tomko --- tests/meson.build | 1 + tests/virt-aa-helper-test | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/tests/meson.build b/tests/meson.build index dfbc2c01e2..991cfc402d 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -40,6 +40,7 @@ tests_env =3D [ 'LC_ALL=3DC', 'LIBVIRT_AUTOSTART=3D0', 'G_DEBUG=3Dfatal-warnings', + 'sysconfdir=3D@0@'.format(get_option('prefix') / get_option('sysconfdir'= )), ] =20 if use_expensive_tests diff --git a/tests/virt-aa-helper-test b/tests/virt-aa-helper-test index 83f53acef6..135c4968b5 100755 --- a/tests/virt-aa-helper-test +++ b/tests/virt-aa-helper-test @@ -16,6 +16,7 @@ fi output=3D"/dev/null" use_valgrind=3D"" ld_library_path=3D"$abs_top_builddir/src/" +profile_path=3D"$sysconfdir/apparmor.d/libvirt/" if [ ! -z "$1" ] && [ "$1" =3D "-d" ]; then output=3D"/dev/stdout" shift @@ -399,6 +400,34 @@ testme "0" "shmem doorbell" "-r -u $valid_uuid" "$test= _xml" "\"/var/lib/libvirt/ sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,,= ,g" "$template_xml"= > "$test_xml" testme "0" "shmem doorbell serverpath" "-r -u $valid_uuid" "$test_xml" "\"= /var/lib/libvirt/ivshmem_socket\"\s*rw,$" =20 +# For the next test to run apparmor needs to be installed and enabled. +# In some environments (e.g. containers) even though apparmor is +# installed, it is not enabled because securityfs is not mounted. +# In those environments this test cannot run so skip it. +# This test also needs to be run as root. +if [ `eval id -u` =3D 0 ] && [ -x "$(command -v aa-enabled)" ] && [ `eval = aa-enabled` =3D "Yes" ]; then + sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk2,g" "$template_xml" = > "$test_xml" + # Running the tests does not require libvirt to be installed. As a + # result the appropriate directories have not been created. Create= them + # now to run the test. + mkdir -p "$profile_path" + # create a corrupted profile + touch "$profile_path/$valid_uuid" + testme "0" "purge" "-r -u $valid_uuid" "$test_xml" + # All the tests are run with the --dry-run option this test is + # never going to fail because the profile is not going to be loaded. + # However, since we touch the profile if it's still here after the test + # it means that something went wrong, so make the test fail. + if [ -f "$profile_path/$valid_uuid" ]; then + echo "FAIL: failed to purge corrupted profile" >$output + echo " '$extra_args $args': " + errors=3D$(($errors + 1)) + # remove corrupted profile anyways not to interfere with + # subsequent runs of the tests. + rm "$profile_path/$valid_uuid" + fi +fi + testme "0" "help" "-h" =20 echo "" >$output --=20 2.17.1