tst.fork.ksh revision 302408
1213365Smarcel#!/bin/ksh -p 2214006Smarcel# 3213365Smarcel# CDDL HEADER START 4213365Smarcel# 5213365Smarcel# The contents of this file are subject to the terms of the 6213365Smarcel# Common Development and Distribution License (the "License"). 7213365Smarcel# You may not use this file except in compliance with the License. 8213365Smarcel# 9213365Smarcel# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10213365Smarcel# or http://www.opensolaris.org/os/licensing. 11213365Smarcel# See the License for the specific language governing permissions 12213365Smarcel# and limitations under the License. 13213365Smarcel# 14213365Smarcel# When distributing Covered Code, include this CDDL HEADER in each 15213365Smarcel# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16213365Smarcel# If applicable, add the following below this CDDL HEADER, with the 17213365Smarcel# fields enclosed by brackets "[]" replaced with your own identifying 18213365Smarcel# information: Portions Copyright [yyyy] [name of copyright owner] 19213365Smarcel# 20213365Smarcel# CDDL HEADER END 21213365Smarcel# 22213365Smarcel 23213365Smarcel# 24213365Smarcel# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 25213365Smarcel# Use is subject to license terms. 26213365Smarcel# 27213365Smarcel#ident "%Z%%M% %I% %E% SMI" 28213365Smarcel 29213365Smarcelif [ $# != 1 ]; then 30213365Smarcel echo expected one argument: '<'dtrace-path'>' 31213365Smarcel exit 2 32213365Smarcelfi 33213365Smarcel 34213365Smarceldtrace=$1 35213365SmarcelDIR=/var/tmp/dtest.$$ 36213365Smarcel 37213365Smarcelmkdir $DIR 38214006Smarcelcd $DIR 39214006Smarcel 40213365Smarcelcat > prov.d <<EOF 41213365Smarcelprovider test_prov { 42213365Smarcel probe go(); 43213365Smarcel}; 44213365SmarcelEOF 45228634Savg 46213365Smarcel$dtrace -h -s prov.d 47213365Smarcelif [ $? -ne 0 ]; then 48213365Smarcel print -u2 "failed to generate header file" 49213365Smarcel exit 1 50214006Smarcelfi 51213365Smarcel 52213365Smarcelcat > test.c <<EOF 53213365Smarcel#include <sys/types.h> 54213365Smarcel#include <sys/wait.h> 55213365Smarcel#include <unistd.h> 56213365Smarcel#include "prov.h" 57213365Smarcel 58223919Saeint 59214006Smarcelmain(int argc, char **argv) 60213365Smarcel{ 61213365Smarcel TEST_PROV_GO(); 62213365Smarcel if (fork() == 0) { 63213365Smarcel TEST_PROV_GO(); 64213365Smarcel return (0); 65213365Smarcel } 66213365Smarcel 67213365Smarcel (void) wait(NULL); 68213365Smarcel TEST_PROV_GO(); 69213365Smarcel 70213365Smarcel return (0); 71213365Smarcel} 72213365SmarcelEOF 73213365Smarcel 74213365Smarcelcc -c test.c 75213365Smarcelif [ $? -ne 0 ]; then 76213365Smarcel print -u2 "failed to compile test.c" 77213365Smarcel exit 1 78213365Smarcelfi 79213365Smarcel$dtrace -G -s prov.d test.o 80213365Smarcelif [ $? -ne 0 ]; then 81213365Smarcel print -u2 "failed to create DOF" 82302234Sbdrewery exit 1 83213365Smarcelfi 84213365Smarcelcc -o test test.o prov.o 85213365Smarcelif [ $? -ne 0 ]; then 86213365Smarcel print -u2 "failed to link final executable" 87213365Smarcel exit 1 88213365Smarcelfi 89214006Smarcel 90214006Smarcelscript() { 91214006Smarcel $dtrace -c ./test -Zqs /dev/stdin <<EOF 92213365Smarcel test_prov*::: 93214006Smarcel { 94214006Smarcel printf("%s:%s:%s\n", probemod, probefunc, probename); 95213365Smarcel } 96214006SmarcelEOF 97213365Smarcel} 98293742Strasz 99293742Straszscript 100293742Straszstatus=$? 101293742Strasz 102293742Straszcd / 103214006Smarcel/bin/rm -rf $DIR 104213365Smarcel 105267752Smavexit $status 106267752Smav