1*3276Sjhaslam#!/bin/ksh -p 2*3276Sjhaslam# 3*3276Sjhaslam# CDDL HEADER START 4*3276Sjhaslam# 5*3276Sjhaslam# The contents of this file are subject to the terms of the 6*3276Sjhaslam# Common Development and Distribution License (the "License"). 7*3276Sjhaslam# You may not use this file except in compliance with the License. 8*3276Sjhaslam# 9*3276Sjhaslam# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*3276Sjhaslam# or http://www.opensolaris.org/os/licensing. 11*3276Sjhaslam# See the License for the specific language governing permissions 12*3276Sjhaslam# and limitations under the License. 13*3276Sjhaslam# 14*3276Sjhaslam# When distributing Covered Code, include this CDDL HEADER in each 15*3276Sjhaslam# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*3276Sjhaslam# If applicable, add the following below this CDDL HEADER, with the 17*3276Sjhaslam# fields enclosed by brackets "[]" replaced with your own identifying 18*3276Sjhaslam# information: Portions Copyright [yyyy] [name of copyright owner] 19*3276Sjhaslam# 20*3276Sjhaslam# CDDL HEADER END 21*3276Sjhaslam# 22*3276Sjhaslam 23*3276Sjhaslam# 24*3276Sjhaslam# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 25*3276Sjhaslam# Use is subject to license terms. 26*3276Sjhaslam# 27*3276Sjhaslam# ident "%Z%%M% %I% %E% SMI" 28*3276Sjhaslam# 29*3276Sjhaslam 30*3276Sjhaslam# 31*3276Sjhaslam# This script primarily tests that the ::dtrace dcmd is not dumping 32*3276Sjhaslam# core. We don't try to make sense of the output of the dcmd nor 33*3276Sjhaslam# do we check to see if any output is produced. We merely see if 34*3276Sjhaslam# mdb fails with a fatal failure. 35*3276Sjhaslam# 36*3276Sjhaslam 37*3276Sjhaslamscript() 38*3276Sjhaslam{ 39*3276Sjhaslam $dtrace -o $dtraceout -s /dev/stdin <<EOF 40*3276Sjhaslam syscall:::entry 41*3276Sjhaslam { 42*3276Sjhaslam @[probefunc] = count(); 43*3276Sjhaslam } 44*3276SjhaslamEOF 45*3276Sjhaslam} 46*3276Sjhaslam 47*3276Sjhaslammdbdoit() 48*3276Sjhaslam{ 49*3276Sjhaslam mdb -k <<EOF 50*3276Sjhaslam ::walk dtrace_state | ::dtrace 51*3276SjhaslamEOF 52*3276Sjhaslam status=$? 53*3276Sjhaslam kill $script 54*3276Sjhaslam} 55*3276Sjhaslam 56*3276Sjhaslamif [ $# != 1 ]; then 57*3276Sjhaslam echo expected one argument: '<'dtrace-path'>' 58*3276Sjhaslam exit 2 59*3276Sjhaslamfi 60*3276Sjhaslam 61*3276Sjhaslamdtrace=$1 62*3276Sjhaslamdtraceout=/tmp/dtrace.out.$$ 63*3276Sjhaslamscript & 64*3276Sjhaslamscript=$! 65*3276Sjhaslamtimeout=15 66*3276Sjhaslam 67*3276Sjhaslam# 68*3276Sjhaslam# Sleep while the above script fires into life. To guard against dtrace dying 69*3276Sjhaslam# and us sleeping forever we allow 15 secs for this to happen. This should be 70*3276Sjhaslam# enough for even the slowest systems. 71*3276Sjhaslam# 72*3276Sjhaslamwhile [ ! -f $dtraceout ]; do 73*3276Sjhaslam sleep 1 74*3276Sjhaslam timeout=$(($timeout-1)) 75*3276Sjhaslam if [ $timeout -eq 0 ]; then 76*3276Sjhaslam echo "dtrace failed to start. Exiting." 77*3276Sjhaslam exit 1 78*3276Sjhaslam fi 79*3276Sjhaslamdone 80*3276Sjhaslam 81*3276Sjhaslammdbdoit 82*3276Sjhaslam 83*3276Sjhaslamrm $dtraceout 84*3276Sjhaslam 85*3276Sjhaslamexit $status 86