From nobody Sun Feb 8 08:13:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594894487; cv=none; d=zohomail.com; s=zohoarc; b=muHtXZXie46/T45DokSI9MaACWvRJ6uIT2/sWuPvvdrTuzz/g7w1zONGLvfl0aNZSxYeSob6ecOazQtFLxeWNuLMPFNB/31BrbFX6LnOr0IB5dBhJQaMe4OByh1Pstx0b9xCyjMOlpNTw8BPJ6hxVBmubVxbndVujQpVoIztzo0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594894487; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pojoJJEdTP9K1cjSJtHIjKwiDa7dpp3EgOi4WHEboj4=; b=XVpPxiNy418PW8AxmfFbd/G81xInad7D53RkoEjbOi6yD1H9CWcGn3GOp+PTzZE4+SaUVZeqqGKGjTifufQYE9qflMLGaKZuzuQWIZ8VnBiKP9jUOwhPPj4W0CEdnwewpmjE2/eT4HcmgVMMF0p0b8hdaaT5Qs/wtlcScmMWhnY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1594894487739879.9180693989673; Thu, 16 Jul 2020 03:14:47 -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-65-ofgsR9zLO2G7oudN66vqAA-1; Thu, 16 Jul 2020 06:14:44 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6168A8015F4; Thu, 16 Jul 2020 10:14:39 +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 4249E5FC2C; Thu, 16 Jul 2020 10:14:39 +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 10A6F9A30F; Thu, 16 Jul 2020 10:14:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06GA7GFd020503 for ; Thu, 16 Jul 2020 06:07:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6BA832DE6D; Thu, 16 Jul 2020 10:07:16 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.194.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id DABCD2DE69 for ; Thu, 16 Jul 2020 10:07:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594894486; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=pojoJJEdTP9K1cjSJtHIjKwiDa7dpp3EgOi4WHEboj4=; b=Txfq+59ey77uTa9HD/ZZtZ0ylE/QdkJhgdGxS7aS5Cpw9juHyda2NJR4Vu5rqeVGwteXUT 6LufCW64Isqb8XAm0CowHUlfISKocXbGPoQon6VG3uhwDfszdPSI+QF9zlGZlONteiG6nd ZMufe0qUtUHyfhVPO3xY9teeMJkqH+E= X-MC-Unique: ofgsR9zLO2G7oudN66vqAA-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 312/351] meson: tests: add file access test setup Date: Thu, 16 Jul 2020 11:59:08 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We need to modify check-file-access.py to be usable as wrapper for libvirt tests. This way we can run the tests using this command: meson test --setup access which will run all tests using check-file-access.py as a wrapper. With autotools all file access are written into single file for all tests and compared once the whole test suite is done. With Meson we will compare the file access after every single test because it is used as wrapper now. That requires writing the file access into separate files for every single test as they are executed in parallel. Since the wrapper is used for all tests in Meson including tests outside of tests directory we have to check for presence of the output file. We should also cleanup after ourselves. Signed-off-by: Pavel Hrdina --- Makefile.am | 3 --- scripts/check-file-access.py | 24 +++++++++++++++++++----- tests/Makefile.am | 12 ------------ tests/meson.build | 8 ++++++++ tests/virtestmock.c | 2 +- 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/Makefile.am b/Makefile.am index 363c5cf66fd..d05a0c1a85a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,9 +37,6 @@ srpm: clean =20 check-local: all tests =20 -check-access: all - @($(MAKE) $(AM_MAKEFLAGS) -C tests check-access) - dist-hook: gen-AUTHORS =20 .PHONY: gen-AUTHORS diff --git a/scripts/check-file-access.py b/scripts/check-file-access.py index aa120cafacf..f0e98f4b652 100755 --- a/scripts/check-file-access.py +++ b/scripts/check-file-access.py @@ -21,15 +21,27 @@ # # =20 +import os +import random import re +import string import sys =20 -if len(sys.argv) !=3D 3: - print("syntax: %s ACCESS-FILE PERMITTED-ACCESS-FILE") - sys.exit(1) +abs_builddir =3D os.environ.get('abs_builddir', '') +abs_srcdir =3D os.environ.get('abs_srcdir', '') =20 -access_file =3D sys.argv[1] -permitted_file =3D sys.argv[2] +filename =3D ''.join(random.choice(string.ascii_letters) for _ in range(16= )) +access_file =3D os.path.join(abs_builddir, 'file-access-{0}.txt'.format(fi= lename)) +permitted_file =3D os.path.join(abs_srcdir, 'permitted_file_access.txt') + +os.environ['VIR_TEST_FILE_ACCESS_OUTPUT'] =3D access_file + +test =3D ' '.join(sys.argv[1:]) + +ret =3D os.system(test) + +if ret !=3D 0 or not os.is_file(access_file): + sys.exit(ret) =20 known_actions =3D ["open", "fopen", "access", "stat", "lstat", "connect"] =20 @@ -120,6 +132,8 @@ for file in files: print(": %s" % file["testname"], end=3D"") print("") =20 +os.remove(access_file) + if err: sys.exit(1) sys.exit(0) diff --git a/tests/Makefile.am b/tests/Makefile.am index 641ed7b390b..04c37ccda2e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -16,18 +16,6 @@ ## License along with this library. If not, see ## . =20 -if WITH_LINUX -check-access: file-access-clean - VIR_TEST_FILE_ACCESS=3D1 $(MAKE) $(AM_MAKEFLAGS) check - $(RUNUTF8) $(PYTHON) $(top_srcdir)/scripts/check-file-access.py \ - $(abs_builddir)/test_file_access.txt \ - $(abs_srcdir)/permitted_file_access.txt | sort -u - -file-access-clean: - > test_file_access.txt -endif WITH_LINUX - - VALGRIND =3D valgrind --quiet --leak-check=3Dfull --trace-children=3Dyes \ --trace-children-skip=3D"*/tools/virsh","*/tests/commandhelper","/usr/bin= /*" \ --suppressions=3D$(abs_srcdir)/.valgrind.supp diff --git a/tests/meson.build b/tests/meson.build index d6e0d2805d7..cf848678505 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -665,3 +665,11 @@ foreach name : test_scripts script =3D find_program(name) test(name, script, env: tests_env) endforeach + +add_test_setup( + 'access', + env: [ + 'VIR_TEST_FILE_ACCESS=3D1', + ], + exe_wrapper: [ meson_python_prog, check_file_access_prog ], +) diff --git a/tests/virtestmock.c b/tests/virtestmock.c index e5dccae2a87..776493f0c5d 100644 --- a/tests/virtestmock.c +++ b/tests/virtestmock.c @@ -69,7 +69,7 @@ printFile(const char *file, output =3D VIR_FILE_ACCESS_DEFAULT; } =20 - if (!(fp =3D real_fopen(output, "a"))) { + if (!(fp =3D real_fopen(output, "w"))) { fprintf(stderr, "Unable to open %s: %s\n", output, g_strerror(errn= o)); abort(); } --=20 2.26.2