/tests/zfs-tests/tests/functional/cli_root/zfs_reservation/zfs_reservation_002_pos.ksh

https://github.com/adilger/zfs · Korn Shell · 88 lines · 33 code · 15 blank · 40 comment · 6 complexity · d727a16dc5285ac10f0d4b2697897b57 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 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. #
  31. # DESCRIPTION:
  32. # A reservation of 'none' (which is an alias for 0) should be allowed. This
  33. # test verifies that is true.
  34. #
  35. # STRATEGY:
  36. # 1. Create a new file system in the test pool.
  37. # 2. Set the reservation to 'none'.
  38. # 3. Verify the associated reservation is indeed 0.
  39. # 4. Repeat with reservation set to 0.
  40. #
  41. verify_runnable "both"
  42. # Use a unique value so earlier test failures will not impact this test.
  43. RESERVATION="reserve"-$$
  44. RESERVATION2="reserve2"-$$
  45. function cleanup
  46. {
  47. typeset FS
  48. for FS in $TESTPOOL/$RESERVATION $TESTPOOL/$RESERVATION2
  49. do
  50. if datasetexists $FS ; then
  51. log_must zfs unmount $FS
  52. log_must zfs destroy $FS
  53. fi
  54. done
  55. }
  56. log_onexit cleanup
  57. log_assert "Ensure a reservation of 0 or 'none' is allowed."
  58. log_must zfs create $TESTPOOL/$RESERVATION
  59. log_must zfs create $TESTPOOL/$RESERVATION2
  60. log_must zfs set reservation=0 $TESTPOOL/$RESERVATION
  61. log_must zfs set reservation=none $TESTPOOL/$RESERVATION2
  62. for FS in $TESTPOOL/$RESERVATION $TESTPOOL/$RESERVATION2
  63. do
  64. reserve=`zfs get -pH reservation $FS | awk '{print $3}'`
  65. if [[ $reserve -ne 0 ]]; then
  66. log_fail "ZFS get -p reservation did not return 0"
  67. fi
  68. reserve=`zfs get -H reservation $FS | awk '{print $3}'`
  69. if [[ $reserve != "none" ]]; then
  70. log_fail "ZFS get reservation did not return 'none'"
  71. fi
  72. done
  73. log_pass "Successfully set reservation to 0 and 'none'"