tst.noreapring.ksh revision 238582
1238582Smm# 2238582Smm# CDDL HEADER START 3238582Smm# 4238582Smm# The contents of this file are subject to the terms of the 5238582Smm# Common Development and Distribution License (the "License"). 6238582Smm# You may not use this file except in compliance with the License. 7238582Smm# 8238582Smm# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9238582Smm# or http://www.opensolaris.org/os/licensing. 10238582Smm# See the License for the specific language governing permissions 11238582Smm# and limitations under the License. 12238582Smm# 13238582Smm# When distributing Covered Code, include this CDDL HEADER in each 14238582Smm# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15238582Smm# If applicable, add the following below this CDDL HEADER, with the 16238582Smm# fields enclosed by brackets "[]" replaced with your own identifying 17238582Smm# information: Portions Copyright [yyyy] [name of copyright owner] 18238582Smm# 19238582Smm# CDDL HEADER END 20238582Smm# 21238582Smm 22238582Smm# 23238582Smm# Copyright (c) 2011, Joyent, Inc. All rights reserved. 24238582Smm# 25238582Smm 26238582Smmif [ $# != 1 ]; then 27238582Smm echo expected one argument: '<'dtrace-path'>' 28238582Smm exit 2 29238582Smmfi 30238582Smm 31238582Smmdtrace=$1 32238582SmmDIR=/var/tmp/dtest.$$ 33238582Smm 34238582Smmmkdir $DIR 35238582Smmcd $DIR 36238582Smm 37238582Smmcat > test.c <<EOF 38238582Smm#include <unistd.h> 39238582Smm#include <sys/sdt.h> 40238582Smm 41238582Smmint 42238582Smmmain(int argc, char **argv) 43238582Smm{ 44238582Smm DTRACE_PROBE(test_prov, probe1); 45238582Smm} 46238582SmmEOF 47238582Smm 48238582Smmcat > prov.d <<EOF 49238582Smmprovider test_prov { 50238582Smm probe probe1(); 51238582Smm}; 52238582SmmEOF 53238582Smm 54238582Smmgcc -c test.c 55238582Smmif [ $? -ne 0 ]; then 56238582Smm print -u2 "failed to compile test.c" 57238582Smm exit 1 58238582Smmfi 59238582Smm$dtrace -G -32 -s prov.d test.o 60238582Smmif [ $? -ne 0 ]; then 61238582Smm print -u2 "failed to create DOF" 62238582Smm exit 1 63238582Smmfi 64238582Smmgcc -o test test.o prov.o 65238582Smmif [ $? -ne 0 ]; then 66238582Smm print -u2 "failed to link final executable" 67238582Smm exit 1 68238582Smmfi 69238582Smm 70238582Smmscript() 71238582Smm{ 72238582Smm $dtrace -Zwqs /dev/stdin <<EOF 73238582Smm test_prov*::: 74238582Smm { 75238582Smm probeid = id; 76238582Smm } 77238582Smm 78238582Smm tick-1sec 79238582Smm /probeid == 0/ 80238582Smm { 81238582Smm printf("launching test\n"); 82238582Smm system("./test"); 83238582Smm } 84238582Smm 85238582Smm tick-1sec 86238582Smm /probeid != 0/ 87238582Smm { 88238582Smm printf("attempting re-enabling\n"); 89238582Smm system("dtrace -e -x errtags -i %d", probeid); 90238582Smm attempts++; 91238582Smm } 92238582Smm 93238582Smm tick-1sec 94238582Smm /attempts > 10/ 95238582Smm { 96238582Smm exit(0); 97238582Smm } 98238582SmmEOF 99238582Smm} 100238582Smm 101238582Smm$dtrace -x bufpolicy=ring -ZwqP test_prov\* > /dev/null 2>&1 & 102238582Smmbackground=$! 103238582Smmecho launched ring buffered enabling as pid $background 104238582Smmscript 2>&1 | tee test.out 105238582Smm 106238582Smm# 107238582Smm# It should be true that our probe was not reaped after the provider was made 108238582Smm# defunct: the active ring buffer in the earlier enabling prevents reaping of 109238582Smm# any of the earlier enabling's ECBs. 110238582Smm# 111238582Smmstatus=0 112238582Smm 113238582Smmif grep D_PDESC_INVAL test.out 2> /dev/null 1>&2 ; then 114238582Smm status=1 115238582Smmelse 116238582Smm grep D_PROC_GRAB test.out 2> /dev/null 1>&2 117238582Smm status=$? 118238582Smmfi 119238582Smm 120238582Smmkill $background 121238582Smmcd / 122238582Smm/usr/bin/rm -rf $DIR 123238582Smm 124238582Smmexit $status 125