tst.reap.ksh revision a386cc11a86ecb60f5a48078d22c1500e2ad003e
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill# CDDL HEADER START
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill# The contents of this file are subject to the terms of the
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill# Common Development and Distribution License (the "License").
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill# You may not use this file except in compliance with the License.
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill# See the License for the specific language governing permissions
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill# and limitations under the License.
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill# When distributing Covered Code, include this CDDL HEADER in each
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill# If applicable, add the following below this CDDL HEADER, with the
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill# fields enclosed by brackets "[]" replaced with your own identifying
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill# information: Portions Copyright [yyyy] [name of copyright owner]
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill# CDDL HEADER END
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill# Copyright (c) 2011, Joyent, Inc. All rights reserved.
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrillif [ $# != 1 ]; then
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill echo expected one argument: '<'dtrace-path'>'
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill#include <unistd.h>
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill#include <sys/sdt.h>
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrillmain(int argc, char **argv)
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill DTRACE_PROBE(test_prov, probe1);
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrillprovider test_prov {
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill probe probe1();
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill test_prov*:::
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill probeid = id;
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill /probeid == 0/
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill printf("launching test\n");
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill system("./test");
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill /probeid != 0/
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill printf("attempting re-enabling\n");
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill system("dtrace -e -x errtags -i %d", probeid);
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill /attempts > 10/
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill# It should be true that our probe was reaped over the course of the enabling,
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill# causing the embedded DTrace invocation to fail on an invalid probe (that is,
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill# D_PDESC_INVAL) instead of an inability to grab the underlying process
f484800de70343e19872fa0f3fde2a00504a9cecBryan Cantrill# (D_PROC_GRAB).