xref: /illumos-gate/usr/src/test/smbclient-tests/tests/smbfs/misc/tp_misc_003.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_003
29#
30# DESCRIPTION:
31#	Verify reconnect after connection to server is lost.
32#
33# STRATEGY:
34#	1. run "mount -F smbfs //server/public /export/mnt"
35#	2. create a file
36#	3. force the connection to drop
37#	4. read the file (from step 2)
38#
39
40. $STF_SUITE/include/libtest.ksh
41
42tc_id="misc003"
43tc_desc=" Verify reconnect after connection loss."
44print_test_case $tc_id - $tc_desc
45
46if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
47	[[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
48    set -x
49fi
50
51server=$(server_name)||return
52
53testdir_init $TDIR
54smbmount_clean $TMNT
55smbmount_init $TMNT
56
57#	1. run "mount -F smbfs //server/public /export/mnt"
58
59cmd="mount -F smbfs //$TUSER:$TPASS@$server/public $TMNT"
60cti_execute -i '' FAIL $cmd
61if [[ $? != 0 ]]; then
62	cti_fail "FAIL: $cmd"
63	return
64else
65	cti_report "PASS: $cmd"
66fi
67
68#	2. create a file
69
70cmd="touch $TMNT/$tc_id"
71cti_execute_cmd $cmd
72if [[ $? != 0 ]]; then
73	cti_fail "FAIL: $cmd"
74	return
75fi
76
77#	3. force the connection to drop
78#	(SMB uses port: 445)
79
80cmd="abort_conn -p 445 $server "
81cti_execute_cmd sudo -n $cmd
82if [[ $? != 0 ]]; then
83	cti_fail "FAIL: $cmd"
84	return
85fi
86sleep 2
87
88#	Would be nice to verify the connections are IDLE,
89#	but it can be tricky to identify which is ours.
90#	For now, just log the connection states here.
91#	Our connetion will show state "IDLE".
92
93cmd="echo '::nsmb_vc' |sudo -n mdb -k"
94cti_execute_cmd $cmd
95if [[ $? != 0 ]]; then
96	cti_fail "FAIL: $cmd"
97	return
98fi
99
100#	4. read the file (from step 2)
101#	This will initiate a reconnect.
102
103cmd="ls -l $TMNT/$tc_id"
104cti_execute_cmd $cmd
105if [[ $? != 0 ]]; then
106	cti_fail "FAIL: $cmd"
107	return
108fi
109
110cti_execute_cmd "rm -rf $TMNT/*"
111
112smbmount_clean $TMNT
113cti_pass "$tc_id: PASS"
114