PageRenderTime 36ms CodeModel.GetById 9ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_011_neg.ksh

http://github.com/zfsonlinux/zfs
Korn Shell | 81 lines | 28 code | 14 blank | 39 comment | 6 complexity | 4cdc62262a9d866f9cb626a0d65aa5e6 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 2007 Sun Microsystems, Inc. All rights reserved.
  24. # Use is subject to license terms.
  25. #
  26. #
  27. # Copyright (c) 2016 by Delphix. All rights reserved.
  28. #
  29. . $STF_SUITE/include/libtest.shlib
  30. #
  31. # DESCRIPTION:
  32. # Verify that zfs mount should fail with bad parameters
  33. #
  34. # STRATEGY:
  35. # 1. Make an array of bad parameters
  36. # 2. Use zfs mount to mount the filesystem
  37. # 3. Verify that zfs mount returns error
  38. #
  39. verify_runnable "both"
  40. function cleanup
  41. {
  42. if snapexists $TESTPOOL/$TESTFS@$TESTSNAP; then
  43. log_must_busy zfs destroy $TESTPOOL/$TESTFS@$TESTSNAP
  44. fi
  45. if is_global_zone && datasetexists $TESTPOOL/$TESTVOL; then
  46. log_must_busy zfs destroy $TESTPOOL/$TESTVOL
  47. fi
  48. }
  49. log_assert "zfs mount fails with bad parameters"
  50. log_onexit cleanup
  51. fs=$TESTPOOL/$TESTFS
  52. set -A badargs "A" "-A" "-" "-x" "-?" "=" "-o *" "-a"
  53. for arg in "${badargs[@]}"; do
  54. log_mustnot eval "zfs mount $arg $fs >/dev/null 2>&1"
  55. done
  56. #verify that zfs mount fails with invalid dataset
  57. for opt in "-o abc" "-O"; do
  58. log_mustnot eval "zfs mount $opt /$fs >/dev/null 2>&1"
  59. done
  60. #verify that zfs mount fails with volume and snapshot
  61. log_must zfs snapshot $TESTPOOL/$TESTFS@$TESTSNAP
  62. log_mustnot eval "zfs mount $TESTPOOL/$TESTFS@$TESTSNAP >/dev/null 2>&1"
  63. if is_global_zone; then
  64. log_must zfs create -V 10m $TESTPOOL/$TESTVOL
  65. log_mustnot eval "zfs mount $TESTPOOL/$TESTVOL >/dev/null 2>&1"
  66. fi
  67. log_pass "zfs mount fails with bad parameters as expected."