Skip to content

Commit

Permalink
xfstests: Fix match grub failed after reset
Browse files Browse the repository at this point in the history
- After reset if directly goes into login page will no need to wait to
match grub page in wait_boot.
- Remove /tmp before copy_log and reboot, to solve no-space-left error
to make reboot signal can't success.
- To fix poo#167347, copy_all_log part will not umount and mount if test
in unstable status and in nfs test.
- Add milestone in run.pm as snapshot rollback point.
  • Loading branch information
SeroSun committed Oct 16, 2024
1 parent 6c0f17f commit 9bedfcd
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 21 deletions.
35 changes: 21 additions & 14 deletions lib/xfstests_utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,13 @@ Log: Collect fs runtime status for XFS, Btrfs and Ext4
=cut

sub collect_fs_status {
my ($category, $num, $fstype) = @_;
my ($category, $num, $fstype, $is_crash) = @_;
return if $is_crash;
my $cmd;
script_run('mount $TEST_DEV $TEST_DIR &> /dev/null');
script_run("[ -n \"\$SCRATCH_DEV\" ] && mount \$SCRATCH_DEV $SCRATCH_FOLDER &> /dev/null");
unless ($fstype eq 'nfs') {
script_run('mount $TEST_DEV $TEST_DIR &> /dev/null');
script_run("[ -n \"\$SCRATCH_DEV\" ] && mount \$SCRATCH_DEV $SCRATCH_FOLDER &> /dev/null");
}
if ($fstype eq 'xfs') {
$cmd = <<END_CMD;
echo "==> /sys/fs/$fstype/stats/stats <==" > $LOG_DIR/$category/$num.fs_stat
Expand All @@ -489,7 +492,11 @@ END_CMD
tail -n +1 /sys/fs/$fstype/*/* >> $LOG_DIR/$category/$num.fs_stat
END_CMD
}
$cmd = <<END_CMD;
elsif ($fstype eq 'nfs') {
enter_cmd("$cmd");
return;
}
$cmd .= <<END_CMD;
umount \$TEST_DEV &> /dev/null
[ -n "\$SCRATCH_DEV" ] && umount \$SCRATCH_DEV &> /dev/null
END_CMD
Expand All @@ -503,12 +510,12 @@ Add all above logs
=cut

sub copy_all_log {
my ($category, $num, $fstype, $btrfs_dump, $raw_dump, $scratch_dev, $scratch_dev_pool) = @_;
my ($category, $num, $fstype, $btrfs_dump, $raw_dump, $scratch_dev, $scratch_dev_pool, $is_crash) = @_;
copy_log($category, $num, 'out.bad');
copy_log($category, $num, 'full');
copy_log($category, $num, 'dmesg');
copy_fsxops($category, $num);
collect_fs_status($category, $num, $fstype);
collect_fs_status($category, $num, $fstype, $is_crash);
if ($btrfs_dump && (check_var 'XFSTESTS', 'btrfs')) { dump_btrfs_img($category, $num, $btrfs_dump); }
if ($raw_dump) { raw_dump($category, $num, $scratch_dev, $scratch_dev_pool); }
}
Expand Down Expand Up @@ -590,16 +597,16 @@ sub test_run_without_heartbeat {
if ($@) {
$test_status = 'FAILED';
$test_duration = time() - $test_start;
sleep(2);
copy_all_log($category, $num, $fstype, $btrfs_dump, $raw_dump, $scratch_dev, $scratch_dev_pool);
script_run('rm -rf /tmp/*'); # Get some space and inode for no-space-left-on-device error to get reboot signal
sleep 2;
copy_all_log($category, $num, $fstype, $btrfs_dump, $raw_dump, $scratch_dev, $scratch_dev_pool, 1);

prepare_system_shutdown;
($virtio_console == 1) ? power('reset') : send_key 'alt-sysrq-b';
reset_consoles if check_var('DESKTOP', 'textmode');
($virtio_console == 1) ? power_action('reboot') : send_key 'alt-sysrq-b';
reconnect_mgmt_console if is_pvm;
$self->wait_boot;

sleep 1;
select_console('root-console');
check_var('DESKTOP', 'textmode') ? $self->wait_boot_textmode : $self->wait_boot;
is_public_cloud() ? select_console('root-console') : select_serial_terminal();
# Save kdump data to KDUMP_DIR if not set "NO_KDUMP=1"
if ($enable_kdump) {
unless (save_kdump($test, $KDUMP_DIR, vmcore => 1, kernel => 1, debug => 1)) {
Expand All @@ -623,7 +630,7 @@ sub test_run_without_heartbeat {
}
else {
$test_status = 'FAILED';
copy_all_log($category, $num, $fstype, $btrfs_dump, $raw_dump, $scratch_dev, $scratch_dev_pool);
copy_all_log($category, $num, $fstype, $btrfs_dump, $raw_dump, $scratch_dev, $scratch_dev_pool, 0);
}
}
# Add test status to STATUS_LOG file
Expand Down
6 changes: 6 additions & 0 deletions tests/xfstests/partition.pm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ my $NFS_VERSION = get_var('XFSTESTS_NFS_VERSION', '4.1');
my $NFS_SERVER_IP;
my $TEST_FOLDER = '/opt/test';
my $SCRATCH_FOLDER = '/opt/scratch';
my $TEST_WRAPPER = '/opt/wrapper.sh';

# Number of SCRATCH disk in SCRATCH_DEV_POOL, other than btrfs has only 1 SCRATCH_DEV, xfstests specific
sub partition_amount_by_homesize {
Expand Down Expand Up @@ -459,6 +460,11 @@ sub run {
if (!get_var('XFSTESTS_NFS_SERVER')) {
set_config;
}

# Get wrapper
assert_script_run("curl -o $TEST_WRAPPER " . data_url('xfstests/wrapper.sh'));
assert_script_run("chmod a+x $TEST_WRAPPER");

}

sub test_flags {
Expand Down
10 changes: 4 additions & 6 deletions tests/xfstests/run.pm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ use lockapi;
# - XFSTESTS_SUBTEST_MAXTIME: Debug use. To set the max time to wait for sub test to finish. Meet this time frame will trigger reboot, and continue next tests.
# - XFSTESTS: TEST_DEV type, and test in this folder and generic/ folder will be triggered. XFSTESTS=(xfs|btrfs|ext4)
my $TEST_RANGES = get_required_var('XFSTESTS_RANGES');
my $TEST_WRAPPER = '/opt/wrapper.sh';
my $BLACKLIST = get_var('XFSTESTS_BLACKLIST');
my $GROUPLIST = get_var('XFSTESTS_GROUPLIST');
my $STATUS_LOG = '/opt/status.log';
Expand Down Expand Up @@ -97,10 +96,6 @@ sub run {
# Load whitelist environment
my $whitelist_env = prepare_whitelist_environment();

# Get wrapper
assert_script_run("curl -o $TEST_WRAPPER " . data_url('xfstests/wrapper.sh'));
assert_script_run("chmod a+x $TEST_WRAPPER");

# Get test list
my @tests = tests_from_ranges($TEST_RANGES, $INST_DIR);
my %uniq;
Expand Down Expand Up @@ -159,7 +154,10 @@ sub run {
}

sub test_flags {
return {fatal => 0};
return {
fatal => 1,
milestone => 1,
};
}

sub post_fail_hook {
Expand Down
8 changes: 7 additions & 1 deletion tests/xfstests/run_subtest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ my %softfail_list = generate_xfstests_list(get_var('XFSTESTS_SOFTFAIL'));

sub run {
my ($self, $args) = @_;
select_serial_terminal;
(my $test = $args->{name}) =~ s/-/\//;
my $enable_heartbeat = $args->{enable_heartbeat};
my $is_last_one = $args->{last_one};
Expand Down Expand Up @@ -187,7 +188,12 @@ sub test_flags {
}

sub post_fail_hook {
return;
my ($self, $msg) = @_;
$self->get_new_serial_output();
$self->fail_if_running();
if ($msg =~ qr/died/) {
die $msg . "\n";
}
}

1;

0 comments on commit 9bedfcd

Please sign in to comment.