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_009
31 #
32 # DESCRIPTION:
33 # Verify smbfs will help sync the dirty pages to the file and close it, including otW close, if the userland does not explicitly do it.
34 #
35 # STRATEGY:
36 # 1. run "mount -F smbfs //server/public /export/mnt"
37 # 2. mkfile in smbfs
38 # 3. open, mmap the file, then write some data into the mapped addr
39 # 4. exit without close the file
40 # 5. 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="mmap009"
51 tc_desc=" Verify smbfs will sync the dirty pages to the file and close it,
52 including otW close, if the userland does not explicitly do 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="tmp009"
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 a file in smbfs, then write something into it,
81 # exit without msync/munmap/close
82 cti_execute FAIL "no_close ${mnt_point}/${test_file}"
83 if (($?!=0)); then
84 cti_fail "FAIL: $cmd"
85 return
86 else
87 cti_report "PASS: $cmd"
88 fi
89
90 # do the same thing in local file, for comparison
91 cti_execute FAIL "no_close ${testdir}/${test_file}"
92 if (($?!=0)); then
93 cti_fail "FAIL: $cmd"
94 return
95 else
96 cti_report "PASS: $cmd"
97 fi
98
99 # diff the local file & smbfs file
100
101 cti_execute_cmd "sum ${testdir}/${test_file}"
102 read sum1 cnt1 junk < cti_stdout
103 cti_report "local sum $sum1 $cnt1"
104
105 cti_execute_cmd "sum ${mnt_point}/${test_file}"
106 read sum2 cnt2 junk < cti_stdout
107 cti_report "smbfs sum $sum2 $cnt2"
108
109 if [[ $sum1 != $sum2 ]] ; then
110 cti_fail "FAIL: the files are different"
111 return
112 else
113 cti_report "PASS: the files are the same"
114 fi
115
116 cti_execute_cmd "rm -rf $testdir/*"
117 cti_execute_cmd "rm -f ${mnt_point}/${test_file}"
118
119 smbmount_clean $mnt_point
120
121 cti_pass "${tc_id}: PASS"