comparison export-tests/test-session-export.sh @ 2558:7535f13569fa

Move test/ to export-tests/ (so it can be distinguished from other test subdirs) and exclude from archive
author Chris Cannam
date Mon, 15 Jun 2020 17:45:04 +0100
parents test/test-session-export.sh@1dbc681aec21
children
comparison
equal deleted inserted replaced
2557:5a397accaf59 2558:7535f13569fa
1 #!/bin/bash
2 #
3 # Test that loading and re-saving a session does not change its contents
4 # Must be run from directory that contains this script
5
6 set -e
7
8 session="$1"
9
10 set -u
11
12 sv="../sonic-visualiser"
13 if [ ! -f "$sv" -o ! -x "$sv" ]; then
14 echo "This script must be run from the sonic-visualiser/test directory" 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 diff -u "$inxml" "$outxml"
75