2017-12-21 21:22:04 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2018-03-02 21:17:57 +00:00
|
|
|
set -ex
|
2017-12-21 21:22:04 +00:00
|
|
|
|
|
|
|
testdir=$(readlink -f $(dirname $0))
|
2018-03-22 22:18:32 +00:00
|
|
|
rootdir=$(readlink -f $testdir/../..)
|
2017-12-21 21:22:04 +00:00
|
|
|
source $rootdir/scripts/common.sh
|
|
|
|
source $rootdir/test/common/autotest_common.sh
|
2018-06-22 09:16:10 +00:00
|
|
|
|
|
|
|
if [ -z "${DEPENDENCY_DIR}" ]; then
|
|
|
|
echo DEPENDENCY_DIR not defined!
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
spdk_nvme_cli="${DEPENDENCY_DIR}/nvme-cli"
|
2017-12-21 21:22:04 +00:00
|
|
|
|
2018-03-02 21:19:08 +00:00
|
|
|
if [ ! -d $spdk_nvme_cli ]; then
|
|
|
|
echo "nvme-cli repository not found at $spdk_nvme_cli; skipping tests."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2017-12-21 21:22:04 +00:00
|
|
|
timing_enter nvme_cli
|
|
|
|
|
|
|
|
if [ `uname` = Linux ]; then
|
|
|
|
start_stub "-s 2048 -i 0 -m 0xF"
|
|
|
|
trap "kill_stub; exit 1" SIGINT SIGTERM EXIT
|
|
|
|
fi
|
|
|
|
|
2018-03-02 21:19:08 +00:00
|
|
|
# Build against the version of SPDK under test
|
|
|
|
rm -f "$spdk_nvme_cli/spdk"
|
|
|
|
ln -sf "$rootdir" "$spdk_nvme_cli/spdk"
|
|
|
|
|
|
|
|
bdfs=$(iter_pci_class_code 01 08 02)
|
|
|
|
bdf=$(echo $bdfs|awk '{ print $1 }')
|
2018-07-18 19:08:17 +00:00
|
|
|
|
2018-09-26 11:19:28 +00:00
|
|
|
if [[ -s $rootdir/CONFIG.local ]] && grep 'CONFIG_LOG_BACKTRACE\?=y' $rootdir/CONFIG.local -q; then
|
2018-07-18 19:08:17 +00:00
|
|
|
nvme_cli_ldflags='LDFLAGS=-lunwind'
|
|
|
|
fi
|
|
|
|
|
2018-03-02 21:19:08 +00:00
|
|
|
cd $spdk_nvme_cli
|
2018-07-18 19:08:17 +00:00
|
|
|
make clean && make -j$(nproc) $nvme_cli_ldflags
|
2018-03-02 21:19:08 +00:00
|
|
|
sed -i 's/spdk=0/spdk=1/g' spdk.conf
|
|
|
|
sed -i 's/shm_id=1/shm_id=0/g' spdk.conf
|
|
|
|
./nvme list
|
|
|
|
./nvme id-ctrl $bdf
|
|
|
|
./nvme list-ctrl $bdf
|
|
|
|
./nvme get-ns-id $bdf
|
|
|
|
./nvme id-ns $bdf
|
|
|
|
./nvme fw-log $bdf
|
|
|
|
./nvme smart-log $bdf
|
|
|
|
./nvme error-log $bdf
|
|
|
|
./nvme list-ns $bdf -n 1
|
|
|
|
./nvme get-feature $bdf -n 1 -f 1 -s 1 -l 100
|
|
|
|
./nvme get-log $bdf -n 1 -i 1 -l 100
|
|
|
|
./nvme reset $bdf
|
2017-12-21 21:22:04 +00:00
|
|
|
if [ `uname` = Linux ]; then
|
|
|
|
trap - SIGINT SIGTERM EXIT
|
|
|
|
kill_stub
|
|
|
|
fi
|
|
|
|
|
2018-03-02 21:11:49 +00:00
|
|
|
report_test_completion spdk_nvme_cli
|
2017-12-21 21:22:04 +00:00
|
|
|
timing_exit nvme_cli
|