xref: /illumos-gate/usr/src/test/nvme-tests/cmd/destruct-ocp.ksh (revision 564eeb7d65973f1d64a5390ff477b689707e9daf)
1#!/usr/bin/ksh
2
3#
4# This file and its contents are supplied under the terms of the
5# Common Development and Distribution License ("CDDL"), version 1.0.
6# You may only use this file in accordance with the terms of version
7# 1.0 of the CDDL.
8#
9# A full copy of the text of the CDDL should have accompanied this
10# source.  A copy of the CDDL is also available via the Internet at
11# http://www.illumos.org/license/CDDL.
12#
13
14#
15# Copyright 2026 Oxide Computer Company
16#
17
18#
19# Run tests that can wreak havoc on a device with OCP features (e.g.
20# error injection, changing the PLP Health window, etc.)
21#
22
23#
24# Environment sanitization.
25#
26export LC_ALL=C.UTF-8
27export LD_PRELOAD=libumem.so
28export UMEM_DEBUG=default
29unalias -a
30set -o pipefail
31
32de_arg0=$(basename $0)
33de_rundir="$(dirname $0)/../runfiles"
34de_file="destruct-ocp.run"
35de_runfile="$de_rundir/$de_file"
36de_runner="/opt/test-runner/bin/run"
37de_nvmeadm="/usr/sbin/nvmeadm"
38
39function fatal
40{
41        typeset msg="$*"
42        [[ -z "$msg" ]] && msg="failed"
43        echo "$de_arg0: $msg" >&2
44        exit 1
45}
46
47
48if (( $# == 0 )); then
49	fatal "missing required device name"
50fi
51
52if ! $de_nvmeadm list "$1" > /dev/null; then
53	fatal "failed to find device $1"
54fi
55
56export NVME_TEST_DEVICE=$1
57$de_runner -c "$de_runfile"
58