[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [OSSTEST PATCH v3 22/25] Introduce ts-xtf-run
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@xxxxxxxxxx> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- ts-xtf-run | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100755 ts-xtf-run diff --git a/ts-xtf-run b/ts-xtf-run new file mode 100755 index 0000000..2e69b27 --- /dev/null +++ b/ts-xtf-run @@ -0,0 +1,116 @@ +#!/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 and OSStest results mapping +sub xtf_result_to_osstest_result ($) { + my ($xret) = @_; + + return "pass" if $xret == 0; # XTF SUCCESS + return "skip" if $xret == 3; # XTF SKIP + return "fail" if $xret == 4; # XTF ERROR + return "fail" if $xret == 5; # XTF FAILURE + 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 -m logfile $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@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |