tst.noreapring.ksh revision 278009
1185380Ssam# 2185380Ssam# CDDL HEADER START 3185380Ssam# 4185380Ssam# The contents of this file are subject to the terms of the 5185380Ssam# Common Development and Distribution License (the "License"). 6185380Ssam# You may not use this file except in compliance with the License. 7185380Ssam# 8185380Ssam# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9185380Ssam# or http://www.opensolaris.org/os/licensing. 10185380Ssam# See the License for the specific language governing permissions 11185380Ssam# and limitations under the License. 12185380Ssam# 13185380Ssam# When distributing Covered Code, include this CDDL HEADER in each 14185380Ssam# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15185380Ssam# If applicable, add the following below this CDDL HEADER, with the 16185380Ssam# fields enclosed by brackets "[]" replaced with your own identifying 17203158Srpaulo# information: Portions Copyright [yyyy] [name of copyright owner] 18185380Ssam# 19185380Ssam# CDDL HEADER END 20185380Ssam# 21185380Ssam 22185380Ssam# 23185380Ssam# Copyright (c) 2011, Joyent, Inc. All rights reserved. 24185380Ssam# 25185380Ssam 26185380Ssamif [ $# != 1 ]; then 27185380Ssam echo expected one argument: '<'dtrace-path'>' 28185380Ssam exit 2 29185380Ssamfi 30185380Ssam 31185380Ssamdtrace=$1 32185380SsamDIR=/var/tmp/dtest.$$ 33185380Ssam 34185380Ssammkdir $DIR 35185380Ssamcd $DIR 36185380Ssam 37185380Ssamcat > test.c <<EOF 38185380Ssam#include <unistd.h> 39185380Ssam#include <sys/sdt.h> 40185380Ssam 41185380Ssamint 42185380Ssammain(int argc, char **argv) 43185380Ssam{ 44185380Ssam DTRACE_PROBE(test_prov, probe1); 45185380Ssam} 46185380SsamEOF 47185380Ssam 48185380Ssamcat > prov.d <<EOF 49185380Ssamprovider test_prov { 50185380Ssam probe probe1(); 51185380Ssam}; 52185380SsamEOF 53185380Ssam 54185380Ssamcc -c test.c 55185380Ssamif [ $? -ne 0 ]; then 56185380Ssam print -u2 "failed to compile test.c" 57185380Ssam exit 1 58185380Ssamfi 59185380Ssam$dtrace -G -32 -s prov.d test.o 60185380Ssamif [ $? -ne 0 ]; then 61185380Ssam print -u2 "failed to create DOF" 62185380Ssam exit 1 63185380Ssamfi 64185380Ssamcc -o test test.o prov.o 65185380Ssamif [ $? -ne 0 ]; then 66185380Ssam print -u2 "failed to link final executable" 67185380Ssam exit 1 68185380Ssamfi 69185380Ssam 70185380Ssamscript() 71185380Ssam{ 72185380Ssam $dtrace -Zwqs /dev/stdin <<EOF 73185380Ssam test_prov*::: 74185380Ssam { 75185380Ssam probeid = id; 76185380Ssam } 77185380Ssam 78185380Ssam tick-1sec 79185380Ssam /probeid == 0/ 80185380Ssam { 81185380Ssam printf("launching test\n"); 82185380Ssam system("./test"); 83185380Ssam } 84185380Ssam 85185380Ssam tick-1sec 86185380Ssam /probeid != 0/ 87185380Ssam { 88185380Ssam printf("attempting re-enabling\n"); 89185380Ssam system("dtrace -e -x errtags -i %d", probeid); 90185380Ssam attempts++; 91185380Ssam } 92185380Ssam 93185380Ssam tick-1sec 94185380Ssam /attempts > 10/ 95185380Ssam { 96185380Ssam exit(0); 97185380Ssam } 98185380SsamEOF 99185380Ssam} 100185380Ssam 101185380Ssam$dtrace -x bufpolicy=ring -ZwqP test_prov\* > /dev/null 2>&1 & 102185380Ssambackground=$! 103185380Ssamecho launched ring buffered enabling as pid $background 104185380Ssamscript 2>&1 | tee test.out 105185380Ssam 106185380Ssam# 107185380Ssam# It should be true that our probe was not reaped after the provider was made 108185380Ssam# defunct: the active ring buffer in the earlier enabling prevents reaping of 109185380Ssam# any of the earlier enabling's ECBs. 110185380Ssam# 111185380Ssamstatus=0 112185380Ssam 113185380Ssamif grep D_PDESC_INVAL test.out 2> /dev/null 1>&2 ; then 114185380Ssam status=1 115185380Ssamelse 116185380Ssam grep D_PROC_GRAB test.out 2> /dev/null 1>&2 117185380Ssam status=$? 118185380Ssamfi 119185380Ssam 120185380Ssamkill $background 121185380Ssamcd / 122185380Ssam/usr/bin/rm -rf $DIR 123185380Ssam 124185380Ssamexit $status 125185380Ssam