PageRenderTime 27ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_008_neg.ksh

http://github.com/zfsonlinux/zfs
Korn Shell | 113 lines | 64 code | 11 blank | 38 comment | 6 complexity | eb9f97fb59c071544393cdeb77aa6c33 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) 2012, 2016 by Delphix. All rights reserved.
  28. #
  29. . $STF_SUITE/include/libtest.shlib
  30. . $STF_SUITE/tests/functional/cli_root/zfs_create/zfs_create.cfg
  31. #
  32. # DESCRIPTION:
  33. # 'zfs create' should return an error with badly formed parameters.
  34. #
  35. # STRATEGY:
  36. # 1. Create an array of parameters
  37. # 2. For each parameter in the array, execute 'zfs create'
  38. # 3. Verify an error is returned.
  39. #
  40. verify_runnable "both"
  41. function cleanup
  42. {
  43. if datasetexists $TESTPOOL/$TESTFS1 ; then
  44. log_must zfs destroy -f $TESTPOOL/$TESTFS1
  45. fi
  46. }
  47. log_onexit cleanup
  48. set -A args "ab" "-?" "-cV" "-Vc" "-c -V" "c" "V" "--c" "-e" "-s" \
  49. "-blah" "-cV 12k" "-s -cV 1P" "-sc" "-Vs 5g" "-o" "--o" "-O" "--O" \
  50. "-o QuOta=none" "-o quota=non" "-o quota=abcd" "-o quota=0" "-o quota=" \
  51. "-o ResErVaTi0n=none" "-o reserV=none" "-o reservation=abcd" "-o reserv=" \
  52. "-o recorDSize=64k" "-o recordsize=2048K" "-o recordsize=2M" \
  53. "-o recordsize=256" "-o recsize=" "-o recsize=zero" "-o recordsize=0" \
  54. "-o mountPoint=/tmp/tmpfile$$" "-o mountpoint=non0" "-o mountpoint=" \
  55. "-o mountpoint=LEGACY" "-o mounpoint=none" \
  56. "-o sharenfs=ON" "-o ShareNFS=off" "-o sharenfs=sss" \
  57. "-o checkSUM=on" "-o checksum=SHA256" "-o chsum=off" "-o checksum=aaa" \
  58. "-o checkSUM=on -V $VOLSIZE" "-o checksum=SHA256 -V $VOLSIZE" \
  59. "-o chsum=off -V $VOLSIZE" "-o checksum=aaa -V $VOLSIZE" \
  60. "-o compression=of" "-o ComPression=lzjb" "-o compress=ON" "-o compress=a" \
  61. "-o compression=of -V $VOLSIZE" "-o ComPression=lzjb -V $VOLSIZE" \
  62. "-o compress=ON -V $VOLSIZE" "-o compress=a -V $VOLSIZE" \
  63. "-o atime=ON" "-o ATime=off" "-o atime=bbb" \
  64. "-o deviCes=on" "-o devices=OFF" "-o devices=aaa" \
  65. "-o exec=ON" "-o EXec=off" "-o exec=aaa" \
  66. "-o readonly=ON" "-o reADOnly=off" "-o rdonly=OFF" "-o rdonly=aaa" \
  67. "-o readonly=ON -V $VOLSIZE" "-o reADOnly=off -V $VOLSIZE" \
  68. "-o rdonly=OFF -V $VOLSIZE" "-o rdonly=aaa -V $VOLSIZE" \
  69. "-o snapdIR=hidden" "-o snapdir=VISible" "-o snapdir=aaa" \
  70. "-o aclmode=DIScard" "-o aclmODE=groupmask" "-o aclmode=aaa" \
  71. "-o aclinherit=deny" "-o aclinHerit=secure" "-o aclinherit=aaa" \
  72. "-o type=volume" "-o type=snapshot" "-o type=filesystem" \
  73. "-o type=volume -V $VOLSIZE" "-o type=snapshot -V $VOLSIZE" \
  74. "-o type=filesystem -V $VOLSIZE" \
  75. "-o creation=aaa" "-o creation=aaa -V $VOLSIZE" \
  76. "-o used=10K" "-o used=10K -V $VOLSIZE" \
  77. "-o available=10K" "-o available=10K -V $VOLSIZE" \
  78. "-o referenced=10K" "-o referenced=10K -V $VOLSIZE" \
  79. "-o compressratio=1.00x" "-o compressratio=1.00x -V $VOLSIZE" \
  80. "-o version=0" "-o version=1.234" "-o version=10K" "-o version=-1" \
  81. "-o version=aaa" "-o version=999"
  82. if is_freebsd; then
  83. args+=("-o jailed=ON" "-o JaiLed=off" "-o jailed=aaa")
  84. else
  85. args+=("-o zoned=ON" "-o ZoNed=off" "-o zoned=aaa")
  86. fi
  87. log_assert "'zfs create' should return an error with badly-formed parameters."
  88. typeset -i i=0
  89. while [[ $i -lt ${#args[*]} ]]; do
  90. typeset arg=${args[i]}
  91. if is_freebsd; then
  92. # FreeBSD does not strictly validate share options (yet).
  93. if [[ "$arg" == "-o sharenfs="* ]]; then
  94. ((i = i + 1))
  95. continue
  96. fi
  97. fi
  98. log_mustnot zfs create $arg $TESTPOOL/$TESTFS1
  99. log_mustnot zfs create -p $arg $TESTPOOL/$TESTFS1
  100. ((i = i + 1))
  101. done
  102. log_pass "'zfs create' with badly formed parameters failed as expected."