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 #
  24 # Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  25 #
  26 
  27 #
  28 # ID:  xattr_009
  29 #
  30 # DESCRIPTION:
  31 # Verify can create many xattrs on a file
  32 #
  33 # STRATEGY:
  34 #       1. Create a file on a filesystem and add 100 xattrs to it
  35 #       2. Verify that the xattrs should be right
  36 #       4. Delete those xattrs
  37 #       5. Verify that xattrs should not be have
  38 #
  39 
  40 . $STF_SUITE/include/libtest.ksh
  41 
  42 tc_id=xattr_009
  43 tc_desc="Verify can create many xattrs on a file"
  44 print_test_case $tc_id - $tc_desc
  45 
  46 if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
  47         [[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
  48     set -x
  49 fi
  50 
  51 server=$(server_name) || return
  52 
  53 testdir_init $TDIR
  54 smbmount_clean $TMNT
  55 smbmount_init $TMNT
  56 
  57 cmd="mount -F smbfs //$TUSER:$TPASS@$server/public $TMNT"
  58 cti_execute -i '' FAIL $cmd
  59 if [[ $? != 0 ]]; then
  60          cti_fail "FAIL: smbmount can't mount the public share unexpectedly"
  61          return
  62 else
  63          cti_report "PASS: smbmount can mount the public share as expected"
  64 fi
  65 
  66 smbmount_getmntopts $TMNT |grep /xattr/ >/dev/null
  67 if [[ $? != 0 ]]; then
  68         smbmount_clean $TMNT
  69         cti_unsupported "UNSUPPORTED (no xattr in this mount)"
  70         return
  71 fi
  72 
  73 # Create a file, and set 100 xattrs on it.
  74 
  75 cti_execute_cmd "rm -f $TMNT/test_file"
  76 cti_execute_cmd "touch $TMNT/test_file"
  77 typeset -i i=0
  78 typeset -i j=100
  79 while [[ $i -lt $j ]]; do
  80   create_xattr $TMNT/test_file passwd$i /etc/passwd
  81   i=$((i+1))
  82 done
  83 
  84 #create the expected output then compare them with xattrs in the test_file
  85 
  86 i=0
  87 cp /dev/null temp_file
  88 echo SUNWattr_ro >> temp_file
  89 echo SUNWattr_rw >> temp_file
  90 while [[ $i -lt $j ]]; do
  91   echo passwd$i >> temp_file
  92   i=$((i+1))
  93 done
  94 cti_execute_cmd "sort temp_file > expected_file"
  95 
  96 #listing the directory passwd*
  97 
  98 cti_execute_cmd "runat $TMNT/test_file ls > output"
  99 cti_execute_cmd "sort output | diff expected_file -"
 100 if [[ $? != 0 ]]; then
 101 cti_fail "FAIL: do not work as expected for xattrs"
 102 return
 103 else
 104 cti_report "PASS: work as expected for xattrs"
 105 fi
 106 
 107 #delete xattrs in test_file verify these are no passwd* in test_file
 108 
 109 cti_execute_cmd "runat $TMNT/test_file rm -f passwd*"
 110 cti_execute_cmd "runat $TMNT/test_file ls passwd*"
 111 if [[ $? == 0 ]]; then
 112 cti_fail "FAIL: have passwd* xattrs in test_file unexpectedly"
 113 return
 114 else
 115 cti_report "PASS: should not have passwd* xattrs in test_file as expected"
 116 fi
 117 
 118 cti_execute_cmd "rm -f temp_file expected_file output"
 119 
 120 smbmount_clean $TMNT
 121 cti_pass "$tc_id: PASS"