PageRenderTime 87ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/sys/cddl/zfs/tests/cli_root/zfs/zfs_002_pos.ksh

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 127 lines | 57 code | 18 blank | 52 comment | 7 complexity | c434ccd17b06011431ab4dd67d5b9569 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 2009 Sun Microsystems, Inc. All rights reserved.
  25. # Use is subject to license terms.
  26. #
  27. # ident "@(#)zfs_002_pos.ksh 1.3 09/06/22 SMI"
  28. #
  29. . $STF_SUITE/include/libtest.kshlib
  30. . $STF_SUITE/tests/userquota/userquota_common.kshlib
  31. ################################################################################
  32. #
  33. # __stc_assertion_start
  34. #
  35. # ID: zfs_002_pos
  36. #
  37. # DESCRIPTION:
  38. # With ZFS_ABORT set, all zfs commands should be able to abort and generate a core file.
  39. #
  40. # STRATEGY:
  41. # 1. Create an array of zfs command
  42. # 2. Execute each command in the array
  43. # 3. Verify the command aborts and generate a core file
  44. #
  45. # TESTABILITY: explicit
  46. #
  47. # TEST_AUTOMATION_LEVEL: automated
  48. #
  49. # CODING_STATUS: COMPLETED (2007-06-29)
  50. #
  51. # __stc_assertion_end
  52. #
  53. ################################################################################
  54. verify_runnable "both"
  55. function cleanup
  56. {
  57. unset ZFS_ABORT
  58. if [[ -d $corepath ]]; then
  59. $RM -rf $corepath
  60. fi
  61. for ds in $fs1 $fs $ctr; do
  62. if datasetexists $ds; then
  63. log_must $ZFS destroy -rRf $ds
  64. fi
  65. done
  66. }
  67. log_assert "With ZFS_ABORT set, all zfs commands can abort and generate a core file."
  68. log_onexit cleanup
  69. #preparation work for testing
  70. corepath=$TESTDIR/core
  71. if [[ -d $corepath ]]; then
  72. $RM -rf $corepath
  73. fi
  74. log_must $MKDIR $corepath
  75. ctr=$TESTPOOL/$TESTCTR
  76. log_must $ZFS create $ctr
  77. fs=$ctr/$TESTFS
  78. fs1=$ctr/$TESTFS1
  79. snap=$fs@$TESTSNAP
  80. clone=$ctr/$TESTCLONE
  81. streamf=$corepath/s.${TESTCASE_ID}
  82. set -A cmds "create $fs" "list $fs" "snapshot $snap" "set snapdir=hidden $fs" \
  83. "get snapdir $fs" "rollback $snap" "inherit snapdir $fs" \
  84. "rename $fs $fs-new" "rename $fs-new $fs" "unmount $fs" \
  85. "mount $fs" "share $fs" "unshare $fs" "send $snap \>$streamf" \
  86. "receive $fs1 \<$streamf" "clone $snap $clone" "promote $clone" \
  87. "promote $fs" "destroy -rRf $fs"
  88. set -A badparams "" "create" "destroy" "snapshot" "rollback" "clone" "promote" "rename" \
  89. "list -*" "set" "get -*" "inherit" "mount -A" "unmount" "share" \
  90. "unshare" "send" "receive"
  91. if ! is_userquota_supported; then
  92. typeset -i i=${cmds[#]}
  93. cmds[i]="allow everyone snapshot $fs"
  94. cmds[((i+1))]="unallow everyone snapshot $fs"
  95. i=${badparams[#]}
  96. badparams[i]="allow"
  97. badparams[((i+1))]="unallow"
  98. fi
  99. log_must $COREADM -p ${corepath}/core.%f
  100. log_must export ZFS_ABORT=yes
  101. for subcmd in "${cmds[@]}" "${badparams[@]}"; do
  102. log_mustnot $ZFS $subcmd
  103. corefile=${corepath}/core.zfs
  104. if [[ ! -e $corefile ]]; then
  105. log_fail "$ZFS $subcmd cannot generate core file with ZFS_ABORT set."
  106. fi
  107. log_must $RM -f $corefile
  108. done
  109. log_pass "With ZFS_ABORT set, zfs command can abort and generate core file as expected."