1#!/usr/local/bin/ksh93 -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# 24# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26. $STF_SUITE/include/libtest.kshlib 27 28# ########################################################################## 29# 30# __stc_assertion_start 31# 32# ID: mmap_write_001_pos 33# 34# DESCRIPTION: 35# Writing to a file and mmaping that file at the 36# same time does not result in a deadlock. 37# 38# STRATEGY: 39# 1. Make sure this test executes on multi-processes system. 40# 2. Call mmapwrite binary. 41# 3. wait 120s and make sure the test file existed. 42# 43# TESTABILITY: explicit 44# 45# TEST_AUTOMATION_LEVEL: automated 46# 47# CODING_STATUS: COMPLETED (2005-07-04) 48# 49# __stc_assertion_end 50# 51################################################################################ 52 53verify_runnable "both" 54 55# Default is 120 seconds or 2 minutes 56WAITTIME=${WAITTIME-120} 57 58log_assert "write()s to a file and mmap() that file at the same time does not "\ 59 "result in a deadlock." 60 61# Detect and make sure this test must be executed on a multi-process system 62NCPUS=`sysctl -a | awk -F '"' '/cpu count="[0-9+]"/ {print $2; exit}'` 63if [[ $? -ne 0 || -z $NCPUS || $NCPUS -le 1 ]]; then 64 log_unsupported "This test must be executed on a multi-processor system." 65fi 66 67log_must $CHMOD 777 $TESTDIR 68$MMAPWRITE $TESTDIR/$TESTFILE & 69PID_MMAPWRITE=$! 70log_note "$MMAPWRITE $TESTDIR/$TESTFILE pid: $PID_MMAPWRITE" 71log_must $SLEEP 10 72 73typeset -i i=0 74while (( i < $WAITTIME )); do 75 if ! $PS -ef | $PGREP $MMAPWRITE > /dev/null ; then 76 log_must $WAIT $PID_MMAPWRITE 77 break 78 fi 79 $SLEEP 1 80 (( i += 1 )) 81done 82 83if $PS -ef | $PGREP $MMAPWRITE > /dev/null ; then 84 log_must $KILL -9 $PID_MMAPWRITE 85fi 86log_must $LS -l $TESTDIR/$TESTFILE 87 88log_pass "write(2) a mmap(2)'ing file succeeded." 89