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