Mercurial > hg > sonic-visualiser
annotate test/test-session-export.sh @ 2533:ae2c8c8e33d4
Update changelog
author | Chris Cannam |
---|---|
date | Mon, 11 May 2020 16:13:14 +0100 |
parents | 1dbc681aec21 |
children |
rev | line source |
---|---|
Chris@2236 | 1 #!/bin/bash |
Chris@2236 | 2 # |
Chris@2236 | 3 # Test that loading and re-saving a session does not change its contents |
Chris@2324 | 4 # Must be run from directory that contains this script |
Chris@2236 | 5 |
Chris@2236 | 6 set -e |
Chris@2236 | 7 |
Chris@2236 | 8 session="$1" |
Chris@2236 | 9 |
Chris@2236 | 10 set -u |
Chris@2236 | 11 |
Chris@2248 | 12 sv="../sonic-visualiser" |
Chris@2324 | 13 if [ ! -f "$sv" -o ! -x "$sv" ]; then |
Chris@2248 | 14 echo "This script must be run from the sonic-visualiser/test directory" 1>&2 |
Chris@2236 | 15 exit 1 |
Chris@2236 | 16 fi |
Chris@2236 | 17 |
Chris@2236 | 18 if ! xmllint --version 2>/dev/null ; then |
Chris@2236 | 19 echo "Can't find required xmllint program (from libxml2 distribution)" 1>&2 |
Chris@2236 | 20 exit 1 |
Chris@2236 | 21 fi |
Chris@2236 | 22 |
Chris@2236 | 23 version=$("$sv" -v 2>&1) |
Chris@2236 | 24 adequate=no |
Chris@2236 | 25 case "$version" in |
Chris@2236 | 26 [012].*) ;; |
Chris@2236 | 27 3.[012]) ;; |
Chris@2236 | 28 3.[012].*) ;; |
Chris@2236 | 29 [1-9]*) adequate=yes ;; |
Chris@2236 | 30 *) echo "Failed to query Sonic Visualiser version" 1>&2 |
Chris@2236 | 31 exit 1 ;; |
Chris@2236 | 32 esac |
Chris@2236 | 33 if [ "$adequate" = "no" ]; then |
Chris@2236 | 34 echo "Sonic Visualiser version must be at least 3.3 (supporting --osc-script option)" 1>&2 |
Chris@2236 | 35 exit 1 |
Chris@2236 | 36 fi |
Chris@2236 | 37 |
Chris@2236 | 38 if [ -z "$session" ]; then |
Chris@2236 | 39 echo "Usage: $0 <session.sv>" 1>&2 |
Chris@2236 | 40 exit 2 |
Chris@2236 | 41 fi |
Chris@2236 | 42 |
Chris@2236 | 43 if [ ! -f "$session" ]; then |
Chris@2236 | 44 echo "Session file $session not found" 1>&2 |
Chris@2236 | 45 exit 1 |
Chris@2236 | 46 fi |
Chris@2236 | 47 |
Chris@2236 | 48 tmpdir=$(mktemp -d) |
Chris@2236 | 49 trap "rm -rf $tmpdir" 0 |
Chris@2236 | 50 |
Chris@2236 | 51 input="$tmpdir/input.sv" |
Chris@2236 | 52 inxml="$tmpdir/input.xml" |
Chris@2236 | 53 output="$tmpdir/output.sv" |
Chris@2236 | 54 outxml="$tmpdir/output.xml" |
Chris@2236 | 55 |
Chris@2236 | 56 cp "$session" "$input" |
Chris@2236 | 57 |
Chris@2236 | 58 cat > "$tmpdir/script" <<EOF |
Chris@2236 | 59 /open "$input" |
Chris@2236 | 60 /save "$output" |
Chris@2236 | 61 /quit |
Chris@2236 | 62 EOF |
Chris@2236 | 63 |
Chris@2236 | 64 "$sv" --no-splash --osc-script "$tmpdir/script" |
Chris@2236 | 65 |
Chris@2236 | 66 if [ ! -f "$output" ]; then |
Chris@2236 | 67 echo "ERROR: Failed to save session to $output at all!" 1>&2 |
Chris@2236 | 68 exit 1 |
Chris@2236 | 69 fi |
Chris@2236 | 70 |
Chris@2236 | 71 bunzip2 -c "$input" | xmllint --format - > "$inxml" |
Chris@2236 | 72 bunzip2 -c "$output" | xmllint --format - > "$outxml" |
Chris@2236 | 73 |
Chris@2249 | 74 diff -u "$inxml" "$outxml" |
Chris@2236 | 75 |