Chris@2236: #!/bin/bash Chris@2236: # Chris@2236: # Test that loading and re-saving a session does not change its contents Chris@2236: # Must be run from same directory as the SV binary Chris@2236: Chris@2236: set -e Chris@2236: Chris@2236: session="$1" Chris@2236: Chris@2236: set -u Chris@2236: Chris@2236: sv="./sonic-visualiser" Chris@2236: if [ ! -x "$sv" ]; then Chris@2236: echo "This script must be run from the directory containing the sonic-visualiser binary" 1>&2 Chris@2236: exit 1 Chris@2236: fi Chris@2236: Chris@2236: if ! xmllint --version 2>/dev/null ; then Chris@2236: echo "Can't find required xmllint program (from libxml2 distribution)" 1>&2 Chris@2236: exit 1 Chris@2236: fi Chris@2236: Chris@2236: version=$("$sv" -v 2>&1) Chris@2236: adequate=no Chris@2236: case "$version" in Chris@2236: [012].*) ;; Chris@2236: 3.[012]) ;; Chris@2236: 3.[012].*) ;; Chris@2236: [1-9]*) adequate=yes ;; Chris@2236: *) echo "Failed to query Sonic Visualiser version" 1>&2 Chris@2236: exit 1 ;; Chris@2236: esac Chris@2236: if [ "$adequate" = "no" ]; then Chris@2236: echo "Sonic Visualiser version must be at least 3.3 (supporting --osc-script option)" 1>&2 Chris@2236: exit 1 Chris@2236: fi Chris@2236: Chris@2236: if [ -z "$session" ]; then Chris@2236: echo "Usage: $0 " 1>&2 Chris@2236: exit 2 Chris@2236: fi Chris@2236: Chris@2236: if [ ! -f "$session" ]; then Chris@2236: echo "Session file $session not found" 1>&2 Chris@2236: exit 1 Chris@2236: fi Chris@2236: Chris@2236: tmpdir=$(mktemp -d) Chris@2236: trap "rm -rf $tmpdir" 0 Chris@2236: Chris@2236: input="$tmpdir/input.sv" Chris@2236: inxml="$tmpdir/input.xml" Chris@2236: output="$tmpdir/output.sv" Chris@2236: outxml="$tmpdir/output.xml" Chris@2236: Chris@2236: cp "$session" "$input" Chris@2236: Chris@2236: cat > "$tmpdir/script" <&2 Chris@2236: exit 1 Chris@2236: fi Chris@2236: Chris@2236: bunzip2 -c "$input" | xmllint --format - > "$inxml" Chris@2236: bunzip2 -c "$output" | xmllint --format - > "$outxml" Chris@2236: Chris@2236: sdiff -w 140 "$inxml" "$outxml" Chris@2236: