From a0cf8a42ed821f1cb9c6ab348228ae9463ede55f Mon Sep 17 00:00:00 2001 From: Petr Vorel Date: Thu, 22 Jun 2023 12:25:32 +0200 Subject: [PATCH] LTP: Allow to reboot after each test Add LTP_REBOOT_AFTER_TEST to allow to reboot after each test. This will be used for IMA testing (ltp_ima_reboot). Link: poo#159045 Signed-off-by: Petr Vorel --- lib/LTP/utils.pm | 6 +++++- tests/kernel/run_ltp.pm | 31 ++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/LTP/utils.pm b/lib/LTP/utils.pm index 2abccd008e25..cf4354afc2eb 100644 --- a/lib/LTP/utils.pm +++ b/lib/LTP/utils.pm @@ -404,14 +404,18 @@ sub parse_openposix_runfile { sub parse_runtest_file { my ($name, $cmds, $cmd_pattern, $cmd_exclude, $test_result_export, $suffix) = @_; my $whitelist = LTP::WhiteList->new(); + my $i = 0; for my $line (@$cmds) { + my $last = 0; + $i++; + $last = 1 if ($i == @$cmds); next if ($line =~ /(^#)|(^$)/); #Command format is " [...] [#]" next if ($line !~ /^\s* ([\w-]+) \s+ (\S.+) #?/gx); next if (is_svirt && ($1 eq 'dnsmasq' || $1 eq 'dhcpd')); # poo#33850 - my $test = {name => $1 . $suffix, command => $2}; + my $test = {name => $1 . $suffix, command => $2, last => $last}; my $tinfo = testinfo($test_result_export, test => $test, runfile => $name); if ($test->{name} =~ m/$cmd_pattern/ && !($test->{name} =~ m/$cmd_exclude/)) { diff --git a/tests/kernel/run_ltp.pm b/tests/kernel/run_ltp.pm index 88949d900c72..2c9ea3a6fb3b 100644 --- a/tests/kernel/run_ltp.pm +++ b/tests/kernel/run_ltp.pm @@ -11,15 +11,33 @@ use 5.018; use warnings; use base 'opensusebasetest'; use testapi qw(is_serial_terminal :DEFAULT); +use serial_terminal 'select_serial_terminal'; +use power_action_utils 'power_action'; use utils; use version_utils 'is_sle'; use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC); +use Utils::Backends qw(is_pvm); use serial_terminal; use Mojo::File 'path'; use Mojo::JSON; +use LTP::utils 'prepare_ltp_env'; use LTP::WhiteList; require bmwqemu; +# FIXME: debug +use Data::Dumper; + +sub do_reboot { + my $self = shift; + + record_info("reboot"); + power_action('reboot', textmode => 1, keepconsole => is_pvm); + reconnect_mgmt_console if is_pvm; + $self->wait_boot; + select_serial_terminal; + prepare_ltp_env; +} + sub start_result { my ($self, $file_name, $title) = @_; my $result = { @@ -400,6 +418,13 @@ sub run { } script_run('vmstat -w'); + + record_info("l2: " . $test->{i}, "last: '" . $test->{last} . "', i: '" . $test->{i} . "'"); + record_info("...", "fail: '" . $result_export->{fail} . "', brok: '" . $result_export->{brok} . "', tconf: '" . $result_export->{conf} . "', retval: '" . $env{retval} . "' test result: '" . $test->{result} . "', status: '" . $test->{status} . "'"); + record_info("result_export: ", Dumper($result_export)); + record_info("test: ", Dumper($test)); + record_info("env: ", Dumper($test_result_export)); + $self->do_reboot if (get_var('LTP_REBOOT_AFTER_TEST') && !$test->{last}); } # Only propogate death don't create it from failure [2] @@ -500,5 +525,9 @@ C: Capture all packets sent or received during each test. C: Save kernel crashdump on test timeout. C: Print backtrace of all processes and show blocked tasks -=cut +=head2 LTP_REBOOT_AFTER_TEST +Reboot SUT after each test (prolong testing significantly, but for some tests +may be necessary, e.g. ltp_ima_reboot). + +=cut