File: test_diff.sh.in

package info (click to toggle)
plplot 5.15.0%2Bdfsg-19
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 31,312 kB
  • sloc: ansic: 79,707; xml: 28,583; cpp: 20,033; ada: 19,456; tcl: 12,081; f90: 11,431; ml: 7,276; java: 6,863; python: 6,792; sh: 3,274; perl: 828; lisp: 75; makefile: 50; sed: 34; fortran: 5
file content (247 lines) | stat: -rwxr-xr-x 7,203 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
#!@SH_EXECUTABLE@
# Test suite to compare C examples with other language bindings
#
# Copyright (C) 2008 Andrew Ross
# Copyright (C) 2008-2018 Alan W. Irwin
#
# This file is part of PLplot.
#
# PLplot is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PLplot is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with PLplot; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#

usage()
{
echo '
Usage: test_diff.sh [OPTIONS]

Options:
   [--device=DEVICE] (DEVICE = any CMake-enabled noninteractive PLplot device.  svg is the default)
   [--familied_device=STRING] (STRING should be "yes" if a familied device or anything else if not
                              a familied device.  The default is "yes" to be consistent with
                              the svg familied device default.)
   [--help]
'
   exit $1
}

# Figure out what script options were specified by the user.

device="svg"
familied_device="yes"

while test $# -gt 0; do
   if [ "@HAVE_BASH@" = "ON" ] ; then
      case "$1" in
      -*=*) optarg=${1#*=} ;;
      *) optarg= ;;
      esac
   else
      case "$1" in
      -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
      *) optarg= ;;
      esac
   fi
   case $1 in
      --device=*)
          device=$optarg
          ;;
      --familied_device=*)
          familied_device=$optarg
          ;;
      --help)
          usage 0 1>&2
          ;;
      *)
          usage 1 1>&2
          ;;
   esac
   shift
done

ret=0
# Comparison C results have no xsuffix.
xsuffix_c=

if [ "${familied_device}" = "yes" ] ; then
    echo -e "\nComparison test using ${device} device which has been asserted to be familied.\n"
    firstpage="01"
else
    echo -e "\nComparison test using ${device} device which has been asserted to be non-familied.\n"
    firstpage=""
fi

if [ "${device}" = "psc" ] || [ "${device}" = "ps" ] ; then
    date_stamped="yes"
    # Number of initial bytes to ignore to avoid datestamp
    ignore_bytes=190
    # Number of initial lines to ignore plus 1 (to indicate
    # which line to use to start the comparison) to avoid datestamp.
    ignore_lines_p1=9
elif [ "${device}" = "psttfc" ] || [ "${device}" = "psttf" ] ; then
    date_stamped="yes"
    ignore_bytes=520
    ignore_lines=17
else
    date_stamped=""
fi

# Compare C results with the following list of languages
for lang in adastandard adatraditional c++ d fortran java lua ocaml octave plrender python tcl ; do
    # Check which suffix is used for this binding
    case $lang in
	adastandard)
	    xsuffix=standard
	    suffix=a
	    ;;
	adatraditional)
	    xsuffix=traditional
	    suffix=a
	    ;;
	c++)
	    xsuffix=
	    suffix=cxx
	    ;;
	d)
	    xsuffix=
	    suffix=d
	    ;;
	fortran)
	    xsuffix=
	    suffix=f
	    ;;
	java)
	    xsuffix=
	    suffix=j
	    ;;
	lua)
	    xsuffix=
	    suffix=lua
	    ;;
	ocaml)
	    xsuffix=
	    suffix=ocaml
	    ;;
	octave)
	    xsuffix=
	    suffix=o
	    ;;
	plrender)
	    xsuffix=
	    suffix=plm
	    ;;
	python)
	    xsuffix=
	    suffix=p
	    ;;
	tcl)
	    xsuffix=
	    suffix=t
	    ;;
    esac

    missing=""
    different=""
    diffstdout=""
    missingstdout=""

    # List of standard examples
    INDEX_LIST="00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 14a 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 33"
    # Check if any examples exist for this language.
    EXAMPLES_EXIST="no"
    for index in ${INDEX_LIST} ; do
	if [ -f x${xsuffix}${index}${suffix}${firstpage}.${device} ] ; then
	    EXAMPLES_EXIST="yes"
	    break
	fi
    done
    if [ "$EXAMPLES_EXIST" = "yes" ] ; then
	for index in ${INDEX_LIST} ; do
	    if [ ! -f x${xsuffix_c}${index}c${firstpage}.${device} ] ; then
                echo "C example ${index} is missing"
	    else
		if [ ! -f x${xsuffix}${index}${suffix}${firstpage}.${device} ] ; then
		    missing="${missing} ${index}"
		else
                    if [ "${familied_device}" = "yes" ] ; then
                        let i=1
                        p="01"
                        pages=""
                        while [ -f "x${xsuffix_c}${index}c${p}.${device}" ] ; do
                            pages="${pages} ${p}"
                            let i=i+1
                            printf -v p "%02d" $i
                        done
                    else
                        pages="xxx"
                    fi
                    isdiff="no"
                    for p in $pages ; do
			if [ ${p} = "xxx" ] ; then
                            p=""
			fi
			if [ "@HAVE_CMP_I@" = "ON" ] ; then
			    if [ "${date_stamped}" = "yes" ] ; then
				# Skip first ${ignore_bytes} bytes of comparison to ignore date stamp.
				@CMP_EXECUTABLE@ -s -i ${ignore_bytes} x${xsuffix_c}${index}c${p}.${device} x${xsuffix}${index}${suffix}${p}.${device}
                            else
				@CMP_EXECUTABLE@ -s x${xsuffix_c}${index}c${p}.${device} x${xsuffix}${index}${suffix}${p}.${device}
                            fi
			    if [ $? != 0 ] && [ ! "${isdiff}" = "yes" ] ; then
				different="${different} ${index}"
				isdiff="yes"
			    fi
			else
			    if [ "${date_stamped}" = "yes" ] ; then
				# Drop first ${ignore_lines_p1} -1 lines from comparison (i.e., start
				# comparing at line ${ignore_lines_p1}) to ignore date stamp.
				@TAIL_EXECUTABLE@ -n +${ignore_lines_p1} x${xsuffix_c}${index}c${p}.${device} > test1.${device}
				@TAIL_EXECUTABLE@ -n +${ignore_lines_p1} x${xsuffix}${index}${suffix}${p}.${device} > test2.${device}
				@DIFF_EXECUTABLE@ -q test1.psc test2.psc 2>&1 > /dev/null
                            else
				@DIFF_EXECUTABLE@ -q x${xsuffix_c}${index}c${p}.${device} x${xsuffix}${index}${suffix}${p}.${device} 2>&1 > /dev/null
                            fi
			    if [ $? != 0 ] && [ ! "${isdiff}" = "yes" ] ; then
				different="${different} ${index}"
				isdiff="yes"
			    fi
			fi
                    done
		    if [ "$index" != "14a" ] ; then
			if [ -f x${xsuffix}${index}${suffix}_${device}.txt ] ; then
			    @DIFF_EXECUTABLE@ -q x${xsuffix_c}${index}c_${device}.txt x${xsuffix}${index}${suffix}_${device}.txt 2>&1 > /dev/null
			    if [ $? != 0 ] ; then
				diffstdout="${diffstdout} ${index}"
			    fi
			else
			    missingstdout="${missingstdout} ${index}"
			fi
		    fi
		fi
	    fi
	done
	echo "${lang}"
	echo "  Missing examples            : ${missing}"
	echo "  Differing graphical output  : ${different}"
	echo "  Missing stdout              : ${missingstdout}"
	echo "  Differing stdout            : ${diffstdout}"
	if [ "${different}" != "" -o "${diffstdout}" != "" ] ; then
	    ret=1
	fi
    fi
done

if [ "${ret}" != "0" ] ; then
    echo "WARNING: Some graphical or stdout results were different"
fi