[libvirt] [PATCH] tests: Make check-file-access.pl accept files through argv

Michal Privoznik posted 1 patch 4 years, 4 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/c9039f20d68e6063f774e567eb5a0a4006b43930.1575468077.git.mprivozn@redhat.com
tests/Makefile.am          | 4 +++-
tests/check-file-access.pl | 8 ++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
[libvirt] [PATCH] tests: Make check-file-access.pl accept files through argv
Posted by Michal Privoznik 4 years, 4 months ago
The script needs two files to open:

  $(builddir)/test_file_access.txt, and
  $(srcdir)/file_access_whitelist.txt.

However, the script is opening the files from the $CWD which
won't work for a VPATH build. Make the script accept paths to the
files through @ARGV and tune the Makefile.am to pass them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 tests/Makefile.am          | 4 +++-
 tests/check-file-access.pl | 8 ++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index cbe8e86224..4c2856bf97 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -454,7 +454,9 @@ EXTRA_DIST += $(test_scripts)
 if WITH_LINUX
 check-access: file-access-clean
 	VIR_TEST_FILE_ACCESS=1 $(MAKE) $(AM_MAKEFLAGS) check
-	$(PERL) check-file-access.pl | sort -u
+	$(PERL) $(abs_srcdir)/check-file-access.pl \
+		$(abs_builddir)/test_file_access.txt \
+		$(abs_srcdir)/file_access_whitelist.txt | sort -u
 
 file-access-clean:
 	> test_file_access.txt
diff --git a/tests/check-file-access.pl b/tests/check-file-access.pl
index ea0b7a18a2..2926126b14 100755
--- a/tests/check-file-access.pl
+++ b/tests/check-file-access.pl
@@ -24,8 +24,12 @@
 use strict;
 use warnings;
 
-my $access_file = "test_file_access.txt";
-my $whitelist_file = "file_access_whitelist.txt";
+sub usage {
+    die "$0 access_file file_access_whitelist\n";
+}
+
+my $access_file = shift or usage();
+my $whitelist_file = shift or usage();
 
 my @known_actions = ("open", "fopen", "access", "stat", "lstat", "connect");
 
-- 
2.23.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] tests: Make check-file-access.pl accept files through argv
Posted by Daniel P. Berrangé 4 years, 4 months ago
On Wed, Dec 04, 2019 at 03:01:31PM +0100, Michal Privoznik wrote:
> The script needs two files to open:
> 
>   $(builddir)/test_file_access.txt, and
>   $(srcdir)/file_access_whitelist.txt.
> 
> However, the script is opening the files from the $CWD which
> won't work for a VPATH build. Make the script accept paths to the
> files through @ARGV and tune the Makefile.am to pass them.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  tests/Makefile.am          | 4 +++-
>  tests/check-file-access.pl | 8 ++++++--
>  2 files changed, 9 insertions(+), 3 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

This matches what i've done in the next version of the python rewrite too

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list