Skip to content

Commit

Permalink
LTP: Allow to reboot after each test
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
pevik committed Nov 29, 2024
1 parent 6abd554 commit a0cf8a4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/LTP/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<name> <command> [<args>...] [#<comment>]"
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/)) {
Expand Down
31 changes: 30 additions & 1 deletion tests/kernel/run_ltp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -500,5 +525,9 @@ C<tcpdump>: Capture all packets sent or received during each test.
C<crashdump>: Save kernel crashdump on test timeout.
C<tasktrace>: 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

0 comments on commit a0cf8a4

Please sign in to comment.