xref: /illumos-gate/usr/src/test/libc-tests/tests/psignal.ksh (revision 08855964b9970604433f7b19dcd71cf5af5e5f14)
1#!/usr/bin/ksh
2#
3# This file and its contents are supplied under the terms of the
4# Common Development and Distribution License ("CDDL"), version 1.0.
5# You may only use this file in accordance with the terms of version
6# 1.0 of the CDDL.
7#
8# A full copy of the text of the CDDL should have accompanied this
9# source.  A copy of the CDDL is also available via the Internet at
10# http://www.illumos.org/license/CDDL.
11#
12
13#
14# Copyright 2016 Joyent, Inc.
15#
16
17#
18# Add regression tests for illumos#5079. Verify that psignal and
19# psiginfo print what we expect to stderr.
20#
21
22set -o errexit
23set -o pipefail
24
25ps_root=$(dirname $0)
26ps_sig32=$ps_root/psignal-5097.32
27ps_sig64=$ps_root/psignal-5097.64
28ps_out=/tmp/$(basename $0).$$
29
30function fatal
31{
32	typeset msg="$*"
33	echo "Test Failed: $msg" >&2
34	exit 1
35}
36
37function test_one
38{
39	typeset prog=$1
40	typeset outfile=$ps_out.test
41
42	$prog >/dev/null 2>$outfile || fatal "$prog unexpectedly failed"
43	diff $ps_out $outfile || fatal "$ps_out and $outfile differ " \
44	    "unexpectedly"
45	rm -f $outfile
46}
47
48cat > $ps_out <<EOF
49hello world: Segmentation Fault
50Information Request
51hello world : Segmentation Fault ( from process  0 )
52Information Request ( from process  0 )
53EOF
54
55[[ $? -ne 0 ]] && fatal "failed to set up output file"
56test_one $ps_sig32
57test_one $ps_sig64
58rm -f $ps_out
59exit 0
60