xref: /illumos-gate/usr/src/test/os-tests/tests/i386/badseg.sh (revision dbdc225a81ccef01e9d416169099b09ddbc06ea1)
1*dbdc225aSJohn Levon#!/bin/bash
2*dbdc225aSJohn Levon#
3*dbdc225aSJohn Levon# This file and its contents are supplied under the terms of the
4*dbdc225aSJohn Levon# Common Development and Distribution License ("CDDL"), version 1.0.
5*dbdc225aSJohn Levon# You may only use this file in accordance with the terms of version
6*dbdc225aSJohn Levon# 1.0 of the CDDL.
7*dbdc225aSJohn Levon#
8*dbdc225aSJohn Levon# A full copy of the text of the CDDL should have accompanied this
9*dbdc225aSJohn Levon# source.  A copy of the CDDL is also available via the Internet at
10*dbdc225aSJohn Levon# http://www.illumos.org/license/CDDL.
11*dbdc225aSJohn Levon#
12*dbdc225aSJohn Levon# Copyright 2019 Joyent, Inc.
13*dbdc225aSJohn Levon#
14*dbdc225aSJohn Levon
15*dbdc225aSJohn Levon#
16*dbdc225aSJohn Levon# badseg intentionally core-dumps. It does a setrlimit(), but we need to
17*dbdc225aSJohn Levon# prevent global core dumps too: we'll do this by blocking the path for
18*dbdc225aSJohn Levon# badseg_exec, but let other processes core dump still just in case.
19*dbdc225aSJohn Levon#
20*dbdc225aSJohn Levon
21*dbdc225aSJohn Levonset -e
22*dbdc225aSJohn Levonset -x
23*dbdc225aSJohn Levon
24*dbdc225aSJohn Levonold_enabled=$(/usr/bin/svcprop -p config_params/global_enabled coreadm)
25*dbdc225aSJohn Levonold_pattern=$(/usr/bin/svcprop -p config_params/global_pattern coreadm)
26*dbdc225aSJohn Levonold_log=$(/usr/bin/svcprop -p config_params/global_log_enabled coreadm)
27*dbdc225aSJohn Levon
28*dbdc225aSJohn Levonmkfile 1m /var/cores/badseg_exec
29*dbdc225aSJohn Levoncoreadm -e global -d log -g /var/cores/%f/%p
30*dbdc225aSJohn Levon# let it settle
31*dbdc225aSJohn Levonsleep 3
32*dbdc225aSJohn Levon
33*dbdc225aSJohn Levon$(dirname $0)/badseg_exec || true
34*dbdc225aSJohn Levon
35*dbdc225aSJohn Levoncoreadm -g "$old_pattern"
36*dbdc225aSJohn Levon
37*dbdc225aSJohn Levonif [[ "$old_enabled" = "true" ]]; then
38*dbdc225aSJohn Levon       coreadm -e global
39*dbdc225aSJohn Levonfi
40*dbdc225aSJohn Levon
41*dbdc225aSJohn Levonif [[ "$old_log" = "true" ]]; then
42*dbdc225aSJohn Levon       coreadm -e log
43*dbdc225aSJohn Levonfi
44*dbdc225aSJohn Levon
45*dbdc225aSJohn Levonrm -f /var/cores/badseg_exec
46