xref: /illumos-gate/usr/src/test/smbclient-tests/tests/smbmount/tp_smbmount_005.ksh (revision 20a7641f9918de8574b8b3b47dbe35c4bfc78df1)
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: smbmount_005
29#
30# DESCRIPTION:
31#        Verify "mount -F smbfs -O" work well
32#
33# STRATEGY:
34#	1. create user "$AUSER" and "$BUSER"
35#	2. run "mount -F smbfs //$AUSER:$APASS@$server/a_share $TMNT"
36#	3. mount successfully
37#	4. run "mount -F smbfs -O //$BUSER:$BPASS@$server/b_share $TMNT"
38#	5. mount successfully
39#
40
41. $STF_SUITE/include/libtest.ksh
42
43tc_id="smbmount005"
44tc_desc="-O work well"
45print_test_case $tc_id - $tc_desc
46
47if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
48	[[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
49    set -x
50fi
51
52server=$(server_name) || return
53
54testdir_init $TDIR
55smbmount_clean $TMNT
56smbmount_init $TMNT
57
58cmd="mount -F smbfs -o noprompt //$AUSER:$APASS@$server/a_share $TMNT"
59cti_execute -i '' FAIL $cmd
60if [[ $? != 0 ]]; then
61	cti_fail "FAIL: smbmount can't mount the share a_share with user $AUSER"
62	return
63else
64	cti_report "PASS: smbmount can mount the share a_share with user $AUSER"
65fi
66
67smbmount_check $TMNT || return
68
69# cp file
70cmd="cp /usr/bin/ls $TMNT/ls_file"
71cti_execute_cmd $cmd
72if [[ $? != 0 ]]; then
73	cti_fail "FAIL: failed to cp the /usr/bin/ls file"
74	return
75else
76	cti_report "PASS: cp the /usr/bin/ls file successfully"
77fi
78
79cmd="diff /usr/bin/ls $TMNT/ls_file"
80cti_execute_cmd $cmd
81if [[ $? != 0 ]]; then
82	cti_fail "FAIL: the file /usr/bin/ls is different with file ls_file"
83	return
84else
85	cti_report "PASS: the file /usr/bin/ls is same to the ls_file file"
86fi
87
88cmd="mount -F smbfs -O -o noprompt //$BUSER:$BPASS@$server/a_share $TMNT"
89cti_execute -i '' FAIL sudo -n $cmd
90if [[ $? != 0 ]]; then
91	cti_fail "FAIL: smbmount can't mount the share a_share on the same point twice with -O option"
92	return
93else
94	cti_report "PASS: smbmount can mount the share a_share on the same point twice with -O option"
95fi
96
97smbmount_check $TMNT || {
98  cti_execute_cmd sudo -n "umount $TMNT"
99  return 1
100}
101
102cmd="diff /usr/bin/ls $TMNT/ls_file"
103cti_execute_cmd sudo -n $cmd
104if [[ $? != 0 ]]; then
105	cti_fail "FAIL: the second diff file /usr/bin/ls is different with the ls_file file"
106	return
107else
108	cti_report "PASS: the second diff file /usr/bin/ls is same to the ls_file file"
109fi
110
111# cp file
112cmd="cp /usr/bin/rm $TMNT/rm_file"
113cti_execute_cmd sudo -n $cmd
114if [[ $? != 0 ]]; then
115	cti_fail "FAIL: failed to cp the /usr/bin/rm file"
116	return
117else
118	cti_report "PASS: cp the file /usr/bin/rm successfully"
119fi
120
121cmd="diff /usr/bin/rm $TMNT/rm_file"
122cti_execute_cmd sudo -n $cmd
123if [[ $? != 0 ]]; then
124	cti_fail "FAIL: the file /usr/bin/rm is different with the rm_file file"
125	return
126else
127	cti_report "PASS: the file /usr/bin/rm is same to the rm_file file"
128fi
129
130cmd="umount $TMNT"
131cti_execute_cmd sudo -n $cmd
132if [[ $? != 0 ]]; then
133	cti_fail "FAIL: the first umount $TMNT is failed "
134	return
135else
136	cti_report "PASS: the first umount $TMNT is successful"
137fi
138
139cmd="diff /usr/bin/ls $TMNT/ls_file"
140cti_execute_cmd sudo -n $cmd
141if [[ $? != 0 ]]; then
142	cti_fail "FAIL:the third diff:file /usr/bin/ls is different with file ls_file"
143	return
144else
145	cti_report "PASS:the third diff:file /usr/bin/ls is same to file ls_file"
146fi
147cmd="diff /usr/bin/rm $TMNT/rm_file"
148cti_execute_cmd sudo -n $cmd
149if [[ $? != 0 ]]; then
150	cti_fail "FAIL: the fourth diff:file /usr/bin/rm is different with file rm_file"
151	return
152else
153	cti_report "PASS: the fourth diff:file /usr/bin/rm is same to the rm_file file"
154fi
155
156cmd="umount $TMNT"
157cti_execute_cmd sudo -n $cmd
158if [[ $? != 0 ]]; then
159	cti_fail "FAIL: the second umount $TMNT is failed"
160	return
161else
162	cti_report "PASS: the second umount $TMNT is successful"
163fi
164
165smbmount_clean $TMNT
166cti_pass "${tc_id}: PASS"
167