PageRenderTime 28ms CodeModel.GetById 6ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_006_neg.ksh

http://github.com/zfsonlinux/zfs
Korn Shell | 90 lines | 32 code | 14 blank | 44 comment | 4 complexity | f19ffe7195704d3fecc3f726e68fec86 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. # 'zfs promote' will fail with invalid arguments:
  33. # (1) NULL arguments
  34. # (2) non-existent clone
  35. # (3) non-clone datasets:
  36. # pool, fs, snapshot,volume
  37. # (4) too many arguments.
  38. # (5) invalid options
  39. # (6) temporary %recv datasets
  40. #
  41. # STRATEGY:
  42. # 1. Create an array of invalid arguments
  43. # 2. For each invalid argument in the array, 'zfs promote' should fail
  44. # 3. Verify the return code from zfs promote
  45. #
  46. verify_runnable "both"
  47. snap=$TESTPOOL/$TESTFS@$TESTSNAP
  48. clone=$TESTPOOL/$TESTCLONE
  49. recvfs=$TESTPOOL/recvfs
  50. set -A args "" \
  51. "$TESTPOOL/blah" \
  52. "$TESTPOOL" "$TESTPOOL/$TESTFS" "$snap" \
  53. "$TESTPOOL/$TESTVOL" "$TESTPOOL $TESTPOOL/$TESTFS" \
  54. "$clone $TESTPOOL/$TESTFS" "- $clone" "-? $clone" \
  55. "$recvfs/%recv"
  56. function cleanup
  57. {
  58. if datasetexists $clone; then
  59. log_must zfs destroy $clone
  60. fi
  61. if datasetexists $recvfs; then
  62. log_must zfs destroy -r $recvfs
  63. fi
  64. if snapexists $snap; then
  65. destroy_snapshot $snap
  66. fi
  67. }
  68. log_assert "'zfs promote' will fail with invalid arguments. "
  69. log_onexit cleanup
  70. create_recv_clone $recvfs
  71. typeset -i i=0
  72. while (( i < ${#args[*]} )); do
  73. log_mustnot zfs promote ${args[i]}
  74. (( i = i + 1 ))
  75. done
  76. log_pass "'zfs promote' fails with invalid argument as expected."