Skip to content

Commit

Permalink
Merge pull request #20267 from lansuse/master
Browse files Browse the repository at this point in the history
xfstests: update dump_btrfs_img() in lib util
  • Loading branch information
SeroSun authored Sep 25, 2024
2 parents bffa5fe + 7a36b61 commit 37b8d63
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions lib/xfstests_utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,8 @@ Log: Only run in test Btrfs, collect image dump for inconsistent error
=cut

sub dump_btrfs_img {
my ($category, $num) = @_;
my $cmd = "echo \"no inconsistent error, skip btrfs image dump\"";
my $ret = script_output("grep -E -m 1 \"filesystem on .+ is inconsistent\" $LOG_DIR/$category/$num");
if ($ret =~ /filesystem on (.+) is inconsistent/) { $cmd = "umount $1;btrfs-image $1 $LOG_DIR/$category/$num.img"; }
my ($category, $num, $dev) = @_;
my $cmd = "umount $dev; btrfs-image $dev $LOG_DIR/$category/$num.img";
script_run($cmd);
}

Expand Down Expand Up @@ -511,7 +509,7 @@ sub copy_all_log {
copy_log($category, $num, 'dmesg');
copy_fsxops($category, $num);
collect_fs_status($category, $num, $fstype);
if (($btrfs_dump) && ($fstype == 'btrfs')) { dump_btrfs_img($category, $num); }
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
2 changes: 1 addition & 1 deletion tests/xfstests/run_subtest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ my $LOOP_DEVICE = get_var('XFSTESTS_LOOP_DEVICE');

# Debug variables
# - INJECT_INFO: inject a line or more line into xfstests subtests for debugging.
# - BTRFS_DUMP: set it a non-zero value to enable btrfs dump.
# - BTRFS_DUMP: enable btrfs dump, value=<device name>. e.g /dev/loop0
# - RAW_DUMP: set it a non-zero value to enable raw dump by dd the super block.
# - XFSTESTS_DEBUG: enable collect more info by set 1 to files under /proc/sys/kernel/, more than 1 info split by space
# e.g. "hardlockup_panic hung_task_panic panic_on_io_nmi panic_on_oops panic_on_rcu_stall..."
Expand Down
2 changes: 1 addition & 1 deletion variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ Debug setting: advance setting to debugging issues, may cause test fail
Variable | Type | Default value | Details
--- | --- | --- | ---
XFSTESTS_DEBUG | string | | set it to enable debug tools under /proc/sys/kernel/. The value of XFSTESTS_DEBUG could be one or more parameters in the following: [hardlockup_panic hung_task_panic panic_on_io_nmi panic_on_oops panic_on_rcu_stall...] Collect more than 1 value at a time could use <space> to split it. e.g. XFSTESTS_DEBUG='hardlockup_panic panic_on_oops'. BTW, the softlockup_all_cpu_backtrace and softlockup_panic are default enabled
BTRFS_DUMP | boolean | 0 | set BTRFS_DUMP=1 to collect btrfs dump image. It uses btrfs-image create/restore an image of the filesystem
BTRFS_DUMP | boolean | 0 | set BTRFS_DUMP=<device name> to collect btrfs dump image. It uses btrfs-image create/restore an image of the filesystem. e.g BTRFS_DUMP=/dev/loop0
RAW_DUMP | boolean | 0 | set RAW_DUMP=1 to collect raw dump. It uses dd to collect start 512k info to dump the superblock of SCRATCH_DEV or SCRATCH_DEV_POOL
INJECT_INFO | string | | Add 1 or several lines of code into xfstests level test script(not in openqa script). To add some debug or log collect info. This code will be used by the test wrapper, it will influence all subtests in this test, so better to only use it in debug and set XFSTESTS_RANGES to the subtest you want to. It contains 2 parameters split by space, the format: '<line-number><space><code>'. Beware the output may not match after injection, and better not to add space in the <code> part to avoid mistakes. e.g. INJECT_INFO='49 free' (to check memory in test code line 49)
INJECT_INFO='<line-number> xtrace | string | | A special inject code is to set xtrace to debug shell script. Set INJECT_INFO='<line-number> xtrace' to openqa configure to enable it and start to record command start after injecting line <line-number>, and redirect debug info to /opt/log/xxx_xtrace.log

0 comments on commit 37b8d63

Please sign in to comment.