tst.exitcore.ksh revision 178476
187866Ssheldonh# 287866Ssheldonh# CDDL HEADER START 387866Ssheldonh# 487866Ssheldonh# The contents of this file are subject to the terms of the 587866Ssheldonh# Common Development and Distribution License (the "License"). 687866Ssheldonh# You may not use this file except in compliance with the License. 787866Ssheldonh# 887866Ssheldonh# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 987866Ssheldonh# or http://www.opensolaris.org/os/licensing. 1087866Ssheldonh# See the License for the specific language governing permissions 1187866Ssheldonh# and limitations under the License. 1287866Ssheldonh# 1387866Ssheldonh# When distributing Covered Code, include this CDDL HEADER in each 1487866Ssheldonh# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1587866Ssheldonh# If applicable, add the following below this CDDL HEADER, with the 1687866Ssheldonh# fields enclosed by brackets "[]" replaced with your own identifying 1787866Ssheldonh# information: Portions Copyright [yyyy] [name of copyright owner] 1887866Ssheldonh# 1987866Ssheldonh# CDDL HEADER END 2087866Ssheldonh# 2187866Ssheldonh 2287866Ssheldonh# 2387866Ssheldonh# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 2487866Ssheldonh# Use is subject to license terms. 2587866Ssheldonh# 2687866Ssheldonh# ident "%Z%%M% %I% %E% SMI" 2787866Ssheldonh 2887866Ssheldonh# 2987866Ssheldonh# This script tests that the proc:::exit probe fires with the correct argument 3087866Ssheldonh# when the process core dumps. The problematic bit here is making sure that 3187866Ssheldonh# a process _can_ dump core -- if core dumps are disabled on both a global 3287866Ssheldonh# and per-process basis, this test will fail. Rather than having this test 3387866Ssheldonh# muck with coreadm(1M) settings, it will fail explicitly in this case and 3487866Ssheldonh# provide a hint as to the problem. In general, machines should never be 3587866Ssheldonh# running with both per-process and global core dumps disabled -- so this 3687866Ssheldonh# should be a non-issue in practice. 3787866Ssheldonh# 3887866Ssheldonh# If this fails, the script will run indefinitely; it relies on the harness 3987866Ssheldonh# to time it out. 4087866Ssheldonh# 4187866Ssheldonhscript() 4287866Ssheldonh{ 4387866Ssheldonh $dtrace -s /dev/stdin <<EOF 4487866Ssheldonh proc:::exit 4587866Ssheldonh /curpsinfo->pr_ppid == $child && 4687866Ssheldonh execargs == "$longsleep" && args[0] == CLD_DUMPED/ 4787866Ssheldonh { 4887866Ssheldonh exit(0); 4987866Ssheldonh } 5087866Ssheldonh 5187866Ssheldonh proc:::exit 5287866Ssheldonh /curpsinfo->pr_ppid == $child && 5387866Ssheldonh execargs == "$longsleep" && args[0] != CLD_DUMPED/ 5487866Ssheldonh { 5587866Ssheldonh printf("Child process could did dump core."); 5687866Ssheldonh exit(1); 5787866Ssheldonh } 5887866SsheldonhEOF 5987866Ssheldonh} 6087866Ssheldonh 6187866Ssheldonhsleeper() 6287866Ssheldonh{ 6387866Ssheldonh while true; do 6487866Ssheldonh $longsleep & 6587866Ssheldonh /bin/sleep 1 6687866Ssheldonh kill -SEGV $! 6787866Ssheldonh done 6887866Ssheldonh /bin/rm -f $corefile 6987866Ssheldonh} 7087866Ssheldonh 7187866Ssheldonhif [ $# != 1 ]; then 7287866Ssheldonh echo expected one argument: '<'dtrace-path'>' 7387866Ssheldonh exit 2 7487866Ssheldonhfi 7587866Ssheldonh 7687866Ssheldonhdtrace=$1 7787866Ssheldonhlongsleep="/bin/sleep 10000" 7887866Ssheldonhcorefile=/tmp/sleep.core 7987866Ssheldonh 8087866Ssheldonhsleeper & 8187866Ssheldonhchild=$! 8287866Ssheldonh 8387866Ssheldonhscript 8487866Ssheldonhstatus=$? 8587866Ssheldonh 8687866Ssheldonh#pstop $child 8787866Ssheldonh#pkill -P $child 8887866Ssheldonhkill $child 8987866Ssheldonh#prun $child 9087866Ssheldonh 9187866Ssheldonh/bin/rm -f $corefile 9287866Ssheldonhexit $status 9387866Ssheldonh