PageRenderTime 58ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_004_neg.ksh

http://github.com/zfsonlinux/zfs
Korn Shell | 109 lines | 55 code | 16 blank | 38 comment | 6 complexity | f1daeb93b06490e0381a05856eb0a586 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 2008 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/tests/functional/cli_root/cli_common.kshlib
  30. #
  31. # DESCRIPTION:
  32. # Verify 'zfs send' fails with malformed parameters.
  33. #
  34. # STRATEGY:
  35. # 1. Define malformed parameters in array
  36. # 2. Feed the parameters to 'zfs send'
  37. # 3. Verify the result
  38. #
  39. verify_runnable "both"
  40. function cleanup
  41. {
  42. typeset snap f
  43. for snap in $snap1 $snap2 $snap3; do
  44. snapexists $snap && \
  45. log_must zfs destroy -f $snap
  46. done
  47. for f in $tmpfile1 $tmpfile2; do
  48. if [[ -e $f ]]; then
  49. rm -f $f
  50. fi
  51. done
  52. }
  53. fs=$TESTPOOL/$TESTFS
  54. snap1=$fs@snap1
  55. snap2=$fs@snap2
  56. snap3=$fs@snap3
  57. set -A badargs \
  58. "" "$TESTPOOL" "$TESTFS" "$fs" "$fs@nonexistent_snap" "?" \
  59. "$snap1/blah" "$snap1@blah" "-i" "-x" "-i $fs" \
  60. "-x $snap1 $snap2" "-i $snap1" \
  61. "-i $snap2 $snap1" "$snap1 $snap2" "-i $snap1 $snap2 $snap3" \
  62. "-ii $snap1 $snap2" "-iii $snap1 $snap2" " -i $snap2 $snap1/blah" \
  63. "-i $snap2/blah $snap1" \
  64. "-i $snap2/blah $snap1/blah" \
  65. "-i $snap1 blah@blah" \
  66. "-i blah@blah $snap1" \
  67. "-i $snap1 ${snap2##*@}" "-i $snap1 @${snap2##*@}" \
  68. "-i ${snap1##*@} ${snap2##*@}" "-i @${snap1##*@} @${snap2##*@}" \
  69. "-i ${snap1##*@} $snap2/blah" "-i @${snap1##*@} $snap2/blah" \
  70. "-i @@${snap1##*@} $snap2" "-i $snap1 -i $snap1 $snap2" \
  71. "-i snap1 snap2" "-i $snap1 snap2" \
  72. "-i $snap1 $snap2 -i $snap1 $snap2" \
  73. "-i snap1 $snap2 -i snap1 $snap2"
  74. log_assert "Verify that invalid parameters to 'zfs send' are caught."
  75. log_onexit cleanup
  76. log_must zfs snapshot $snap1
  77. tmpfile1=$TESTDIR/testfile1.$$
  78. log_must touch $tmpfile1
  79. log_must zfs snapshot $snap2
  80. tmpfile2=$TESTDIR/testfile2.$$
  81. log_must touch $tmpfile2
  82. log_must zfs snapshot $snap3
  83. typeset -i i=0
  84. while (( i < ${#badargs[*]} ))
  85. do
  86. log_mustnot eval "zfs send ${badargs[i]} >/dev/null"
  87. (( i = i + 1 ))
  88. done
  89. #Testing zfs send fails by send backup stream to terminal
  90. for arg in "$snap1" "-i $snap1 $snap2"; do
  91. log_mustnot eval "zfs send $arg >/dev/console"
  92. done
  93. log_pass "Invalid parameters to 'zfs send' are caught as expected."