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# This script ensures that cputrack(1M) will fail to start when the cpc 29210753Srpaulo# provider has active enablings. 30210753Srpaulo# 31210753Srpaulo# The script will fail if: 32210753Srpaulo# 1) The system under test does not define the 'PAPI_tot_ins' event. 33210753Srpaulo# 34210753Srpaulo 35210753Srpauloscript() 36210753Srpaulo{ 37210753Srpaulo $dtrace -o $dtraceout -s /dev/stdin <<EOF 38210753Srpaulo #pragma D option bufsize=128k 39210753Srpaulo 40210753Srpaulo cpc:::PAPI_tot_ins-all-10000 41210753Srpaulo { 42210753Srpaulo @[probename] = count(); 43210753Srpaulo } 44210753SrpauloEOF 45210753Srpaulo} 46210753Srpaulo 47210753Srpaulo 48210753Srpauloif [ $# != 1 ]; then 49210753Srpaulo echo expected one argument: '<'dtrace-path'>' 50210753Srpaulo exit 2 51210753Srpaulofi 52210753Srpaulo 53210753Srpaulodtrace=$1 54210753Srpaulodtraceout=/tmp/dtrace.out.$$ 55210753Srpauloscript 2>/dev/null & 56210753Srpaulotimeout=15 57210753Srpaulo 58210753Srpaulo# 59210753Srpaulo# Sleep while the above script fires into life. To guard against dtrace dying 60210753Srpaulo# and us sleeping forever we allow 15 secs for this to happen. This should be 61210753Srpaulo# enough for even the slowest systems. 62210753Srpaulo# 63210753Srpaulowhile [ ! -f $dtraceout ]; do 64210753Srpaulo sleep 1 65210753Srpaulo timeout=$(($timeout-1)) 66210753Srpaulo if [ $timeout -eq 0 ]; then 67210753Srpaulo echo "dtrace failed to start. Exiting." 68210753Srpaulo exit 1 69210753Srpaulo fi 70210753Srpaulodone 71210753Srpaulo 72210753Srpaulocputrack -c PAPI_tot_ins sleep 10 73210753Srpaulostatus=$? 74210753Srpaulo 75210753Srpaulorm $dtraceout 76210753Srpaulo 77210753Srpauloexit $status 78