For the sanity-lnet test we often compare different YAML files.
This is done with diff which is the wrong tool since two YAML
files that are the same can have different indentations. The
libyaml maintainer states using python tools for this is the
proper supported way to do this.
Test-Parameters: trivial testlist=sanity-lnet
Change-Id: Ie0ef623e8ec729aaad862fc3f33eb0a3b4172fad
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51507
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Feng Lei <flei@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
local rc=0
! [[ -e $expected ]] && echo "$expected not found" && return 1
! [[ -e $actual ]] && echo "$actual not found" && return 1
- diff -upN ${actual} ${expected} || rc=$?
+ if [ verify_yaml_available ]; then
+ verify_compare_yaml $actual $expected || rc=$?
+ else
+ diff -upN ${actual} ${expected} || rc=$?
+ fi
echo "Expected:"
cat $expected
echo "Actual:"
verify_yaml() {
python3 -c "import sys, yaml; obj = yaml.safe_load(sys.stdin)"
}
+
+verify_compare_yaml() {
+ python3 -c "import sys, yaml; f=open(\"$1\", \"r\"); obj1 = yaml.safe_load(f); f=open(\"$2\", \"r\"); obj2 = yaml.safe_load(f); sys.exit(obj1 != obj2)"
+}