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

/tests/sys/cddl/zfs/tests/snapshot/snapshot_007_pos.ksh

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 112 lines | 43 code | 17 blank | 52 comment | 9 complexity | e264b723c8f0ec3018ebf1954373d82b MD5 | raw file
  1. #! /usr/local/bin/ksh93 -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. # $FreeBSD$
  23. #
  24. # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
  25. # Use is subject to license terms.
  26. #
  27. # ident "@(#)snapshot_007_pos.ksh 1.2 07/01/09 SMI"
  28. #
  29. . $STF_SUITE/include/libtest.kshlib
  30. ################################################################################
  31. #
  32. # __stc_assertion_start
  33. #
  34. # ID: snapshot_007_pos
  35. #
  36. # DESCRIPTION:
  37. # Verify that many snapshots can be made on a zfs dataset.
  38. #
  39. # STRATEGY:
  40. # 1) Create a file in the zfs dataset
  41. # 2) Create a snapshot of the dataset
  42. # 3) Remove all the files from the original dataset
  43. # 4) For each snapshot directory verify consistency
  44. #
  45. # TESTABILITY: explicit
  46. #
  47. # TEST_AUTOMATION_LEVEL: automated
  48. #
  49. # CODING_STATUS: COMPLETED (2005-07-04)
  50. #
  51. # __stc_assertion_end
  52. #
  53. ################################################################################
  54. verify_runnable "both"
  55. function cleanup
  56. {
  57. typeset -i i=1
  58. while [ $i -lt $COUNT ]; do
  59. snapexists $SNAPCTR.$i
  60. if [[ $? -eq 0 ]]; then
  61. log_must $ZFS destroy $SNAPCTR.$i
  62. fi
  63. if [[ -e $SNAPDIR.$i ]]; then
  64. log_must $RM -rf $SNAPDIR1.$i > /dev/null 2>&1
  65. fi
  66. (( i = i + 1 ))
  67. done
  68. if [[ -e $SNAPDIR1 ]]; then
  69. log_must $RM -rf $SNAPDIR1 > /dev/null 2>&1
  70. fi
  71. if [[ -e $TESTDIR ]]; then
  72. log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
  73. fi
  74. }
  75. log_assert "Verify that many snapshots can be made on a zfs dataset."
  76. log_onexit cleanup
  77. [[ -n $TESTDIR ]] && \
  78. log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
  79. typeset -i COUNT=10
  80. log_note "Create some files in the $TESTDIR directory..."
  81. populate_dir $TESTDIR1/file $COUNT $NUM_WRITES $BLOCKSZ ITER $SNAPCTR
  82. log_note "Remove all of the original files"
  83. [[ -n $TESTDIR ]] && \
  84. log_must $RM -rf $TESTDIR1/file* > /dev/null 2>&1
  85. i=1
  86. while [[ $i -lt $COUNT ]]; do
  87. FILECOUNT=`$LS $SNAPDIR1.$i/file* | wc -l`
  88. typeset j=1
  89. while [ $j -lt $FILECOUNT ]; do
  90. log_must $FILE_CHECK $SNAPDIR1.$i/file.$j $j
  91. (( j = j + 1 ))
  92. done
  93. (( i = i + 1 ))
  94. done
  95. log_pass "All files are consistent"