xref: /illumos-gate/usr/src/test/smbclient-tests/tests/smbfs/mmap/tp_mmap_008.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# 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
50tc_id="mmap008"
51tc_desc=" Verify smbfs will keep the SMB FID alive when there are
52 mapped pages associated with it"
53print_test_case $tc_id - $tc_desc
54
55if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
56	[[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
57    set -x
58fi
59
60server=$(server_name) || return
61
62testdir=$TDIR
63mnt_point=$TMNT
64
65testdir_init $testdir
66smbmount_clean $mnt_point
67smbmount_init $mnt_point
68
69test_file="tmp008"
70
71cmd="mount -F smbfs //$TUSER:$TPASS@$server/public $mnt_point"
72cti_execute -i '' FAIL $cmd
73if (($?!=0)); then
74	cti_fail "FAIL: $cmd"
75	return
76else
77	cti_report "PASS: $cmd"
78fi
79
80# open, mmap & close a file in smbfs, then write something into it
81cti_execute FAIL "close_wr ${mnt_point}/${test_file}"
82if (($?!=0)); then
83	cti_fail "FAIL: $cmd"
84	return
85else
86	cti_report "PASS: $cmd"
87fi
88
89# do the same thing in local file, for comparison
90cti_execute FAIL "close_wr ${testdir}/${test_file}"
91if (($?!=0)); then
92	cti_fail "FAIL: $cmd"
93	return
94else
95	cti_report "PASS: $cmd"
96fi
97
98# diff the local file & smbfs file
99
100cti_execute_cmd "sum ${testdir}/${test_file}"
101read sum1 cnt1 junk < cti_stdout
102cti_report "local sum $sum1 $cnt1"
103
104cti_execute_cmd "sum ${mnt_point}/${test_file}"
105read sum2 cnt2 junk < cti_stdout
106cti_report "smbfs sum $sum2 $cnt2"
107
108if [[ $sum1 != $sum2 ]] ; then
109        cti_fail "FAIL: the files are different"
110        return
111else
112        cti_report "PASS: the files are the same"
113fi
114
115cti_execute_cmd "rm -rf $testdir/*"
116cti_execute_cmd "rm -f ${mnt_point}/${test_file}"
117
118smbmount_clean $mnt_point
119
120cti_pass "${tc_id}: PASS"
121