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