Chris@2236: #!/bin/bash Chris@2236: # Chris@2236: # Test that loading and re-saving a session does not change its contents Chris@2324: # Must be run from directory that contains this script Chris@2236: Chris@2236: set -e Chris@2236: Chris@2236: session="$1" Chris@2236: Chris@2236: set -u Chris@2236: Chris@2248: sv="../sonic-visualiser" Chris@2324: if [ ! -f "$sv" -o ! -x "$sv" ]; then Chris@2248: echo "This script must be run from the sonic-visualiser/test directory" 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@2249: diff -u "$inxml" "$outxml" Chris@2236: