File: config-diff.sh

package info (click to toggle)
libnvme 1.16.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,020 kB
  • sloc: ansic: 35,812; perl: 1,834; sh: 475; python: 194; cpp: 64; makefile: 55
file content (48 lines) | stat: -rwxr-xr-x 1,013 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash -e
# SPDX-License-Identifier: LGPL-2.1-or-later

positional_args=()
sysfs_tar=""
config_json=""

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

set -- "${positional_args[@]}"

test_binary="$1"
build_dir="$2"
expected_output="$3"

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 \
"${test_binary}" "${config_json}" > "${output}" || echo "test failed"

diff -u "${expected_output}" "${output}"