summaryrefslogtreecommitdiffstats
path: root/test/config/config-diff.sh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-x[-rw-r--r--]test/config/config-diff.sh52
1 files changed, 38 insertions, 14 deletions
diff --git a/test/config/config-diff.sh b/test/config/config-diff.sh
index c15b42c..abec20e 100644..100755
--- a/test/config/config-diff.sh
+++ b/test/config/config-diff.sh
@@ -1,24 +1,48 @@
#!/bin/bash -e
# SPDX-License-Identifier: LGPL-2.1-or-later
-BUILD_DIR=$1
-CONFIG_DUMP=$2
-SYSDIR_INPUT=$3
-CONFIG_JSON=$4
-EXPECTED_OUTPUT=$5
+positional_args=()
+sysfs_tar=""
+config_json=""
-ACTUAL_OUTPUT="${BUILD_DIR}"/$(basename "${EXPECTED_OUTPUT}")
+while [[ $# -gt 0 ]]; do
+ case $1 in
+ --sysfs-tar)
+ sysfs_tar=$2
+ shift 1
+ ;;
+ --config-json)
+ config_json=$2
+ shift 1
+ ;;
+ *)
+ positional_args+=("$1")
+ shift
+ ;;
+ esac
+done
-TEST_NAME="$(basename -s .tar.xz $SYSDIR_INPUT)"
-TEST_DIR="$BUILD_DIR/$TEST_NAME"
+set -- "${positional_args[@]}"
-rm -rf "${TEST_DIR}"
-mkdir "${TEST_DIR}"
-tar -x -f "${SYSDIR_INPUT}" -C "${TEST_DIR}"
+test_binary="$1"
+build_dir="$2"
+expected_output="$3"
-LIBNVME_SYSFS_PATH="$TEST_DIR" \
+sysfs_path=""
+if [[ -n "${sysfs_tar}" ]]; then
+ test_name="$(basename -s .tar.xz ${sysfs_tar})"
+ sysfs_path="${build_dir}/${test_name}"
+
+ rm -rf "${sysfs_path}"
+ mkdir "${sysfs_path}"
+ tar -x -f "${sysfs_tar}" -C "${sysfs_path}"
+fi
+
+output="${build_dir}"/$(basename "${expected_output}")
+
+LIBNVME_SYSFS_PATH="${sysfs_path}" \
LIBNVME_HOSTNQN=nqn.2014-08.org.nvmexpress:uuid:ce4fee3e-c02c-11ee-8442-830d068a36c6 \
LIBNVME_HOSTID=ce4fee3e-c02c-11ee-8442-830d068a36c6 \
-"${CONFIG_DUMP}" "${CONFIG_JSON}" > "${ACTUAL_OUTPUT}" || echo "test failed"
+"${test_binary}" "${config_json}" > "${output}" || echo "test failed"
-diff -u "${EXPECTED_OUTPUT}" "${ACTUAL_OUTPUT}"
+diff -u "${expected_output}" "${output}"