/tests/sys/cddl/zfs/tests/xattr/xattr_008_pos.ksh

https://bitbucket.org/freebsd/freebsd-base · Korn Shell · 112 lines · 48 code · 11 blank · 53 comment · 6 complexity · 1dc87cf81e15a78ef5dec30ae50f3257 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. # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
  23. # Use is subject to license terms.
  24. #
  25. # ident "@(#)xattr_008_pos.ksh 1.2 08/02/27 SMI"
  26. #
  27. # $FreeBSD$
  28. . $STF_SUITE/include/libtest.kshlib
  29. . $STF_SUITE/tests/xattr/xattr_common.kshlib
  30. ################################################################################
  31. #
  32. # __stc_assertion_start
  33. #
  34. # ID: xattr_008_pos
  35. #
  36. # DESCRIPTION:
  37. # We verify that the special . and .. dirs work as expected for xattrs.
  38. #
  39. # STRATEGY:
  40. # 1. Create a file and an xattr on that file
  41. # 2. List the . directory, verifying the output
  42. # 3. Verify we're unable to list the ../ directory
  43. #
  44. # TESTABILITY: explicit
  45. #
  46. # TEST_AUTOMATION_LEVEL: automated
  47. #
  48. # CODING_STATUS: COMPLETED (2006-12-05)
  49. #
  50. # __stc_assertion_end
  51. #
  52. ################################################################################
  53. function cleanup {
  54. typeset file
  55. for file in $TMPDIR/output.${TESTCASE_ID} $TMPDIR/expected-output.${TESTCASE_ID} \
  56. $TESTDIR/myfile.${TESTCASE_ID} ; do
  57. log_must $RM -f $file
  58. done
  59. }
  60. log_assert "special . and .. dirs work as expected for xattrs"
  61. log_onexit cleanup
  62. test_requires RUNAT
  63. # create a file, and an xattr on it
  64. log_must $TOUCH $TESTDIR/myfile.${TESTCASE_ID}
  65. create_xattr $TESTDIR/myfile.${TESTCASE_ID} passwd /etc/passwd
  66. if check_version "5.10"
  67. then
  68. # listing the directory . should show one file
  69. OUTPUT=$($RUNAT $TESTDIR/myfile.${TESTCASE_ID} $LS .)
  70. if [ "$OUTPUT" != "passwd" ]
  71. then
  72. log_fail "Listing the . directory doesn't show \"passwd\" as expected."
  73. fi
  74. # list the directory . long form
  75. log_must eval "$RUNAT $TESTDIR/myfile.${TESTCASE_ID} $LS -a . > $TMPDIR/output.${TESTCASE_ID}"
  76. # create a file that should be the same as the command above
  77. create_expected_output $TMPDIR/expected-output.${TESTCASE_ID} . .. passwd
  78. # compare them
  79. log_must $DIFF $TMPDIR/output.${TESTCASE_ID} $TMPDIR/expected-output.${TESTCASE_ID}
  80. else
  81. # listing the directory .
  82. log_must eval "$RUNAT $TESTDIR/myfile.${TESTCASE_ID} $LS . > $TMPDIR/output.${TESTCASE_ID}"
  83. create_expected_output $TMPDIR/expected-output.${TESTCASE_ID} \
  84. SUNWattr_ro SUNWattr_rw passwd
  85. log_must $DIFF $TMPDIR/output.${TESTCASE_ID} $TMPDIR/expected-output.${TESTCASE_ID}
  86. # list the directory . long form
  87. log_must eval "$RUNAT $TESTDIR/myfile.${TESTCASE_ID} $LS -a . > $TMPDIR/output.${TESTCASE_ID}"
  88. create_expected_output $TMPDIR/expected-output.${TESTCASE_ID} . .. \
  89. SUNWattr_ro SUNWattr_rw passwd
  90. log_must $DIFF $TMPDIR/output.${TESTCASE_ID} $TMPDIR/expected-output.${TESTCASE_ID}
  91. fi
  92. # list the directory .. expecting one file
  93. OUTPUT=$($RUNAT $TESTDIR/myfile.${TESTCASE_ID} $LS ..)
  94. if [ "$OUTPUT" != ".." ]
  95. then
  96. log_fail "Listing the .. directory doesn't show \"..\" as expected."
  97. fi
  98. # verify we can't list ../
  99. log_mustnot eval "$RUNAT $TESTDIR/myfile.${TESTCASE_ID} $LS ../ > /dev/null 2>&1"
  100. log_pass "special . and .. dirs work as expected for xattrs"