From b9004f8f3d2901f177a3f13860a9d1bfaab41803 Mon Sep 17 00:00:00 2001 From: Yong Sun Date: Wed, 16 Oct 2024 16:11:09 +0800 Subject: [PATCH] xfstests: Fix match grub failed after reset - 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. --- lib/xfstests_utils.pm | 35 +++++++++++++++++++++-------------- tests/xfstests/partition.pm | 6 ++++++ tests/xfstests/run.pm | 5 ++++- tests/xfstests/run_subtest.pm | 8 +++++++- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/lib/xfstests_utils.pm b/lib/xfstests_utils.pm index 81c347bc466c..15edd6510800 100644 --- a/lib/xfstests_utils.pm +++ b/lib/xfstests_utils.pm @@ -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 = < /sys/fs/$fstype/stats/stats <==" > $LOG_DIR/$category/$num.fs_stat @@ -489,7 +492,11 @@ END_CMD tail -n +1 /sys/fs/$fstype/*/* >> $LOG_DIR/$category/$num.fs_stat END_CMD } - $cmd = < /dev/null [ -n "\$SCRATCH_DEV" ] && umount \$SCRATCH_DEV &> /dev/null END_CMD @@ -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); } } @@ -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)) { @@ -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 diff --git a/tests/xfstests/partition.pm b/tests/xfstests/partition.pm index 5c58e71dd05c..bc96eca5a996 100644 --- a/tests/xfstests/partition.pm +++ b/tests/xfstests/partition.pm @@ -36,6 +36,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 { @@ -458,6 +459,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 { diff --git a/tests/xfstests/run.pm b/tests/xfstests/run.pm index 8e290f7d15f8..78e54f18ecb0 100644 --- a/tests/xfstests/run.pm +++ b/tests/xfstests/run.pm @@ -158,7 +158,10 @@ sub run { } sub test_flags { - return {fatal => 0}; + return { + fatal => 1, + milestone => 1, + }; } sub post_fail_hook { diff --git a/tests/xfstests/run_subtest.pm b/tests/xfstests/run_subtest.pm index c7bac5d2568f..3b0709627562 100644 --- a/tests/xfstests/run_subtest.pm +++ b/tests/xfstests/run_subtest.pm @@ -77,6 +77,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}; @@ -186,7 +187,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;