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_010
31 #
32 # DESCRIPTION:
33 # Verify file read/write is coherent with mmap.
34 #
35 # STRATEGY:
36 # 1. run "mount -F smbfs //server/public /export/mnt"
37 # 2. open and mmap a test file
38 # 3. write something into test file, then check the result through mmap
39 # 4. memset some parts of mmaped addr, then check the result through
40 # file read
41 # 5. close test file
42 # KEYWORDS:
43 #
44 # TESTABILITY: explicit
45 #
46 # __stc_assertion_end
47 #
48
49 . $STF_SUITE/include/libtest.ksh
50
51 tc_id="mmap010"
52 tc_desc=" Verify file read/write is coherent with mmap"
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 # Note: size should be prime (see cp_mmap)
61 size=1123k
62
63 server=$(server_name) || return
64
65 testdir=$TDIR
66 mnt_point=$TMNT
67
68 testdir_init $testdir
69 smbmount_clean $mnt_point
70 smbmount_init $mnt_point
71
72 test_file="tmp010"
73
74 cmd="mount -F smbfs //$TUSER:$TPASS@$server/public $mnt_point"
75 cti_execute -i '' FAIL $cmd
76 if (($?!=0)); then
77 cti_fail "FAIL: $cmd"
78 return
79 else
80 cti_report "PASS: $cmd"
81 fi
82
83 # open, mmap a file in smbfs, then perform the 2 tests mentioned above
84 cti_execute FAIL "rw_mmap -n $size -f ${mnt_point}/${test_file}"
85 if (($?!=0)); then
86 cti_fail "FAIL: $cmd"
87 return
88 else
89 cti_report "PASS: $cmd"
90 fi
91
92 # do the same thing in local file, for comparison
93 cti_execute FAIL "rw_mmap -n $size -f ${testdir}/${test_file}"
94 if (($?!=0)); then
95 cti_fail "FAIL: $cmd"
96 return
97 else
98 cti_report "PASS: $cmd"
99 fi
100
101 # diff the local file & smbfs file
102
103 cti_execute_cmd "sum ${testdir}/${test_file}"
104 read sum1 cnt1 junk < cti_stdout
105 cti_report "local sum $sum1 $cnt1"
106
107 cti_execute_cmd "sum ${mnt_point}/${test_file}"
108 read sum2 cnt2 junk < cti_stdout
109 cti_report "smbfs sum $sum2 $cnt2"
110
111 if [[ $sum1 != $sum2 ]] ; then
112 cti_fail "FAIL: the files are different"
113 return
114 else
115 cti_report "PASS: the files are the same"
116 fi
117
118 cti_execute_cmd "rm -rf $testdir/*"
119 cti_execute_cmd "rm -f ${mnt_point}/${test_file}"
120
121 smbmount_clean $mnt_point
122
123 cti_pass "${tc_id}: PASS"