xref: /illumos-gate/usr/src/test/smbclient-tests/tests/smbfs/mmap/tp_mmap_002.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_002
31#
32# DESCRIPTION:
33#        Verify smbfs-mmap can putpage without block i/o
34#
35# STRATEGY:
36#       1. run "mount -F smbfs //server/public /export/mnt"
37#       2. mkfile in local testdir
38#	3. with discrete mmap, cp the file into smbfs
39#	4. diff src file and des file
40# KEYWORDS:
41#
42# TESTABILITY: explicit
43#
44# __stc_assertion_end
45#
46
47. $STF_SUITE/include/libtest.ksh
48
49tc_id="mmap002"
50tc_desc=" Verify smbfs-mmap can putpage without block i/o"
51print_test_case $tc_id - $tc_desc
52
53if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
54	[[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
55    set -x
56fi
57
58# Note: size should be prime (see cp_mmap)
59size=1123k
60
61server=$(server_name) || return
62
63testdir=$TDIR
64mnt_point=$TMNT
65
66testdir_init $testdir
67smbmount_clean $mnt_point
68smbmount_init $mnt_point
69
70test_file="tmp002"
71
72cmd="mount -F smbfs //$TUSER:$TPASS@$server/public $mnt_point"
73cti_execute -i '' FAIL $cmd
74if (($?!=0)); then
75	cti_fail "FAIL: smbmount can't mount the public share"
76	return
77else
78	cti_report "PASS: smbmount can mount the public share"
79fi
80
81# make a local file
82
83cmd="mkfile_mmap -n $size -f ${testdir}/${test_file}"
84cti_execute FAIL $cmd
85if (($?!=0)); then
86	cti_fail "FAIL: $cmd"
87	return
88else
89	cti_report "PASS: $cmd"
90fi
91
92# discontinuously mmap and read the local file, then write into the smbfs file
93
94cmd="cp_mmap -t d -f ${testdir}/${test_file} ${mnt_point}/${test_file}"
95cti_execute FAIL $cmd
96if (($?!=0)); then
97	cti_fail "FAIL: $cmd"
98	return
99else
100	cti_report "PASS: $cmd"
101fi
102
103# diff the local file & smbfs file
104
105cti_execute_cmd "sum ${testdir}/${test_file}"
106read sum1 cnt1 junk < cti_stdout
107cti_report "local sum $sum1 $cnt1"
108
109cti_execute_cmd "sum ${mnt_point}/${test_file}"
110read sum2 cnt2 junk < cti_stdout
111cti_report "smbfs sum $sum2 $cnt2"
112
113if [[ $sum1 != $sum2 ]] ; then
114        cti_fail "FAIL: the files are different"
115        return
116else
117        cti_report "PASS: the files are the same"
118fi
119
120cti_execute_cmd "rm -rf $testdir/*"
121cti_execute_cmd "rm -f ${mnt_point}/${test_file}"
122
123smbmount_clean $mnt_point
124
125cti_pass "${tc_id}: PASS"
126