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