PageRenderTime 69ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_004_neg.ksh

http://github.com/zfsonlinux/zfs
Korn Shell | 86 lines | 33 code | 13 blank | 40 comment | 6 complexity | e93c95e022324f39a1edf1017f97de3e 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. . $STF_SUITE/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib
  31. #
  32. # DESCRIPTION:
  33. # 'zfs rollback' should fail when passing invalid options, too many
  34. # arguments,non-snapshot datasets or missing datasets
  35. #
  36. # STRATEGY:
  37. # 1. Create an array of invalid options
  38. # 2. Execute 'zfs rollback' with invalid options, too many arguments
  39. # or missing datasets
  40. # 3. Verify 'zfs rollback' return with errors
  41. #
  42. verify_runnable "both"
  43. function cleanup
  44. {
  45. typeset ds
  46. for ds in $TESTPOOL $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL; do
  47. if snapexists ${ds}@$TESTSNAP; then
  48. log_must zfs destroy ${ds}@$TESTSNAP
  49. fi
  50. done
  51. }
  52. log_assert "'zfs rollback' should fail with bad options,too many arguments," \
  53. "non-snapshot datasets or missing datasets."
  54. log_onexit cleanup
  55. set -A badopts "r" "R" "f" "-F" "-rF" "-RF" "-fF" "-?" "-*" "-blah" "-1" "-2"
  56. for ds in $TESTPOOL $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL; do
  57. log_must zfs snapshot ${ds}@$TESTSNAP
  58. done
  59. for ds in $TESTPOOL $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL; do
  60. for opt in "" "-r" "-R" "-f" "-rR" "-rf" "-rRf"; do
  61. log_mustnot eval "zfs rollback $opt $ds >/dev/null 2>&1"
  62. log_mustnot eval "zfs rollback $opt ${ds}@$TESTSNAP \
  63. ${ds}@$TESTSNAP >/dev/null 2>&1"
  64. log_mustnot eval "zfs rollback $opt >/dev/null 2>&1"
  65. # zfs rollback should fail with non-existen snapshot
  66. log_mustnot eval "zfs rollback $opt ${ds}@nosnap >/dev/null 2>&1"
  67. done
  68. for badopt in ${badopts[@]}; do
  69. log_mustnot eval "zfs rollback $badopt ${ds}@$TESTSNAP \
  70. >/dev/null 2>&1"
  71. done
  72. done
  73. log_pass "'zfs rollback' fails as expected with illegal arguments."