diff options
author | matt-fidd <[email protected]> | 2021-04-07 00:05:54 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-06 16:05:54 -0700 |
commit | a03b288cf08f39540ae1c30bc353de96912f343e (patch) | |
tree | fa0c61143de4456df20fc509650f2c6be768320d /tests | |
parent | bbcec73783c552658a4fe54de8aee110109874bc (diff) |
zfs get -p only outputs 3 columns if "clones" property is empty
get_clones_string currently returns an empty string for filesystem
snapshots which have no clones. This breaks parsable `zfs get` output as
only three columns are output, instead of 4.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Matt Fiddaman <[email protected]>
Co-authored-by: matt <[email protected]>
Closes #11837
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh | 12 | ||||
-rw-r--r-- | tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_common.kshlib | 10 |
2 files changed, 19 insertions, 3 deletions
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh index eeae5390f..3547fb76c 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh @@ -27,6 +27,7 @@ # # Copyright (c) 2016 by Delphix. All rights reserved. +# Copyright (c) 2021 Matt Fiddaman # . $STF_SUITE/tests/functional/cli_root/zfs_get/zfs_get_common.kshlib @@ -72,7 +73,8 @@ typeset all_props=("${zfs_props[@]}" \ "${zfs_props_os[@]}" \ "${userquota_props[@]}") typeset dataset=($TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \ - $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP) + $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP + $TESTPOOL/$TESTFS@$TESTSNAP1 $TESTPOOL/$TESTCLONE) typeset bookmark_props=(creation) typeset bookmark=($TESTPOOL/$TESTFS#$TESTBKMARK $TESTPOOL/$TESTVOL#$TESTBKMARK) @@ -102,6 +104,7 @@ function check_return_value if [[ $item == $p ]]; then ((found += 1)) + cols=$(echo $line | awk '{print NF}') break fi done < $TESTDIR/$TESTFILE0 @@ -109,6 +112,9 @@ function check_return_value if ((found == 0)); then log_fail "'zfs get $opt $props $dst' return " \ "error message.'$p' haven't been found." + elif [[ "$opt" == "-p" ]] && ((cols != 4)); then + log_fail "'zfs get $opt $props $dst' returned " \ + "$cols columns instead of 4." fi done @@ -123,6 +129,10 @@ log_onexit cleanup create_snapshot $TESTPOOL/$TESTFS $TESTSNAP create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP +# Create second snapshot and clone it +create_snapshot $TESTPOOL/$TESTFS $TESTSNAP1 +create_clone $TESTPOOL/$TESTFS@$TESTSNAP1 $TESTPOOL/$TESTCLONE + # Create filesystem and volume's bookmark create_bookmark $TESTPOOL/$TESTFS $TESTSNAP $TESTBKMARK create_bookmark $TESTPOOL/$TESTVOL $TESTSNAP $TESTBKMARK diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_common.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_common.kshlib index d8cb9af02..9b4eecf37 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_common.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_common.kshlib @@ -26,6 +26,7 @@ # # Copyright (c) 2016 by Delphix. All rights reserved. +# Copyright (c) 2021 Matt Fiddaman # . $STF_SUITE/include/libtest.shlib @@ -87,8 +88,8 @@ function gen_option_str # $elements $prefix $separator $counter } # -# Cleanup the volume snapshot, filesystem snapshot, volume bookmark, and -# filesystem bookmark that were created for this test case. +# Cleanup the volume snapshot, filesystem snapshots, clone, volume bookmark, +# and filesystem bookmark that were created for this test case. # function cleanup { @@ -97,6 +98,11 @@ function cleanup datasetexists $TESTPOOL/$TESTFS@$TESTSNAP && \ destroy_snapshot $TESTPOOL/$TESTFS@$TESTSNAP + datasetexists $TESTPOOL/$TESTCLONE && \ + destroy_clone $TESTPOOL/$TESTCLONE + datasetexists $TESTPOOL/$TESTFS@$TESTSNAP1 && \ + destroy_snapshot $TESTPOOL/$TESTFS@$TESTSNAP1 + bkmarkexists $TESTPOOL/$TESTVOL#$TESTBKMARK && \ destroy_bookmark $TESTPOOL/$TESTVOL#$TESTBKMARK bkmarkexists $TESTPOOL/$TESTFS#$TESTBKMARK && \ |