Debian Codegraph @

tools/cgreen_libxml_output_diff

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 #
3 # Will run the cgreen-runner in directory ../tools
4 # on library with name $1 (e.g. 'lib${name}.so')
5 # generating XML output that will be compared to
6 # sources are in $2 for...
7 # ...expected output file name in $3
8 # ...and commands to normalize output (in the file normalize_{name}.sed)
9 #
10 # Determine OS
11 unameo=`unamescip-shell system . . uname. -o 1>/dev/nullscip-shell filesystem . . `/dev/null`. 2>/dev/nullscip-shell filesystem . . `/dev/null`.; echoscip-shell system . . echo. $?`
12 if [scip-shell system . . `[`. $unameo -eq 0 ]; then
13 OS=`unamescip-shell system . . uname. -o`
14 else
15 OS=`unamescip-shell system . . uname. -s`
16 fi
17
18 # Set up library prefix and extension
19 case "$OS" in
20 Darwin)
21 prefix=lib
22 extension=dylib
23 ;;
24 GNU/Linux|FreeBSD)
25 prefix=lib
26 extension=so
27 ;;
28 Cygwin)
29 prefix=cyg
30 extension=dll
31 ;;
32 Msys)
33 prefix=lib
34 extension=dll
35 ;;
36 *)
37 echoscip-shell system . . echo. "ERROR: $0 can't handle OS=$OS"
38 exit 2
39 ;;
40 esac
41
42 # Handle arguments
43 if [scip-shell system . . `[`. $# -ne 3 ]; then
44 echoscip-shell system . . echo. "ERROR: $0 requires exactly 3 arguments"
45 exit 2
46 fi
47
48 # TODO: don't shift
49 name=$1; shift 1
50
51 sourcedir=$1 ; shift 1
52 sourcedir=$(perlscip-shell system . . perl. -e 'use Cwd "abs_path"; print abs_path(@ARGV[0])' -- "$sourcedir")
53 if [scip-shell system . . `[`. $(unamescip-shell system . . uname. -n) = thoni64 ]; then
54 # On my Cygwin machine I have linked /home to c:/Users so absolute paths don't match
55 # what runner prints, so try to replace that (don't know how to generalize this...)
56 sourcedir=`echoscip-shell system . . echo. $sourcedir | sedscip-shell system . . sed. -e s#/cygdrive/c/Users#/home#`
57 fi
58
59 # TODO: don't shift
60 expected=$1 ; shift 1
61
62 commandfile="${sourcedir}/normalize_${name}.sed"
63
64 # Do it!
65 if [scip-shell system . . `[`. -z "$CGREEN_PER_TEST_TIMEOUT" ]; then
66 printfscip-shell system . . printf. "Comparing output of ${name} to expected: "
67 else
68 printfscip-shell system . . printf. "Comparing output of ${name} to expected with CGREEN_PER_TEST_TIMEOUT=$CGREEN_PER_TEST_TIMEOUT: "
69 fi
70
71 # Run runner on library store output and error
72 ../tools/cgreen-runner -X L "${prefix}${name}.${extension}" > "${name}.output" 2> "${name}.error"
73 catscip-shell system . . cat. "${name}.error" >> "${name}.output"
74 catscip-shell system . . cat. L-*${name}.xml L-*${name}-default.xml >> "${name}.output"
75
76 tempfile=`mktempscip-shell system . . mktemp.`
77
78 # sed commands to normalize...
79 # - line numbers in error messages
80 echoscip-shell system . . echo. "s/:[0-9]+:/:/g" > $tempfile
81
82 # - timing info
83 echoscip-shell system . . echo. "s/in [0-9]+ms\./in 0ms\./g" >> $tempfile
84
85 # - library prefix
86 # TODO: should use prefix, shouldn't it?
87 echoscip-shell system . . echo. s/\".*${name}\"/\"${name}\"/g >> $tempfile
88
89 # - source path, ensure parenthesis are not interpreted by sed -E
90 # but allow any characters before sourcedir in the string
91 echoscip-shell system . . echo. s%\".*${sourcedir//[\(\)]/.}/%\"%g >> $tempfile
92
93 # Do normalization using the commands in the tempfile and the specified commandfile
94 sedscip-shell system . . sed. -E -f "${tempfile}" -f "${commandfile}" "${name}.output" > "${name}.output.normalized"
95
96 # Check for color capability
97 if testscip-shell system . . test. -t 1; then
98 ncolors=$(tputscip-shell system . . tput. colors)
99
100 if testscip-shell system . . test. -n "$ncolors" && testscip-shell system . . test. $ncolors -ge 8; then
101 green="$(tputscip-shell system . . tput. setaf 2)"
102 normal="$(tputscip-shell system . . tput. sgr0)"
103 fi
104 fi
105
106 # Compare normalized output to expected
107 cmpscip-shell system . . cmp. -s "${name}.output.normalized" "${sourcedir}/${expected}"
108
109 # If not the same, show diff
110 rc=$?
111 if [scip-shell system . . `[`. $rc -ne 0 ]
112 then
113 echoscip-shell system . . echo.
114 diffscip-shell system . . diff. -c "${name}.output.normalized" "${sourcedir}/${expected}"
115 else
116 echoscip-shell system . . echo. ${green}Ok${normal}
117 fi
118 exit $rc