PageRenderTime 25ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_006_pos.ksh

http://github.com/zfsonlinux/zfs
Korn Shell | 124 lines | 64 code | 24 blank | 36 comment | 9 complexity | 36f7b1eaed841108fd542d4626d0f739 MD5 | raw file
Possible License(s): Apache-2.0, MPL-2.0-no-copyleft-exception
  1. #!/bin/ksh -p
  2. #
  3. # CDDL HEADER START
  4. #
  5. # The contents of this file are subject to the terms of the
  6. # Common Development and Distribution License (the "License").
  7. # You may not use this file except in compliance with the License.
  8. #
  9. # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10. # or http://www.opensolaris.org/os/licensing.
  11. # See the License for the specific language governing permissions
  12. # and limitations under the License.
  13. #
  14. # When distributing Covered Code, include this CDDL HEADER in each
  15. # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16. # If applicable, add the following below this CDDL HEADER, with the
  17. # fields enclosed by brackets "[]" replaced with your own identifying
  18. # information: Portions Copyright [yyyy] [name of copyright owner]
  19. #
  20. # CDDL HEADER END
  21. #
  22. #
  23. # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
  24. # Use is subject to license terms.
  25. #
  26. #
  27. # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
  28. #
  29. . $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib
  30. #
  31. # DESCRIPTION:
  32. # User property could be set via creation time by 'zfs snapshot -o'
  33. #
  34. # STRATEGY:
  35. # 1. Create snapshot and give '-o property=value'
  36. # 2. Verify the snapshot be created and user property have been set.
  37. #
  38. verify_runnable "both"
  39. function cleanup
  40. {
  41. for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL ; do
  42. typeset fssnap=$fs@snap
  43. if datasetexists $fssnap ; then
  44. log_must zfs destroy -rf $fssnap
  45. fi
  46. done
  47. cleanup_user_prop $TESTPOOL
  48. }
  49. function nonexist_user_prop
  50. {
  51. typeset user_prop=$1
  52. typeset dtst=$2
  53. typeset source=$(get_source $user_prop $dtst)
  54. typeset value=$(get_prop $user_prop $dtst)
  55. if [[ $source == '-' && $value == '-' ]]; then
  56. return 0
  57. else
  58. return 1
  59. fi
  60. }
  61. log_assert "User property could be set upon snapshot via 'zfs snapshot -o'."
  62. log_onexit cleanup
  63. typeset snap_property=
  64. for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL ; do
  65. typeset fssnap=$fs@snap
  66. prop_name=$(valid_user_property 10)
  67. value=$(user_property_value 16)
  68. log_must eval "zfs snapshot -o $prop_name='$value' $fssnap"
  69. log_must snapexists $fssnap
  70. log_mustnot nonexist_user_prop $prop_name $fssnap
  71. log_must zfs destroy -f $fssnap
  72. prop_name2=$(valid_user_property 10)
  73. value2=$(user_property_value 16)
  74. log_must eval "zfs snapshot -o $prop_name='$value' -o $prop_name2='$value2' $fssnap"
  75. log_must snapexists $fssnap
  76. log_mustnot nonexist_user_prop $prop_name $fssnap
  77. log_mustnot nonexist_user_prop $prop_name2 $fssnap
  78. done
  79. cleanup
  80. prop_name=$(valid_user_property 10)
  81. value=$(user_property_value 16)
  82. log_must eval "zfs snapshot -r -o $prop_name='$value' $TESTPOOL@snap"
  83. for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL ; do
  84. typeset fssnap=$fs@snap
  85. log_must snapexists $fssnap
  86. log_mustnot nonexist_user_prop $prop_name $fssnap
  87. log_must zfs destroy -rf $fssnap
  88. done
  89. cleanup
  90. prop_name2=$(valid_user_property 10)
  91. value2=$(user_property_value 16)
  92. log_must eval "zfs snapshot -r -o $prop_name='$value' -o $prop_name2='$value2' $TESTPOOL@snap"
  93. for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL ; do
  94. typeset fssnap=$fs@snap
  95. log_must snapexists $fssnap
  96. log_mustnot nonexist_user_prop $prop_name $fssnap
  97. log_mustnot nonexist_user_prop $prop_name2 $fssnap
  98. log_must zfs destroy -rf $fssnap
  99. done
  100. log_pass "User property could be set upon snapshot via 'zfs snapshot -o'."