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 2025 Oxide Computer Company 16# 17 18# 19# Validate that the NVMe device in question is usable for these tests. 20# What we care about is that namespace one is present. 21# 22 23# 24# Environment sanity and debugging. 25# 26export LC_ALL=C.UTF-8 27export LD_PRELOAD=libumem.so 28export UMEM_DEBUG=default 29unalias -a 30set -o pipefail 31 32nd_arg0=$(basename $0) 33nd_rundir="$(dirname $0)/../runfiles" 34nd_file="non-destruct.run" 35nd_runfile="$nd_rundir/$nd_file" 36nd_runner="/opt/test-runner/bin/run" 37nd_nvmeadm="/usr/sbin/nvmeadm" 38nd_device= 39 40function fatal 41{ 42 typeset msg="$*" 43 [[ -z "$msg" ]] && msg="failed" 44 echo "$nd_arg0: $msg" >&2 45 exit 1 46} 47 48# 49# Check that the supplied device is an NVMe device that the system knows 50# about and that it has basic features that we can use. 51# 52function check_device 53{ 54 typeset state 55 56 if ! $nd_nvmeadm list "$nd_device" >/dev/null; then 57 fatal "failed to find device $nd_device" 58 fi 59 60 if ! $nd_nvmeadm list "$nd_device/1" >/dev/null; then 61 fatal "failed to find namespace 1 on $nd_device" 62 fi 63 64 state=$(nvmeadm list -p -o ns-state "$nd_device/1") 65 if [[ "$state" != "blkdev" ]]; then 66 fatal "$nd_device/1 namespace is not attached to blkdev" 67 fi 68 69} 70 71# 72# Export the basic environment variables that the test programs expect 73# to identify what to operate on. 74# 75function setup_env 76{ 77 export NVME_TEST_DEVICE=$nd_device 78} 79 80function run_tests 81{ 82 $nd_runner -c "$nd_runfile" 83} 84 85if (( $# == 0 )); then 86 fatal "missing required device name" 87fi 88 89nd_device="$1" 90 91check_device 92setup_env 93run_tests 94