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