PageRenderTime 39ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_002_pos.ksh

http://github.com/zfsonlinux/zfs
Korn Shell | 176 lines | 105 code | 18 blank | 53 comment | 8 complexity | 58fab88b4e81de46f1846ae7d7b8a8fb 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 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. #
  29. . $STF_SUITE/tests/functional/cli_user/zfs_list/zfs_list.kshlib
  30. #
  31. # DESCRIPTION:
  32. # The sort functionality in 'zfs list' works as expected.
  33. #
  34. # STRATEGY:
  35. # 1. Using several zfs datasets with names, creation dates, checksum options
  36. # 2. Sort the datasets by name, checksum options, creation date.
  37. # 3. Verify that the datasets are sorted correctly.
  38. #
  39. verify_runnable "both"
  40. # datasets ordered by name
  41. fs_name="Apple Banana Carrot Orange apple banana carrot"
  42. vol_name="Apple-vol Banana-vol Carrot-vol Orange-vol apple-vol"
  43. vol_name="$vol_name banana-vol carrot-vol"
  44. if is_global_zone ; then
  45. snap_name="Apple-vol@snap Apple@snap Banana-vol@snap Banana@snap"
  46. snap_name="$snap_name Carrot-vol@snap Carrot@snap Orange-vol@snap Orange@snap"
  47. snap_name="$snap_name apple-vol@snap apple@snap banana-vol@snap banana@snap"
  48. snap_name="$snap_name carrot-vol@snap carrot@snap"
  49. else
  50. snap_name="Apple@snap Banana@snap"
  51. snap_name="$snap_name Carrot@snap Orange@snap"
  52. snap_name="$snap_name apple@snap banana@snap"
  53. snap_name="$snap_name carrot@snap"
  54. fi
  55. fs_creation=$fs_name
  56. vol_creation=$vol_name
  57. if is_global_zone ; then
  58. snap_creation="Apple@snap Apple-vol@snap Banana@snap Banana-vol@snap"
  59. snap_creation="$snap_creation Carrot@snap Carrot-vol@snap Orange@snap Orange-vol@snap"
  60. snap_creation="$snap_creation apple@snap apple-vol@snap banana@snap banana-vol@snap"
  61. snap_creation="$snap_creation carrot@snap carrot-vol@snap"
  62. else
  63. snap_creation="Apple@snap Banana@snap"
  64. snap_creation="$snap_creation Carrot@snap Orange@snap"
  65. snap_creation="$snap_creation apple@snap banana@snap"
  66. snap_creation="$snap_creation carrot@snap"
  67. fi
  68. #
  69. # datsets ordered by checksum options (note, Orange, Carrot & Banana have the
  70. # same checksum options, so ZFS should revert to sorting them alphabetically by
  71. # name)
  72. #
  73. fs_cksum="carrot apple banana Apple Banana Carrot Orange"
  74. vol_cksum="carrot-vol apple-vol banana-vol Apple-vol Banana-vol"
  75. vol_cksum="$vol_cksum Carrot-vol Orange-vol"
  76. snap_cksum=$snap_creation
  77. fs_rev_cksum="carrot apple banana Apple Orange Carrot Banana"
  78. vol_rev_cksum="carrot-vol apple-vol banana-vol Apple-vol Orange-vol"
  79. vol_rev_cksum="$vol_rev_cksum Carrot-vol Banana-vol"
  80. log_assert "The sort functionality in 'zfs list' works as expected."
  81. #
  82. # we must be in the C locale here, as running in other locales
  83. # will make zfs use that locale's sort order.
  84. #
  85. LC_ALL=C; export LC_ALL
  86. # sort by creation
  87. verify_sort \
  88. "zfs list -H -r -o name -s creation -t filesystem $TESTPOOL/$TESTFS" \
  89. "$fs_creation" "creation date"
  90. if is_global_zone ; then
  91. verify_sort \
  92. "zfs list -H -r -o name -s creation -t volume $TESTPOOL/$TESTFS" \
  93. "$vol_creation" "creation date"
  94. fi
  95. verify_sort \
  96. "zfs list -H -r -o name -s creation -t snapshot $TESTPOOL/$TESTFS" \
  97. "$snap_creation" "creation date"
  98. # sort by checksum
  99. verify_sort \
  100. "zfs list -H -r -o name -s checksum -t filesystem $TESTPOOL/$TESTFS" \
  101. "$fs_cksum" "checksum"
  102. if is_global_zone ; then
  103. verify_sort \
  104. "zfs list -H -r -o name -s checksum -t volume $TESTPOOL/$TESTFS" \
  105. "$vol_cksum" "checksum"
  106. fi
  107. verify_sort \
  108. "zfs list -H -r -o name -s checksum -t snapshot $TESTPOOL/$TESTFS" \
  109. "$snap_cksum" "checksum"
  110. verify_sort \
  111. "zfs list -H -r -o name -S checksum -t snapshot $TESTPOOL/$TESTFS" \
  112. "$snap_cksum" "checksum"
  113. # sort by name
  114. verify_sort \
  115. "zfs list -H -r -o name -s name -t filesystem $TESTPOOL/$TESTFS" \
  116. "$fs_name" "name"
  117. if is_global_zone ; then
  118. verify_sort \
  119. "zfs list -H -r -o name -s name -t volume $TESTPOOL/$TESTFS" \
  120. "$vol_name" "name"
  121. fi
  122. verify_sort \
  123. "zfs list -H -r -o name -s name -t snapshot $TESTPOOL/$TESTFS" \
  124. "$snap_name" "name"
  125. # reverse sort by creation
  126. verify_reverse_sort \
  127. "zfs list -H -r -o name -S creation -t filesystem $TESTPOOL/$TESTFS" \
  128. "$fs_creation" "creation date"
  129. if is_global_zone ; then
  130. verify_reverse_sort \
  131. "zfs list -H -r -o name -S creation -t volume $TESTPOOL/$TESTFS" \
  132. "$vol_creation" "creation date"
  133. fi
  134. verify_reverse_sort \
  135. "zfs list -H -r -o name -S creation -t snapshot $TESTPOOL/$TESTFS" \
  136. "$snap_creation" "creation date"
  137. # reverse sort by checksum
  138. verify_reverse_sort \
  139. "zfs list -H -r -o name -S checksum -t filesystem $TESTPOOL/$TESTFS" \
  140. "$fs_rev_cksum" "checksum"
  141. if is_global_zone ; then
  142. verify_reverse_sort \
  143. "zfs list -H -r -o name -S checksum -t volume $TESTPOOL/$TESTFS" \
  144. "$vol_rev_cksum" "checksum"
  145. fi
  146. # reverse sort by name
  147. verify_reverse_sort \
  148. "zfs list -H -r -o name -S name -t filesystem $TESTPOOL/$TESTFS"\
  149. "$fs_name" "name"
  150. if is_global_zone ; then
  151. verify_reverse_sort \
  152. "zfs list -H -r -o name -S name -t volume $TESTPOOL/$TESTFS"\
  153. "$vol_name" "name"
  154. fi
  155. verify_reverse_sort \
  156. "zfs list -H -r -o name -S name -t snapshot $TESTPOOL/$TESTFS"\
  157. "$snap_name" "name"
  158. log_pass "The sort functionality in 'zfs list' works as expected."