/tests/sys/cddl/zfs/tests/cli_root/zfs_send/zfs_send_004_neg.ksh

https://bitbucket.org/freebsd/freebsd-base · Korn Shell · 123 lines · 55 code · 16 blank · 52 comment · 6 complexity · dbee21fe82049780342e7fc17f8ced92 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 2008 Sun Microsystems, Inc. All rights reserved.
  25. # Use is subject to license terms.
  26. #
  27. # ident "@(#)zfs_send_004_neg.ksh 1.5 08/02/27 SMI"
  28. #
  29. . $STF_SUITE/tests/cli_root/cli_common.kshlib
  30. #################################################################################
  31. #
  32. # __stc_assertion_start
  33. #
  34. # ID: zfs_send_004_neg
  35. #
  36. # DESCRIPTION:
  37. # Verify 'zfs send' fails with malformed parameters.
  38. #
  39. # STRATEGY:
  40. # 1. Define malformed parameters in array
  41. # 2. Feed the parameters to 'zfs send'
  42. # 3. Verify the result
  43. #
  44. # TESTABILITY: explicit
  45. #
  46. # TEST_AUTOMATION_LEVEL: automated
  47. #
  48. # CODING_STATUS: COMPLETED (2005-09-06)
  49. #
  50. # __stc_assertion_end
  51. #
  52. ################################################################################
  53. verify_runnable "both"
  54. function cleanup
  55. {
  56. typeset snap f
  57. for snap in $snap1 $snap2 $snap3; do
  58. snapexists $snap && \
  59. log_must $ZFS destroy -f $snap
  60. done
  61. for f in $tmpfile1 $tmpfile2; do
  62. if [[ -e $f ]]; then
  63. $RM -f $f
  64. fi
  65. done
  66. }
  67. fs=$TESTPOOL/$TESTFS
  68. snap1=$fs@snap1
  69. snap2=$fs@snap2
  70. snap3=$fs@snap3
  71. set -A badargs \
  72. "" "$TESTPOOL" "$TESTFS" "$fs" "$fs@nonexisten_snap" "?" \
  73. "$snap1/blah" "$snap1@blah" "-i" "-x" "-i $fs" \
  74. "-x $snap1 $snap2" "-i $snap1" \
  75. "-i $snap2 $snap1" "$snap1 $snap2" "-i $snap1 $snap2 $snap3" \
  76. "-ii $snap1 $snap2" "-iii $snap1 $snap2" " -i $snap2 $snap1/blah" \
  77. "-i $snap2/blah $snap1" \
  78. "-i $snap2/blah $snap1/blah" \
  79. "-i $snap1 blah@blah" \
  80. "-i blah@blah $snap1" \
  81. "-i $snap1 ${snap2##*@}" "-i $snap1 @${snap2##*@}" \
  82. "-i ${snap1##*@} ${snap2##*@}" "-i @${snap1##*@} @${snap2##*@}" \
  83. "-i ${snap1##*@} $snap2/blah" "-i @${snap1##*@} $snap2/blah" \
  84. "-i @@${snap1##*@} $snap2" "-i $snap1 -i $snap1 $snap2" \
  85. "-i snap1 snap2" "-i $snap1 snap2" \
  86. "-i $snap1 $snap2 -i $snap1 $snap2" \
  87. "-i snap1 $snap2 -i snap1 $snap2"
  88. log_assert "Verify that invalid parameters to 'zfs send' are caught."
  89. log_onexit cleanup
  90. log_must $ZFS snapshot $snap1
  91. tmpfile1=$TESTDIR/testfile1.${TESTCASE_ID}
  92. log_must $TOUCH $tmpfile1
  93. log_must $ZFS snapshot $snap2
  94. tmpfile2=$TESTDIR/testfile2.${TESTCASE_ID}
  95. log_must $TOUCH $tmpfile2
  96. log_must $ZFS snapshot $snap3
  97. typeset -i i=0
  98. while (( i < ${#badargs[*]} ))
  99. do
  100. log_mustnot eval "$ZFS send ${badargs[i]} >/dev/null"
  101. (( i = i + 1 ))
  102. done
  103. #Testing zfs send fails by send backup stream to terminal
  104. for arg in "$snap1" "-i $snap1 $snap2"; do
  105. log_mustnot eval "$ZFS send $arg >/dev/console"
  106. done
  107. log_pass "Invalid parameters to 'zfs send' are caught as expected."