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 51tc_id="mmap010" 52tc_desc=" Verify file read/write is coherent with mmap" 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 60# Note: size should be prime (see cp_mmap) 61size=1123k 62 63server=$(server_name) || return 64 65testdir=$TDIR 66mnt_point=$TMNT 67 68testdir_init $testdir 69smbmount_clean $mnt_point 70smbmount_init $mnt_point 71 72test_file="tmp010" 73 74cmd="mount -F smbfs //$TUSER:$TPASS@$server/public $mnt_point" 75cti_execute -i '' FAIL $cmd 76if (($?!=0)); then 77 cti_fail "FAIL: $cmd" 78 return 79else 80 cti_report "PASS: $cmd" 81fi 82 83# open, mmap a file in smbfs, then perform the 2 tests mentioned above 84cti_execute FAIL "rw_mmap -n $size -f ${mnt_point}/${test_file}" 85if (($?!=0)); then 86 cti_fail "FAIL: $cmd" 87 return 88else 89 cti_report "PASS: $cmd" 90fi 91 92# do the same thing in local file, for comparison 93cti_execute FAIL "rw_mmap -n $size -f ${testdir}/${test_file}" 94if (($?!=0)); then 95 cti_fail "FAIL: $cmd" 96 return 97else 98 cti_report "PASS: $cmd" 99fi 100 101# diff the local file & smbfs file 102 103cti_execute_cmd "sum ${testdir}/${test_file}" 104read sum1 cnt1 junk < cti_stdout 105cti_report "local sum $sum1 $cnt1" 106 107cti_execute_cmd "sum ${mnt_point}/${test_file}" 108read sum2 cnt2 junk < cti_stdout 109cti_report "smbfs sum $sum2 $cnt2" 110 111if [[ $sum1 != $sum2 ]] ; then 112 cti_fail "FAIL: the files are different" 113 return 114else 115 cti_report "PASS: the files are the same" 116fi 117 118cti_execute_cmd "rm -rf $testdir/*" 119cti_execute_cmd "rm -f ${mnt_point}/${test_file}" 120 121smbmount_clean $mnt_point 122 123cti_pass "${tc_id}: PASS" 124