]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/test/json_config/json_diff.sh
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / test / json_config / json_diff.sh
1 #!/usr/bin/env bash
2
3 set -x
4
5 if [ $# -ne 2 ]; then
6 echo "This script need exactly two arguments"
7 exit 1
8 fi
9
10 rootdir=$(readlink -f $(dirname $0)/../..)
11
12 # Compare two JSON files.
13 #
14 # NOTE: Order of objects in JSON can change by just doing loads -> dumps so all JSON objects (not arrays) are sorted by
15 # config_filter.py script. Sorted output is used to compare JSON output.
16 #
17
18 tmp_file_1=$(mktemp /tmp/$(basename ${1}).XXX)
19 tmp_file_2=$(mktemp /tmp/$(basename ${2}).XXX)
20 ret=0
21
22 $rootdir/test/json_config/config_filter.py -method "sort" < $1 > $tmp_file_1
23 $rootdir/test/json_config/config_filter.py -method "sort" < $2 > $tmp_file_2
24
25 if ! diff -u $tmp_file_1 $tmp_file_2; then
26 ret=1
27
28 echo "=== Start of file: $tmp_file_1 ==="
29 cat $tmp_file_1
30 echo "=== End of file: $tmp_file_1 ==="
31 echo ""
32 echo "=== Start of file: $tmp_file_2 ==="
33 cat $tmp_file_2
34 echo "=== End of file: $tmp_file_2 ==="
35 echo ""
36 else
37 echo "INFO: JSON config files are the same"
38 fi
39
40 rm $tmp_file_1 $tmp_file_2
41 exit $ret