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 # Copyright 2018 Nexenta Systems, Inc. All rights reserved.
24
25 #
26 # mmap test purpose
27 #
28 # __stc_assertion_start
29 #
30 # ID: mmap_008
31 #
32 # DESCRIPTION:
33 # Verify smbfs will keep the SMB FID alive when
34 # there are mapped pages associated with it.
35 #
36 # STRATEGY:
37 # 1. run "mount -F smbfs //server/public /export/mnt"
38 # 2. mkfile in smbfs
39 # 3. open, mmap & close the file, then write data into the mapped addr
40 # 4. verify the data successfully written back to smb server
41 # KEYWORDS:
42 #
43 # TESTABILITY: explicit
44 #
45 # __stc_assertion_end
46 #
47
48 . $STF_SUITE/include/libtest.ksh
49
50 tc_id="mmap008"
51 tc_desc=" Verify smbfs will keep the SMB FID alive when there are
52 mapped pages associated with it"
53 print_test_case $tc_id - $tc_desc
54
55 if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
56 [[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
57 set -x
58 fi
59
60 server=$(server_name) || return
61
62 testdir=$TDIR
63 mnt_point=$TMNT
64
65 testdir_init $testdir
66 smbmount_clean $mnt_point
67 smbmount_init $mnt_point
68
69 test_file="tmp008"
70
71 cmd="mount -F smbfs //$TUSER:$TPASS@$server/public $mnt_point"
72 cti_execute -i '' FAIL $cmd
73 if (($?!=0)); then
74 cti_fail "FAIL: $cmd"
75 return
76 else
77 cti_report "PASS: $cmd"
78 fi
79
80 # open, mmap & close a file in smbfs, then write something into it
81 cti_execute FAIL "close_wr ${mnt_point}/${test_file}"
82 if (($?!=0)); then
83 cti_fail "FAIL: $cmd"
84 return
85 else
86 cti_report "PASS: $cmd"
87 fi
88
89 # do the same thing in local file, for comparison
90 cti_execute FAIL "close_wr ${testdir}/${test_file}"
91 if (($?!=0)); then
92 cti_fail "FAIL: $cmd"
93 return
94 else
95 cti_report "PASS: $cmd"
96 fi
97
98 # diff the local file & smbfs file
99
100 cti_execute_cmd "sum ${testdir}/${test_file}"
101 read sum1 cnt1 junk < cti_stdout
102 cti_report "local sum $sum1 $cnt1"
103
104 cti_execute_cmd "sum ${mnt_point}/${test_file}"
105 read sum2 cnt2 junk < cti_stdout
106 cti_report "smbfs sum $sum2 $cnt2"
107
108 if [[ $sum1 != $sum2 ]] ; then
109 cti_fail "FAIL: the files are different"
110 return
111 else
112 cti_report "PASS: the files are the same"
113 fi
114
115 cti_execute_cmd "rm -rf $testdir/*"
116 cti_execute_cmd "rm -f ${mnt_point}/${test_file}"
117
118 smbmount_clean $mnt_point
119
120 cti_pass "${tc_id}: PASS"