summaryrefslogtreecommitdiffstats
path: root/scripts/regress
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-30 22:38:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-30 22:38:48 +0000
commit01c4d3d32c5044d3d17055c2d94d40fee9d130e1 (patch)
tree2c213cd5436bff644fa7023b94674a9c12d2e1af /scripts/regress
parentAdding upstream version 2.4+really2.4. (diff)
downloadnvme-cli-01c4d3d32c5044d3d17055c2d94d40fee9d130e1.tar.xz
nvme-cli-01c4d3d32c5044d3d17055c2d94d40fee9d130e1.zip
Adding upstream version 2.5.upstream/2.5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/regress')
-rwxr-xr-xscripts/regress113
1 files changed, 113 insertions, 0 deletions
diff --git a/scripts/regress b/scripts/regress
new file mode 100755
index 0000000..302ff86
--- /dev/null
+++ b/scripts/regress
@@ -0,0 +1,113 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Copyright 2015 PMC-Sierra, Inc.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+#
+# Author: Stephen Bates <stephen.bates@pmcs.com>
+#
+# Description:
+# Regression test-suite for the NVM Express CLI.
+#
+
+DEVICE=
+WRITE=false
+LIST=false
+
+RAND_BASE=temp.rand
+RAND_WFILE=${RAND_BASE}.write
+RAND_RFILE=${RAND_BASE}.read
+RAND_SIZE=4k
+
+green=$(tput bold)$(tput setaf 2)
+red=$(tput bold)$(tput setaf 1)
+rst=$(tput sgr0)
+
+while getopts ":d:wl" opt; do
+ case $opt in
+ d)
+ DEVICE=${OPTARG}
+ ;;
+ w)
+ echo "WARNING: Write mode enabled, this might trash your drive!"
+ WRITE=true
+ ;;
+ l)
+ LIST=true
+ ;;
+ \?)
+ echo "Invalid option: -$OPTARG" >&2
+ exit 1
+ ;;
+ :)
+ echo "Option -$OPTARG requires an argument." >&2
+ exit 1
+ ;;
+ esac
+done
+
+if [ -z "$DEVICE" ]; then
+ echo "regress: You must specify a NVMe device using -d"
+ exit 1
+fi
+
+function print_pass_fail {
+ $* > /dev/null 2>&1
+ if (( $? )); then
+ echo ${red}"FAILED!"${rst}
+ echo "Failed running command: "
+ echo " $*"
+ exit 1
+ else
+ echo ${green}"PASSED!"${rst}
+ fi
+}
+
+function run_test {
+ LINE="$*"
+ printf " %-3s %-68s : " "RUN" "${LINE::67}"
+ print_pass_fail $*
+}
+
+make clean > /dev/null || exit -1
+make install > /dev/null || exit -1
+
+if $LIST ; then
+ run_test nvme list
+fi
+run_test nvme id-ctrl ${DEVICE}
+run_test nvme id-ns -raw-binary ${DEVICE}
+run_test nvme list-ns -n 1 ${DEVICE}
+run_test nvme get-ns-id ${DEVICE}
+run_test nvme get-log ${DEVICE} --log-id=2 --log-len=512
+run_test nvme fw-log ${DEVICE}
+run_test nvme fw-log ${DEVICE} -b
+run_test nvme smart-log ${DEVICE}
+run_test nvme error-log ${DEVICE}
+run_test nvme get-feature ${DEVICE} -f 7
+run_test nvme flush ${DEVICE}
+
+if $WRITE ; then
+ run_test dd if=/dev/urandom of=${RAND_WFILE} bs=${RAND_SIZE} count=1
+ run_test nvme write ${DEVICE} --start-block=0 --block-count=0 --data-size=${RAND_SIZE} --data ${RAND_WFILE}
+fi
+run_test nvme read ${DEVICE} --start-block=0 --block-count=0 --data-size=${RAND_SIZE} --data ${RAND_RFILE} --latency
+if $WRITE ; then
+ run_test diff ${RAND_RFILE} ${RAND_WFILE}
+ rm ${RAND_WFILE} > /dev/null
+fi
+rm ${RAND_RFILE} > /dev/null