| 1 |
#!/bin/bash -e |
| 2 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 |
|
| 4 |
positional_args=() |
| 5 |
sysfs_tar="" |
| 6 |
config_json="" |
| 7 |
|
| 8 |
while [[ $# -gt 0 ]]; do |
| 9 |
case $1 in |
| 10 |
--sysfs-tar) |
| 11 |
sysfs_tar=$2 |
| 12 |
shift 1 |
| 13 |
;; |
| 14 |
--config-json) |
| 15 |
config_json=$2 |
| 16 |
shift 1 |
| 17 |
;; |
| 18 |
*) |
| 19 |
positional_args+=("$1") |
| 20 |
shift |
| 21 |
;; |
| 22 |
esac |
| 23 |
done |
| 24 |
|
| 25 |
set -- "${positional_args[@]}" |
| 26 |
|
| 27 |
test_binary="$1" |
| 28 |
build_dir="$2" |
| 29 |
expected_output="$3" |
| 30 |
|
| 31 |
sysfs_path="" |
| 32 |
if [[ -n "${sysfs_tar}" ]]; then |
| 33 |
test_name="$(basename -s .tar.xz ${sysfs_tar})" |
| 34 |
sysfs_path="${build_dir}/${test_name}" |
| 35 |
|
| 36 |
rm -rf "${sysfs_path}" |
| 37 |
mkdir "${sysfs_path}" |
| 38 |
tar -x -f "${sysfs_tar}" -C "${sysfs_path}" |
| 39 |
fi |
| 40 |
|
| 41 |
output="${build_dir}"/$(basename "${expected_output}") |
| 42 |
|
| 43 |
LIBNVME_SYSFS_PATH="${sysfs_path}" \ |
| 44 |
LIBNVME_HOSTNQN=nqn.2014-08.org.nvmexpress:uuid:ce4fee3e-c02c-11ee-8442-830d068a36c6 \ |
| 45 |
LIBNVME_HOSTID=ce4fee3e-c02c-11ee-8442-830d068a36c6 \ |
| 46 |
"${test_binary}" "${config_json}" > "${output}" || echo "test failed" |
| 47 |
|
| 48 |
diff -u "${expected_output}" "${output}" |