/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_005_neg.ksh

https://github.com/adilger/zfs · Korn Shell · 83 lines · 29 code · 14 blank · 40 comment · 5 complexity · d1f64ef333b5202e42aeaed8c4585cfb 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 2008 Sun Microsystems, Inc. All rights reserved.
  24. # Use is subject to license terms.
  25. #
  26. #
  27. # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
  28. # Copyright 2016 Nexenta Systems, Inc.
  29. #
  30. . $STF_SUITE/include/libtest.shlib
  31. . $STF_SUITE/tests/functional/zvol/zvol_common.shlib
  32. #
  33. # DESCRIPTION:
  34. # Verify a device cannot be dump and swap at the same time.
  35. #
  36. # STRATEGY:
  37. # 1. Create a ZFS volume
  38. # 2. Set it as swap device.
  39. # 3. Verify dumpadm with this zvol will fail.
  40. #
  41. verify_runnable "global"
  42. if ! is_physical_device $DISKS; then
  43. log_unsupported "This directory cannot be run on raw files."
  44. fi
  45. volsize=$(zfs get -H -o value volsize $TESTPOOL/$TESTVOL)
  46. function cleanup
  47. {
  48. swap -l | grep $voldev > /dev/null 2>&1
  49. if (( $? == 0 )) ; then
  50. log_must swap -d $voldev
  51. fi
  52. typeset dumpdev=$(get_dumpdevice)
  53. if [[ $dumpdev != $savedumpdev ]] ; then
  54. safe_dumpadm $savedumpdev
  55. fi
  56. zfs set volsize=$volsize $TESTPOOL/$TESTVOL
  57. }
  58. log_assert "Verify a device cannot be dump and swap at the same time."
  59. log_onexit cleanup
  60. voldev=${ZVOL_DEVDIR}/$TESTPOOL/$TESTVOL
  61. savedumpdev=$(get_dumpdevice)
  62. # If device in swap list, it cannot be dump device
  63. log_must swap -a $voldev
  64. log_mustnot dumpadm -d $voldev
  65. log_must swap -d $voldev
  66. # If device has dedicated as dump device, it cannot add into swap list
  67. safe_dumpadm $voldev
  68. log_mustnot swap -a $voldev
  69. log_pass "A device cannot be dump and swap at the same time."