All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Anthony PERARD <anthony.perard@citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: [OSSTEST PATCH v12 18/21] TestSupport: Implement target_cmd_subunit a subunit stream parser into substeps
Date: Wed, 12 Jul 2017 16:05:05 +0100	[thread overview]
Message-ID: <20170712150508.24461-19-anthony.perard@citrix.com> (raw)
In-Reply-To: <20170712150508.24461-1-anthony.perard@citrix.com>

target_cmd_subunit can be used like target_cmd, but the command would
needs to output a subunit v1 stream, which will be parsed and turned
into osstest substeps. The command can be `| subunit-2to1` in order to
turn a subunit v2 stream into v1.

Currently, time is not taken into account, and all substeps will have
bogus timestamp as the output of the command is parsed after it has
runned.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 Osstest/TestSupport.pm | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 7215156..f3174d2 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -55,6 +55,7 @@ BEGIN {
 
                       target_cmd_root_status target_cmd_output_root_status
                       target_cmd_root target_cmd target_cmd_build
+                      target_cmd_subunit
                       target_cmd_output_root target_cmd_output
                       target_cmd_inputfh_root sshuho
                       target_getfile target_getfile_root
@@ -737,6 +738,48 @@ sub target_cmd_root ($$;$$) { tcmd(undef,undef,0, 'root',@_); }
 # Instead, returns the wait status (ie, what came in $?)
 sub target_cmd_root_status ($$;$$) { tcmd(undef,undef,1, 'root',@_); }
 
+sub subunit_result_to_osstest_result ($) {
+    my ($ret) = @_;
+    return "pass" if $ret eq "success" or $ret eq "successful";
+    return "fail" if $ret eq "failure";
+    return "skip" if $ret eq "skip";
+    return "fail" if $ret eq "error";
+}
+sub subunit_sanitize ($) {
+    my ($testname) = @_;
+    $testname =~ s/ /_/g;
+    return $testname;
+}
+
+sub target_cmd_subunit ($$;$$) {
+    my $stdout = IO::File::new_tmpfile();
+    my $rc = tcmd(undef,$stdout,0, 'osstest', @_);
+    $stdout->seek(0,0) or die "$stdout $!";
+    my $logfilename = undef;
+    my $fh = undef;
+
+    while (<$stdout>) {
+        if (/^time: (\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)(\.\d+)?Z$/) {
+            # This is the timestamp for the next events
+        } elsif (/^test: (.+)\n/) {
+            $logfilename = subunit_sanitize($1) . '.log';
+            $fh = open_unique_stashfile(\$logfilename);
+            substep_start(subunit_sanitize($1), $logfilename);
+        } elsif (/^(success(ful)?|failure|skip|error): (.+?)( \[( multipart)?)?$/) {
+            if ($4) {
+                my $test_output = "";
+                while (<$stdout>) {
+                    last if (/^\]$/);
+                    $test_output .= $_;
+                }
+                print $fh $test_output or die $!;
+            }
+            close $fh or die $!;
+            substep_finish(subunit_sanitize($3), subunit_result_to_osstest_result($1));
+        }
+    }
+}
+
 sub tcmdout {
     my $stdout= IO::File::new_tmpfile();
     my $badstatusok = $_[1];
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-07-12 15:17 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-12 15:04 [OSSTEST PATCH v12 00/21] Have OpenStack tested on top of xen's master and libvirt's master Anthony PERARD
2017-07-12 15:04 ` [OSSTEST PATCH v12 01/21] ts-openstack-deploy: Deploy OpenStack on a host with devstack Anthony PERARD
2017-07-12 15:04 ` [OSSTEST PATCH v12 02/21] ts-openstack-tempest: Run Tempest to check OpenStack Anthony PERARD
2017-07-12 15:04 ` [OSSTEST PATCH v12 03/21] ts-openstack-deploy: Set http proxy Anthony PERARD
2017-07-12 15:04 ` [OSSTEST PATCH v12 04/21] TestSupport: provide target_https_mitm_proxy_cert_path Anthony PERARD
2017-07-12 15:04 ` [OSSTEST PATCH v12 05/21] ts-openstack-deploy: set CURL_CA_BUNDLE Anthony PERARD
2017-07-12 15:04 ` [OSSTEST PATCH v12 06/21] ts-openstack-deploy: Keep CURL_CA_BUNDLE when sudo is called Anthony PERARD
2017-07-12 15:04 ` [OSSTEST PATCH v12 07/21] ts-openstack-deploy: Try to disable use of SYSTEMD Anthony PERARD
2017-07-12 15:04 ` [OSSTEST PATCH v12 08/21] ts-kernel-build: Enable network related modules for Neutron Anthony PERARD
2017-07-12 15:04 ` [OSSTEST PATCH v12 09/21] ts-openstack-deploy: Switch to Neutron for network Anthony PERARD
2017-07-12 15:04 ` [OSSTEST PATCH v12 10/21] ts-openstack-deploy: Increase open fd limit for RabbitMQ Anthony PERARD
2017-07-19 10:28   ` Ian Jackson
2017-07-19 11:08     ` Anthony PERARD
2017-07-19 13:05       ` Ian Jackson
2017-07-19 13:25         ` Anthony PERARD
2017-07-19 13:38           ` Ian Jackson
2017-07-12 15:04 ` [OSSTEST PATCH v12 11/21] ts-openstack-deploy: Apply a Tempest patch Anthony PERARD
2017-07-12 15:04 ` [OSSTEST PATCH v12 12/21] ts-openstack-deploy: Ignore libvirt-python version and use latest Anthony PERARD
2017-07-12 15:05 ` [OSSTEST PATCH v12 13/21] ts-openstack-tempest: Fix tempest invocation Anthony PERARD
2017-07-12 15:05 ` [OSSTEST PATCH v12 14/21] ts-openstack-tempest: Update list of skipped tests Anthony PERARD
2017-07-19 10:29   ` Ian Jackson
2017-07-12 15:05 ` [OSSTEST PATCH v12 15/21] ts-openstack-deploy: Move logs to /var/log/openstack Anthony PERARD
2017-07-12 15:05 ` [OSSTEST PATCH v12 16/21] ts-logs-capture: Capture OpenStack logs Anthony PERARD
2017-07-12 15:05 ` [OSSTEST PATCH v12 17/21] ts-openstack-deploy: Increase devstack timeout Anthony PERARD
2017-07-12 15:05 ` Anthony PERARD [this message]
2017-07-13 13:28   ` [OSSTEST PATCH v12 18/21] TestSupport: Implement target_cmd_subunit a subunit stream parser into substeps Ian Jackson
2017-07-13 14:43     ` Anthony PERARD
2017-07-13 18:11       ` Anthony PERARD
2017-07-17 17:12         ` Ian Jackson
2017-07-17 17:06       ` Ian Jackson
2017-07-12 15:05 ` [OSSTEST PATCH v12 19/21] ts-openstack-tempest: Use target_cmd_subunit Anthony PERARD
2017-07-13 13:28   ` Ian Jackson
2017-07-12 15:05 ` [OSSTEST PATCH v12 20/21] Create a flight to test OpenStack with xen-unstable and libvirt Anthony PERARD
2017-07-19 12:56   ` Ian Jackson
2017-07-20 17:36     ` Anthony PERARD
2017-07-12 15:05 ` [OSSTEST PATCH v12 21/21] make-flight: Increase dom0_mem for openstack flight Anthony PERARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170712150508.24461-19-anthony.perard@citrix.com \
    --to=anthony.perard@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.