PageRenderTime 49ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/sys/cddl/zfs/tests/cli_root/zfs_snapshot/zfs_snapshot_007_neg.ksh

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 146 lines | 71 code | 25 blank | 50 comment | 10 complexity | b8506be21e9b65840a3902e0dbb37feb MD5 | raw file
  1. #!/usr/local/bin/ksh93 -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. # $FreeBSD$
  23. #
  24. # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
  25. # Use is subject to license terms.
  26. #
  27. # ident "@(#)zfs_snapshot_007_neg.ksh 1.1 09/05/19 SMI"
  28. #
  29. . $STF_SUITE/tests/cli_root/zfs_set/zfs_set_common.kshlib
  30. #################################################################################
  31. #
  32. # __stc_assertion_start
  33. #
  34. # ID: zfs_snapshot_007_pos
  35. #
  36. # DESCRIPTION:
  37. # 'zfs snapshot -o' cannot set properties other than user property
  38. #
  39. # STRATEGY:
  40. # 1. Create snapshot and give '-o property=value' with regular property.
  41. # 2. Verify the snapshot creation failed.
  42. #
  43. # TESTABILITY: explicit
  44. #
  45. # TEST_AUTOMATION_LEVEL: automated
  46. #
  47. # CODING_STATUS: COMPLETED (2009-04-27)
  48. #
  49. # __stc_assertion_end
  50. #
  51. ################################################################################
  52. verify_runnable "both"
  53. function cleanup
  54. {
  55. for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do
  56. typeset fssnap=$fs@snap
  57. if datasetexists $fssnap ; then
  58. log_must $ZFS destroy -rf $fssnap
  59. fi
  60. done
  61. cleanup_user_prop $TESTPOOL
  62. }
  63. function nonexist_user_prop
  64. {
  65. typeset user_prop=$1
  66. typeset dtst=$2
  67. typeset source=$(get_source $user_prop $dtst)
  68. typeset value=$(get_prop $user_prop $dtst)
  69. if [[ $source == '-' && $value == '-' ]]; then
  70. return 0
  71. else
  72. return 1
  73. fi
  74. }
  75. log_assert "'zfs snapshot -o' cannot set properties other than user property."
  76. log_onexit cleanup
  77. typeset ro_props="type used available avail creation referenced refer compressratio \
  78. mounted origin"
  79. typeset snap_ro_props="volsize recordsize recsize quota reservation reserv mountpoint \
  80. sharenfs checksum compression compress atime devices exec readonly rdonly \
  81. setuid zoned"
  82. $ZFS upgrade -v > /dev/null 2>&1
  83. if [[ $? -eq 0 ]]; then
  84. snap_ro_props="$snap_ro_props version"
  85. fi
  86. for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do
  87. typeset fssnap=$fs@snap
  88. prop_name=$(valid_user_property 10)
  89. value=$(user_property_value 16)
  90. log_must eval "$ZFS snapshot -o $prop_name='$value' $fssnap"
  91. log_must snapexists $fssnap
  92. log_mustnot nonexist_user_prop $prop_name $fssnap
  93. log_must $ZFS destroy -f $fssnap
  94. prop_name2=$(valid_user_property 10)
  95. value2=$(user_property_value 16)
  96. log_must eval "$ZFS snapshot -o $prop_name='$value' -o $prop_name2='$value2' $fssnap"
  97. log_must snapexists $fssnap
  98. log_mustnot nonexist_user_prop $prop_name $fssnap
  99. log_mustnot nonexist_user_prop $prop_name2 $fssnap
  100. log_must $ZFS destroy -f $fssnap
  101. done
  102. cleanup
  103. prop_name=$(valid_user_property 10)
  104. value=$(user_property_value 16)
  105. log_must eval "$ZFS snapshot -r -o $prop_name='$value' $TESTPOOL@snap"
  106. for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do
  107. typeset fssnap=$fs@snap
  108. log_must snapexists $fssnap
  109. log_mustnot nonexist_user_prop $prop_name $fssnap
  110. done
  111. cleanup
  112. prop_name2=$(valid_user_property 10)
  113. value2=$(user_property_value 16)
  114. log_must eval "$ZFS snapshot -r -o $prop_name='$value' -o $prop_name2='$value2' $TESTPOOL@snap"
  115. for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do
  116. typeset fssnap=$fs@snap
  117. log_must snapexists $fssnap
  118. log_mustnot nonexist_user_prop $prop_name $fssnap
  119. log_mustnot nonexist_user_prop $prop_name2 $fssnap
  120. done
  121. log_pass "'zfs snapshot -o' cannot set properties other than user property."