[libvirt] [tck PATCH 3/3] Allow tests to be listed as positional arguments

Daniel P. Berrangé posted 3 patches 6 years, 8 months ago
[libvirt] [tck PATCH 3/3] Allow tests to be listed as positional arguments
Posted by Daniel P. Berrangé 6 years, 8 months ago
The -t argument accepts the path to a test file or a test directory. It
would be useful if shell wildcards could be used to specify test files,
but this doesn't work when using optional arguments.

By changing the test path(s) to be positional arguments we can easily
allow for shell wildcards.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 bin/libvirt-tck | 35 +++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/bin/libvirt-tck b/bin/libvirt-tck
index d5519dd..bd332a4 100644
--- a/bin/libvirt-tck
+++ b/bin/libvirt-tck
@@ -8,7 +8,7 @@ libvirt-tck - libvirt Technology Compatability Kit
 
 =head1 SYNOPSIS
 
- # libvirt-tck [OPTIONS]
+ # libvirt-tck [OPTIONS] [TESTS..]
 
 Run with default config, probing for URI to use
 
@@ -62,8 +62,15 @@ the default configuration file from C</etc/libvirt-tck/default.cfg>
 and will allow libvirt to probe for the hypervisor driver to
 run. If a reliably repeatable test result set is desired, it is
 recommended to always give an explicit libvirt connection URI
-to choose the driver. The following options are available when
-running the C<libvirt-tck> command
+to choose the driver.
+
+Any command line arguments that are not parsed as options will
+be considered paths to test scripts to invoke. If no paths are
+given, all tests under C</usr/share/libvirt-tck/tests> will be
+executed.
+
+The following options are available when running the C<libvirt-tck>
+command
 
 =over 4
 
@@ -98,11 +105,6 @@ networks, storage pools, etc which have a "tck" name prefix.
 User created objects whose name does not start with "tck" will be
 left untouched.
 
-=item -t, --testdir PATH
-
-Specify an alternate directory path in which to find the test
-scripts to be run. If omitted, defaults to C</usr/share/libvirt-tck/tests>
-
 =item -a, --archive FILE
 
 Generate an archive containing all the raw test results. The
@@ -144,7 +146,6 @@ my $timer = 0;
 my $archive;
 my $config = catfile($confdir, "default.cfg");
 my $format = "text";
-my $testdir = catdir($datadir, "tests");
 
 if (!GetOptions("verbose" => \$verbose,
 		"debug" => \$debug,
@@ -154,7 +155,6 @@ if (!GetOptions("verbose" => \$verbose,
 		"config=s" => \$config,
 		"force" => \$force,
 		"format=s" => \$format,
-		"testdir=s" => \$testdir,
 		"timer" => \$timer) || $help) {
     pod2usage(-verbose => $help,
 	      -output => $help ? \*STDOUT : \*STDERR,
@@ -181,12 +181,19 @@ if ($verbose && $quiet) {
 	      -output => \*STDERR);
 }
 
-unless (-e $testdir) {
-    print STDERR "$0: test directory '$testdir' does not exist\n";
-    exit 2;
+my @testdirs = @ARGV;
+unless (@testdirs) {
+    push @testdirs, catdir($datadir, "tests");
+}
+
+foreach (@testdirs) {
+    unless (-e $_) {
+	print STDERR "$0: test path '$_' does not exist\n";
+	exit 2;
+    }
 }
 
-my @newargv = ("-r", "--norc", "--merge", $testdir);
+my @newargv = ("-r", "--norc", "--merge", @testdirs);
 
 if ($archive) {
     push @newargv, "-a", $archive;
-- 
2.19.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [tck PATCH 3/3] Allow tests to be listed as positional arguments
Posted by Laine Stump 6 years, 8 months ago
On 11/2/18 11:52 AM, Daniel P. Berrangé wrote:
> The -t argument accepts the path to a test file or a test directory. It
> would be useful if shell wildcards could be used to specify test files,
> but this doesn't work when using optional arguments.
>
> By changing the test path(s) to be positional arguments we can easily
> allow for shell wildcards.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>


I don't have experience with whatever is doing the commandline parsing,
but it looks like it ought to work, and the few things I threw at it
worked as expected.


Reviewed-by: Laine Stump <laine@laine.org>


> ---
>  bin/libvirt-tck | 35 +++++++++++++++++++++--------------
>  1 file changed, 21 insertions(+), 14 deletions(-)
>
> diff --git a/bin/libvirt-tck b/bin/libvirt-tck
> index d5519dd..bd332a4 100644
> --- a/bin/libvirt-tck
> +++ b/bin/libvirt-tck
> @@ -8,7 +8,7 @@ libvirt-tck - libvirt Technology Compatability Kit
>  
>  =head1 SYNOPSIS
>  
> - # libvirt-tck [OPTIONS]
> + # libvirt-tck [OPTIONS] [TESTS..]
>  
>  Run with default config, probing for URI to use
>  
> @@ -62,8 +62,15 @@ the default configuration file from C</etc/libvirt-tck/default.cfg>
>  and will allow libvirt to probe for the hypervisor driver to
>  run. If a reliably repeatable test result set is desired, it is
>  recommended to always give an explicit libvirt connection URI
> -to choose the driver. The following options are available when
> -running the C<libvirt-tck> command
> +to choose the driver.
> +
> +Any command line arguments that are not parsed as options will
> +be considered paths to test scripts to invoke. If no paths are
> +given, all tests under C</usr/share/libvirt-tck/tests> will be
> +executed.
> +
> +The following options are available when running the C<libvirt-tck>
> +command
>  
>  =over 4
>  
> @@ -98,11 +105,6 @@ networks, storage pools, etc which have a "tck" name prefix.
>  User created objects whose name does not start with "tck" will be
>  left untouched.
>  
> -=item -t, --testdir PATH
> -
> -Specify an alternate directory path in which to find the test
> -scripts to be run. If omitted, defaults to C</usr/share/libvirt-tck/tests>
> -
>  =item -a, --archive FILE
>  
>  Generate an archive containing all the raw test results. The
> @@ -144,7 +146,6 @@ my $timer = 0;
>  my $archive;
>  my $config = catfile($confdir, "default.cfg");
>  my $format = "text";
> -my $testdir = catdir($datadir, "tests");
>  
>  if (!GetOptions("verbose" => \$verbose,
>  		"debug" => \$debug,
> @@ -154,7 +155,6 @@ if (!GetOptions("verbose" => \$verbose,
>  		"config=s" => \$config,
>  		"force" => \$force,
>  		"format=s" => \$format,
> -		"testdir=s" => \$testdir,
>  		"timer" => \$timer) || $help) {
>      pod2usage(-verbose => $help,
>  	      -output => $help ? \*STDOUT : \*STDERR,
> @@ -181,12 +181,19 @@ if ($verbose && $quiet) {
>  	      -output => \*STDERR);
>  }
>  
> -unless (-e $testdir) {
> -    print STDERR "$0: test directory '$testdir' does not exist\n";
> -    exit 2;
> +my @testdirs = @ARGV;
> +unless (@testdirs) {
> +    push @testdirs, catdir($datadir, "tests");
> +}
> +
> +foreach (@testdirs) {
> +    unless (-e $_) {
> +	print STDERR "$0: test path '$_' does not exist\n";
> +	exit 2;
> +    }
>  }
>  
> -my @newargv = ("-r", "--norc", "--merge", $testdir);
> +my @newargv = ("-r", "--norc", "--merge", @testdirs);
>  
>  if ($archive) {
>      push @newargv, "-a", $archive;


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