PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/sys/cddl/zfs/tests/cli_root/zfs_unshare/zfs_unshare_004_neg.ksh

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 95 lines | 29 code | 13 blank | 53 comment | 5 complexity | 43ba276d72f724f360b65ed61b920e8a 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 2007 Sun Microsystems, Inc. All rights reserved.
  25. # Use is subject to license terms.
  26. #
  27. # ident "@(#)zfs_unshare_004_neg.ksh 1.3 07/10/09 SMI"
  28. #
  29. . $STF_SUITE/include/libtest.kshlib
  30. #################################################################################
  31. #
  32. # __stc_assertion_start
  33. #
  34. # ID: zfs_unshare_004_neg
  35. #
  36. # DESCRIPTION:
  37. # Verify that "zfs unshare" issue error message with badly formed parameter.
  38. #
  39. # STRATEGY:
  40. # 1. Define badly formed parameters
  41. # 2. Invoke 'zfs unshare'
  42. # 3. Verify that unshare fails and issue error message.
  43. #
  44. # TESTABILITY: explicit
  45. #
  46. # TEST_AUTOMATION_LEVEL: automated
  47. #
  48. # CODING_STATUS: COMPLETED (2005-07-18)
  49. #
  50. # __stc_assertion_end
  51. #
  52. ################################################################################
  53. verify_runnable "global"
  54. set -A opts "" "$TESTPOOL/$NONEXISTFSNAME" "$NONEEXISTMOUNTPOINT" "-?" "-1" \
  55. "-a blah" "$TESTPOOL/$TESTFS $TESTPOOL/$TESTFS1" \
  56. "-f $TESTPOOL/$TESTFS $TESTPOOL/$TESTFS1" \
  57. "$TESTPOOL/$TESTFS $TESTDIR" "-f $TESTPOOL/$TESTFS $TESTDIR" \
  58. "${TESTDIR#/}" "-f ${TESTDIR#/}"
  59. log_assert "Verify that '$ZFS unshare' issue error message with badly formed parameter."
  60. shareval=$(get_prop sharenfs $TESTPOOL/$TESTFS)
  61. if [[ $shareval == off ]]; then
  62. log_must $ZFS set sharenfs=on $TESTPOOL/$TESTFS
  63. fi
  64. typeset -i i=0
  65. while [[ $i -lt ${#args[*]} ]]; do
  66. log_mustnot $ZFS unshare ${args[i]}
  67. ((i = i + 1))
  68. done
  69. #Testing that unsharing unshared filesystem fails.
  70. mpt=$(get_prop mountpoint $TESTPOOL/$TESTFS)
  71. log_must $ZFS unshare $TESTPOOL/$TESTFS
  72. for opt in "" "-f"; do
  73. log_mustnot eval "$ZFS unshare $opt $TESTPOOL/$TESTFS >/dev/null 2>&1"
  74. log_mustnot eval "$ZFS unshare $opt $mpt >/dev/null 2>&1"
  75. done
  76. #Testing zfs unshare fails with legacy share set
  77. log_must $ZFS set sharenfs=off $TESTPOOL/$TESTFS
  78. for opt in "" "-f"; do
  79. log_mustnot eval "$ZFS unshare $opt $TESTPOOL/$TESTFS >/dev/null 2>&1"
  80. log_mustnot eval "$ZFS unshare $opt $mpt >/dev/null 2>&1"
  81. done
  82. log_pass "'$ZFS unshare' fails as expected with badly-formed parameters."