From 9bedfcd209e1071bd8ba7268fb2b5a5d9b7499aa Mon Sep 17 00:00:00 2001 From: Yong Sun Date: Wed, 16 Oct 2024 18:27:22 +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 | 10 ++++------ tests/xfstests/run_subtest.pm | 8 +++++++- 4 files changed, 38 insertions(+), 21 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 f6ece5afa230..3bdff8e2116f 100644 --- a/tests/xfstests/partition.pm +++ b/tests/xfstests/partition.pm @@ -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 { @@ -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 { diff --git a/tests/xfstests/run.pm b/tests/xfstests/run.pm index 1c0a53a7b8e5..5b09400d45c9 100644 --- a/tests/xfstests/run.pm +++ b/tests/xfstests/run.pm @@ -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'; @@ -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; @@ -159,7 +154,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 971776780133..5571c2c1081b 100644 --- a/tests/xfstests/run_subtest.pm +++ b/tests/xfstests/run_subtest.pm @@ -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}; @@ -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;