1210753Srpaulo#!/bin/ksh 2210753Srpaulo# 3210753Srpaulo# CDDL HEADER START 4210753Srpaulo# 5210753Srpaulo# The contents of this file are subject to the terms of the 6210753Srpaulo# Common Development and Distribution License (the "License"). 7210753Srpaulo# You may not use this file except in compliance with the License. 8210753Srpaulo# 9210753Srpaulo# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10210753Srpaulo# or http://www.opensolaris.org/os/licensing. 11210753Srpaulo# See the License for the specific language governing permissions 12210753Srpaulo# and limitations under the License. 13210753Srpaulo# 14210753Srpaulo# When distributing Covered Code, include this CDDL HEADER in each 15210753Srpaulo# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16210753Srpaulo# If applicable, add the following below this CDDL HEADER, with the 17210753Srpaulo# fields enclosed by brackets "[]" replaced with your own identifying 18210753Srpaulo# information: Portions Copyright [yyyy] [name of copyright owner] 19210753Srpaulo# 20210753Srpaulo# CDDL HEADER END 21210753Srpaulo# 22210753Srpaulo 23210753Srpaulo# 24210753Srpaulo# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25210753Srpaulo# Use is subject to license terms. 26210753Srpaulo# 27210753Srpaulo 28210753Srpaulo 29210753Srpaulo# 30210753Srpaulo# This tests that cpustat(1) should fail to start if the cpc provider 31210753Srpaulo# is already calling the shots. 32210753Srpaulo# 33210753Srpaulo# This script will fail if: 34210753Srpaulo# 1) The system under test does not define the 'PAPI_tot_ins' 35210753Srpaulo# generic event. 36210753Srpaulo 37210753Srpauloscript() 38210753Srpaulo{ 39210753Srpaulo $dtrace -o $dtraceout -s /dev/stdin <<EOF 40210753Srpaulo #pragma D option bufsize=128k 41210753Srpaulo 42210753Srpaulo cpc:::PAPI_tot_ins-all-10000 43210753Srpaulo { 44210753Srpaulo @[probename] = count(); 45210753Srpaulo } 46210753SrpauloEOF 47210753Srpaulo} 48210753Srpaulo 49210753Srpauloif [ $# != 1 ]; then 50210753Srpaulo echo expected one argument: '<'dtrace-path'>' 51210753Srpaulo exit 2 52210753Srpaulofi 53210753Srpaulo 54210753Srpaulodtrace=$1 55210753Srpaulodtraceout=/tmp/dtrace.out.$$ 56210753Srpauloscript 2>/dev/null & 57210753Srpaulotimeout=15 58210753Srpaulo 59210753Srpaulo# 60210753Srpaulo# Sleep while the above script fires into life. To guard against dtrace dying 61210753Srpaulo# and us sleeping forever we allow 15 secs for this to happen. This should be 62210753Srpaulo# enough for even the slowest systems. 63210753Srpaulo# 64210753Srpaulowhile [ ! -f $dtraceout ]; do 65210753Srpaulo sleep 1 66210753Srpaulo timeout=$(($timeout-1)) 67210753Srpaulo if [ $timeout -eq 0 ]; then 68210753Srpaulo echo "dtrace failed to start. Exiting." 69210753Srpaulo exit 1 70210753Srpaulo fi 71210753Srpaulodone 72210753Srpaulo 73210753Srpaulocpustat -c PAPI_tot_ins 1 5 74210753Srpaulostatus=$? 75210753Srpaulo 76210753Srpaulorm $dtraceout 77210753Srpaulo 78210753Srpauloexit $status 79