xref: /illumos-gate/usr/src/test/smbclient-tests/tests/smbfs/misc/tp_misc_002.ksh (revision 96c8483a3fb53529bbf410957b0ad69cfb5d9229)
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: misc_002
29#
30# DESCRIPTION:
31#	Verify attribute cache invalidation after
32#	some higher-level directory is renamed.
33#
34# STRATEGY:
35#	1. run "mount -F smbfs //server/public /export/mnt"
36#	2. mkdir a/b/c/d
37#	3. mv a z
38#	4. mkdir a
39#	5. verify stat of a/b/c shows ENOENT
40#	(All steps must be completed in less than a few seconds.)
41#
42
43. $STF_SUITE/include/libtest.ksh
44
45tc_id="misc002"
46tc_desc=" Verify attribute cache invalidation under renamed directory"
47print_test_case $tc_id - $tc_desc
48
49if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
50	[[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
51    set -x
52fi
53
54server=$(server_name)||return
55
56testdir_init $TDIR
57smbmount_clean $TMNT
58smbmount_init $TMNT
59
60cmd="mount -F smbfs //$TUSER:$TPASS@$server/public $TMNT"
61cti_execute -i '' FAIL $cmd
62if [[ $? != 0 ]]; then
63	cti_fail "FAIL: smbmount can't mount the public share"
64	return
65else
66	cti_report "PASS: smbmount can mount the public share"
67fi
68
69cmd="mkdir -p $TMNT/a/b/c"
70cti_execute_cmd $cmd
71if [[ $? != 0 ]]; then
72	cti_fail "FAIL: $cmd"
73	return
74fi
75
76cmd="mv $TMNT/a $TMNT/z"
77cti_execute_cmd $cmd
78if [[ $? != 0 ]]; then
79	cti_fail "FAIL: $cmd"
80	return
81fi
82
83cmd="mkdir $TMNT/a"
84cti_execute_cmd $cmd
85if [[ $? != 0 ]]; then
86	cti_fail "FAIL: $cmd"
87	return
88fi
89
90# a should exist, but should have nothing under it.
91if [[ -d $TMNT/a/b/c ]] ; then
92	cti_fail "FAIL: a/b/c/d still exists"
93	return
94fi
95
96# z should exist, and z/b/c
97if [[ ! -d $TMNT/z ]] ; then
98	cti_fail "FAIL: dir 'z' missing"
99	return
100fi
101if [[ ! -d $TMNT/z/b/c ]] ; then
102	cti_fail "FAIL: dir 'z/b/c/d' missing"
103	return
104fi
105
106cti_execute_cmd "rm -rf $TMNT/*"
107
108smbmount_clean $TMNT
109cti_pass "$tc_id: PASS"
110