xref: /illumos-gate/usr/src/cmd/dtrace/test/tst/common/pid/tst.provregex3.ksh (revision a386cc11a86ecb60f5a48078d22c1500e2ad003e)
16e0bee74Sjhaslam#!/bin/ksh -p
26e0bee74Sjhaslam#
36e0bee74Sjhaslam# CDDL HEADER START
46e0bee74Sjhaslam#
56e0bee74Sjhaslam# The contents of this file are subject to the terms of the
66e0bee74Sjhaslam# Common Development and Distribution License (the "License").
76e0bee74Sjhaslam# You may not use this file except in compliance with the License.
86e0bee74Sjhaslam#
96e0bee74Sjhaslam# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
106e0bee74Sjhaslam# or http://www.opensolaris.org/os/licensing.
116e0bee74Sjhaslam# See the License for the specific language governing permissions
126e0bee74Sjhaslam# and limitations under the License.
136e0bee74Sjhaslam#
146e0bee74Sjhaslam# When distributing Covered Code, include this CDDL HEADER in each
156e0bee74Sjhaslam# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
166e0bee74Sjhaslam# If applicable, add the following below this CDDL HEADER, with the
176e0bee74Sjhaslam# fields enclosed by brackets "[]" replaced with your own identifying
186e0bee74Sjhaslam# information: Portions Copyright [yyyy] [name of copyright owner]
196e0bee74Sjhaslam#
206e0bee74Sjhaslam# CDDL HEADER END
216e0bee74Sjhaslam#
226e0bee74Sjhaslam
236e0bee74Sjhaslam#
246e0bee74Sjhaslam# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
256e0bee74Sjhaslam# Use is subject to license terms.
266e0bee74Sjhaslam#
276e0bee74Sjhaslam
286e0bee74Sjhaslam#
296e0bee74Sjhaslam# This test verifies that a regex in the provider name will match
306e0bee74Sjhaslam# USDT probes as well as pid probes (e.g., p*d$target matches both
316e0bee74Sjhaslam# pid$target and pyramid$target.)
326e0bee74Sjhaslam#
336e0bee74Sjhaslam
346e0bee74Sjhaslamif [ $# != 1 ]; then
356e0bee74Sjhaslam	echo expected one argument: '<'dtrace-path'>'
366e0bee74Sjhaslam	exit 2
376e0bee74Sjhaslamfi
386e0bee74Sjhaslam
396e0bee74Sjhaslamdtrace=$1
406e0bee74SjhaslamDIR=${TMPDIR:-/tmp}/dtest.$$
416e0bee74Sjhaslam
426e0bee74Sjhaslammkdir $DIR
436e0bee74Sjhaslamcd $DIR
446e0bee74Sjhaslam
456e0bee74Sjhaslamcat > Makefile <<EOF
466e0bee74Sjhaslamall: main
476e0bee74Sjhaslam
486e0bee74Sjhaslammain: main.o prov.o
49*a386cc11SRobert Mustacchi	gcc -m32 -o main main.o prov.o
506e0bee74Sjhaslam
516e0bee74Sjhaslammain.o: main.c prov.h
52*a386cc11SRobert Mustacchi	gcc -m32 -c main.c
536e0bee74Sjhaslam
546e0bee74Sjhaslamprov.h: prov.d
556e0bee74Sjhaslam	$dtrace -h -s prov.d
566e0bee74Sjhaslam
576e0bee74Sjhaslamprov.o: prov.d main.o
586e0bee74Sjhaslam	$dtrace -G -32 -s prov.d main.o
596e0bee74SjhaslamEOF
606e0bee74Sjhaslam
616e0bee74Sjhaslamcat > prov.d <<EOF
626e0bee74Sjhaslamprovider pyramid {
636e0bee74Sjhaslam	probe entry();
646e0bee74Sjhaslam};
656e0bee74SjhaslamEOF
666e0bee74Sjhaslam
676e0bee74Sjhaslamcat > main.c <<EOF
686e0bee74Sjhaslam#include <sys/sdt.h>
696e0bee74Sjhaslam#include "prov.h"
706e0bee74Sjhaslam
716e0bee74Sjhaslamint
726e0bee74Sjhaslammain(int argc, char **argv)
736e0bee74Sjhaslam{
746e0bee74Sjhaslam	PYRAMID_ENTRY();
756e0bee74Sjhaslam}
766e0bee74SjhaslamEOF
776e0bee74Sjhaslam
786e0bee74Sjhaslammake > /dev/null
796e0bee74Sjhaslamif [ $? -ne 0 ]; then
806e0bee74Sjhaslam	print -u2 "failed to build"
816e0bee74Sjhaslam	exit 1
826e0bee74Sjhaslamfi
836e0bee74Sjhaslam
846e0bee74Sjhaslamcat > main.d <<'EOF'
856e0bee74Sjhaslamp*d$target::main:entry
866e0bee74Sjhaslam{
876e0bee74Sjhaslam	printf("%s:%s:%s\n", probemod, probefunc, probename);
886e0bee74Sjhaslam}
896e0bee74SjhaslamEOF
906e0bee74Sjhaslam
916e0bee74Sjhaslamscript() {
926e0bee74Sjhaslam	$dtrace -q -s ./main.d -c ./main
936e0bee74Sjhaslam}
946e0bee74Sjhaslam
956e0bee74Sjhaslamscript
966e0bee74Sjhaslamstatus=$?
976e0bee74Sjhaslam
986e0bee74Sjhaslamcd /tmp
996e0bee74Sjhaslam/usr/bin/rm -rf $DIR
1006e0bee74Sjhaslam
1016e0bee74Sjhaslamexit $status
102