echo "Missing xmlstarlet binary!"
exit 1
fi
+
if [ `uname` = FreeBSD ]; then
SED=gsed
+ DIFFCOLOPTS=""
else
SED=sed
-fi
+ termwidth=$(stty -a | head -1 | sed -e 's/.*columns \([0-9]*\).*/\1/')
+ if [ -n "$termwidth" -a "$termwidth" != "0" ]; then
+ termwidth="-W ${termwidth}"
+ fi
+ DIFFCOLOPTS="-y $termwidth"
+fi
#! @file ceph-helpers.sh
# @brief Toolbox to manage Ceph cluster dedicated to testing
# Set to "yes" in order to ignore diff errors and save results to update test
getjson="no"
-termwidth=$(stty -a | head -1 | sed -e 's/.*columns \([0-9]*\).*/\1/')
-if test -n "$termwidth" -a "$termwidth" != "0"; then termwidth="-W ${termwidth}"; fi
-
# Ignore the epoch and filter out the attr '_' value because it has date information and won't match
jqfilter='.inconsistents | (.[].shards[].attrs[] | select(.name == "_") | .value) |= "----Stripped-by-test----"'
sortkeys='import json; import sys ; JSON=sys.stdin.read() ; ud = json.loads(JSON) ; print json.dumps(ud, sort_keys=True, indent=2)'
EOF
jq "$jqfilter" $dir/json | python -c "$sortkeys" | sed -e "$sedfilter" > $dir/csjson
- diff -y $termwidth $dir/checkcsjson $dir/csjson || test $getjson = "yes" || return 1
+ diff ${DIFFCOLOPTS} $dir/checkcsjson $dir/csjson || test $getjson = "yes" || return 1
if test $getjson = "yes"
then
jq '.' $dir/json > save1.json
EOF
jq "$jqfilter" $dir/json | python -c "$sortkeys" | sed -e "$sedfilter" > $dir/csjson
- diff -y $termwidth $dir/checkcsjson $dir/csjson || test $getjson = "yes" || return 1
+ diff ${DIFFCOLOPTS} $dir/checkcsjson $dir/csjson || test $getjson = "yes" || return 1
if test $getjson = "yes"
then
jq '.' $dir/json > save2.json
EOF
jq "$jqfilter" $dir/json | python -c "$sortkeys" > $dir/csjson
- diff -y $dir/checkcsjson $dir/csjson || return 1
+ diff ${DIFFCOLOPTS} $dir/checkcsjson $dir/csjson || return 1
if which jsonschema > /dev/null;
then