From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: ian.jackson@eu.citrix.com, Wei Liu <wei.liu2@citrix.com>
Subject: [OSSTEST PATCH RFC v2 11/14] Introduce ts-xtf-run
Date: Mon, 8 Aug 2016 10:22:43 +0100 [thread overview]
Message-ID: <1470648166-3412-12-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1470648166-3412-1-git-send-email-wei.liu2@citrix.com>
This is the main script for running XTF. It will first perform
selftest, and then run each XTF test case as a substep.
It does the following things:
1. Run self tests for individual environment and record the result.
2. Collect tests according to available environments.
3. Run the collected tests one by one.
The script may exit early if it detects the test host is down or
xtf-runner returns non-recognisable exit code.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
ts-xtf-run | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 122 insertions(+)
create mode 100755 ts-xtf-run
diff --git a/ts-xtf-run b/ts-xtf-run
new file mode 100755
index 0000000..c72ac18
--- /dev/null
+++ b/ts-xtf-run
@@ -0,0 +1,122 @@
+#!/usr/bin/perl -w
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2016 Citrix Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+use strict qw(vars);
+use Osstest;
+use POSIX;
+use Osstest::TestSupport;
+
+tsreadconfig();
+
+our $ho = selecthost('host');
+
+our $runner = "/home/xtf/xtf-runner";
+our @tests;
+our @all_environments;
+our @environments;
+
+# XTF results (runner returned numeric values) and OSStest results:
+#
+# SUCCESS(0) -> pass
+# SKIP(3) -> skip
+# ERROR(4) -> fail
+# FAILURE(5) -> fail
+#
+sub xtf_result_to_osstest_result ($) {
+ my ($xret) = @_;
+
+ return "pass" if $xret == 0;
+ return "skip" if $xret == 3;
+ return "fail" if $xret == 4;
+ return "fail" if $xret == 5;
+ die "xtf runner gave unexpected result $xret";
+}
+
+sub get_environments () {
+ my $output = target_cmd_output_root($ho, <<END);
+ $runner --list --environments
+END
+ push @all_environments, split /\n/, $output;
+}
+
+# Call the runner on one test case, generate a substep for it in final test
+# report. Return runner exit code to caller. May exit the script early if
+# things go really bad.
+sub do_one_test ($) {
+ my ($name) = @_;
+ my $tid = "xtf/$name";
+ my $cmd = "xtf-runner $name";
+ my $output;
+ my $ret;
+ my $osstest_result;
+
+ substep_start($tid, $cmd);
+
+ if (! eval {
+ $output = target_cmd_output_root($ho, <<END, 600);
+ $runner $name 1>&2; echo \$?
+END
+ $output =~ m/^(\d+)$/ or die "$output ?";
+ $ret = $1;
+
+ target_cmd_output_root($ho, 'echo ok.');
+ $osstest_result = xtf_result_to_osstest_result($ret);
+ 1;
+ }) {
+ logm("XTF test threw exception:\n$@");
+ substep_finish($tid, "fail");
+ exit 0;
+ }
+
+ logm("Test $name, XTF returned $ret -> OSSTest $osstest_result");
+ substep_finish($tid, $osstest_result);
+
+ return $ret;
+}
+
+# Run selftest for each environment, record the ones that are
+# functional to get maximum coverage.
+sub do_selftest () {
+ foreach my $e (sort @all_environments) {
+ my $output = target_cmd_output_root($ho, <<END);
+ $runner --list $e selftest
+END
+ my $ret = do_one_test($output);
+ push @environments, $e if $ret == 0;
+ }
+}
+
+sub get_tests_list () {
+ foreach my $e (sort @environments) {
+ my $output = target_cmd_output_root($ho, <<END);
+ $runner --list $e --all --host
+END
+ push @tests, split /\n/, $output;
+ }
+}
+
+sub do_all_tests () {
+ foreach my $t (sort @tests) {
+ do_one_test($t);
+ }
+}
+
+get_environments();
+do_selftest();
+get_tests_list();
+do_all_tests();
+exit 0;
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-08-08 9:47 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-08 9:22 [OSSTEST PATCH RFC v2 00/14] Integrate XTF into OSSTest Wei Liu
2016-08-08 9:22 ` [OSSTEST PATCH RFC v2 01/14] ts-xen-build: always compile in FEP support Wei Liu
2016-08-08 14:46 ` Ian Jackson
2016-08-08 9:22 ` [OSSTEST PATCH RFC v2 02/14] DO NOT APPLY ts-leak-check: sleep 5 seconds before collecting stuff Wei Liu
2016-08-08 9:22 ` [OSSTEST PATCH RFC v2 03/14] ap-common: add xtf tree Wei Liu
2016-08-08 14:46 ` Ian Jackson
2016-08-08 9:22 ` [OSSTEST PATCH RFC v2 04/14] DO NOT APPLY point xtf to my personal tree Wei Liu
2016-08-08 9:22 ` [OSSTEST PATCH RFC v2 05/14] BuildSupport: move buildcmd_stamped_logged here Wei Liu
2016-08-08 14:47 ` Ian Jackson
2016-08-08 9:22 ` [OSSTEST PATCH RFC v2 06/14] Introduce ts-xtf-build Wei Liu
2016-08-08 14:48 ` Ian Jackson
2016-08-08 9:22 ` [OSSTEST PATCH RFC v2 07/14] sg-run-job: create xtf build recipe Wei Liu
2016-08-08 9:22 ` [OSSTEST PATCH RFC v2 08/14] Introduce ts-xtf-install Wei Liu
2016-08-08 14:49 ` Ian Jackson
2016-08-08 9:22 ` [OSSTEST PATCH RFC v2 09/14] mfi-common: create xtf build job for 4.8 onwards Wei Liu
2016-08-08 14:51 ` Ian Jackson
2016-08-08 16:21 ` Wei Liu
2016-08-08 16:26 ` Andrew Cooper
2016-08-08 16:58 ` Wei Liu
2016-08-08 9:22 ` [OSSTEST PATCH RFC v2 10/14] Introduce ts-xtf-fep Wei Liu
2016-08-08 14:52 ` Ian Jackson
2016-08-08 9:22 ` Wei Liu [this message]
2016-08-08 14:55 ` [OSSTEST PATCH RFC v2 11/14] Introduce ts-xtf-run Ian Jackson
2016-08-09 8:11 ` Wei Liu
2016-08-08 16:29 ` Andrew Cooper
2016-08-08 16:56 ` Ian Jackson
2016-08-08 9:22 ` [OSSTEST PATCH RFC v2 12/14] sg-run-job: test-xtf recipe Wei Liu
2016-08-08 14:56 ` Ian Jackson
2016-08-08 9:22 ` [OSSTEST PATCH RFC v2 13/14] make-flight: create 5 xtf jobs Wei Liu
2016-08-08 14:56 ` Ian Jackson
2016-08-08 9:22 ` [OSSTEST PATCH RFC v2 14/14] Create XTF branch Wei Liu
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=1470648166-3412-12-git-send-email-wei.liu2@citrix.com \
--to=wei.liu2@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).