1# 2# CDDL HEADER START 3# 4# The contents of this file are subject to the terms of the 5# Common Development and Distribution License (the "License"). 6# You may not use this file except in compliance with the License. 7# 8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9# or http://www.opensolaris.org/os/licensing. 10# See the License for the specific language governing permissions 11# and limitations under the License. 12# 13# When distributing Covered Code, include this CDDL HEADER in each 14# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15# If applicable, add the following below this CDDL HEADER, with the 16# fields enclosed by brackets "[]" replaced with your own identifying 17# information: Portions Copyright [yyyy] [name of copyright owner] 18# 19# CDDL HEADER END 20# 21 22# 23# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24# Use is subject to license terms. 25# 26#pragma ident "@(#)tst.predcache.ksh 1.1 06/08/28 SMI" 27 28unload() 29{ 30 svcadm disable -s svc:/network/nfs/mapid:default 31 32 modunload -i 0 33 modunload -i 0 34 modunload -i 0 35 36 if ( modinfo | grep dtrace ); then 37 svcadm enable svc:/network/nfs/mapid:default 38 echo $tst: could not unload dtrace 39 exit 1 40 fi 41 42 svcadm enable svc:/network/nfs/mapid:default 43} 44 45script1() 46{ 47 $dtrace -s /dev/stdin <<EOF 48 syscall:::entry 49 /pid != $ppid/ 50 { 51 @a[probefunc] = count(); 52 } 53 54 tick-1sec 55 /i++ == 5/ 56 { 57 exit(0); 58 } 59EOF 60} 61 62script2() 63{ 64 $dtrace -s /dev/stdin <<EOF 65 66 #pragma D option statusrate=1ms 67 68 syscall:::entry 69 /pid == $ppid/ 70 { 71 ttl++; 72 } 73 74 tick-1sec 75 /i++ == 5/ 76 { 77 exit(2); 78 } 79 80 END 81 /ttl/ 82 { 83 printf("success; ttl is %d", ttl); 84 exit(0); 85 } 86 87 END 88 /ttl == 0/ 89 { 90 printf("error -- total should be non-zero"); 91 exit(1); 92 } 93EOF 94} 95 96ppid=$$ 97dtrace=/usr/sbin/dtrace 98 99unload 100script1 & 101child=$! 102 103let waited=0 104 105while [ "$waited" -lt 5 ]; do 106 seconds=`date +%S` 107 108 if [ "$seconds" -ne "$last" ]; then 109 last=$seconds 110 let waited=waited+1 111 fi 112done 113 114wait $child 115status=$? 116 117if [ "$status" -ne 0 ]; then 118 echo $tst: first dtrace failed 119 exit $status 120fi 121 122unload 123script2 & 124child=$! 125 126let waited=0 127 128while [ "$waited" -lt 10 ]; do 129 seconds=`date +%S` 130 131 if [ "$seconds" -ne "$last" ]; then 132 last=$seconds 133 let waited=waited+1 134 fi 135done 136 137wait $child 138status=$? 139 140exit $status 141