/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_018_pos.ksh

https://github.com/adilger/zfs · Korn Shell · 98 lines · 40 code · 12 blank · 46 comment · 9 complexity · 1e1664932484027fd08b7891449bc807 MD5 · raw file

  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 2009 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/zpool_create/zpool_create.shlib
  31. #
  32. # DESCRIPTION:
  33. #
  34. # zpool create can create pools with specified properties
  35. #
  36. # STRATEGY:
  37. # 1. Create a pool with all editable properties
  38. # 2. Verify those properties are set
  39. # 3. Create a pool with two properties set
  40. # 4. Verify both properties are set correctly
  41. #
  42. function cleanup
  43. {
  44. poolexists $TESTPOOL && destroy_pool $TESTPOOL
  45. rm -f $CPATH
  46. }
  47. log_onexit cleanup
  48. log_assert "zpool create can create pools with specified properties"
  49. #
  50. # we don't include "root" property in this list, as it requires both "cachefile"
  51. # and "root" to be set at the same time. A test for this is included in
  52. # ../../root.
  53. #
  54. typeset props=("autoreplace" "delegation" "cachefile" "version" "autoexpand")
  55. typeset vals=("off" "off" "$CPATH" "3" "on")
  56. typeset -i i=0;
  57. while [ $i -lt "${#props[@]}" ]
  58. do
  59. log_must zpool create -o ${props[$i]}=${vals[$i]} $TESTPOOL $DISK0
  60. RESULT=$(get_pool_prop ${props[$i]} $TESTPOOL)
  61. if [[ $RESULT != ${vals[$i]} ]]
  62. then
  63. zpool get all $TESTPOOL
  64. log_fail "Pool was created without setting the ${props[$i]} " \
  65. "property"
  66. fi
  67. log_must zpool destroy $TESTPOOL
  68. ((i = i + 1))
  69. done
  70. # Destroy our pool
  71. poolexists $TESTPOOL && destroy_pool $TESTPOOL
  72. # pick two properties, and verify we can create with those as well
  73. log_must zpool create -o delegation=off -o cachefile=$CPATH $TESTPOOL $DISK0
  74. RESULT=$(get_pool_prop delegation $TESTPOOL)
  75. if [[ $RESULT != off ]]
  76. then
  77. zpool get all $TESTPOOL
  78. log_fail "Pool created without the delegation prop."
  79. fi
  80. RESULT=$(get_pool_prop cachefile $TESTPOOL)
  81. if [[ $RESULT != $CPATH ]]
  82. then
  83. zpool get all $TESTPOOL
  84. log_fail "Pool created without the cachefile prop."
  85. fi
  86. log_pass "zpool create can create pools with specified properties"