1# Process with autom4te to create an -*- Autotest -*- test suite.
2
3AT_INIT([dmr-test])
4
5AT_ARG_OPTION_ARG([baselines],
6    [--baselines=yes|no   Build the baseline file for parser test 'arg'],
7    [echo "baselines set to $at_arg_baselines";
8     baselines=$at_arg_baselines],[baselines=])
9
10# There is no easy way to write a --generate... option for the function expression
11# tests. Better to do it by hand... Use ... .num.func_base as the extension for the
12# baselines.
13
14# Usage DMR_PARSE $1 <test_input> $2 <pass/xfail>
15# The baseline is assumed to be $1.baseline
16m4_define([DMR_PARSE], [
17
18    AT_SETUP([parse $1])
19    AT_KEYWORDS([parse])
20
21    input=$abs_srcdir/$1
22    baseline=$input.baseline
23
24    AS_IF([test -n "$baselines" -a x$baselines = xyes],
25        [
26        AT_CHECK([$abs_builddir/dmr-test -x -p $input], [ignore], [stdout], [stderr])
27        AT_CHECK([cat stdout stderr > $baseline.tmp])
28        ],
29        [
30        AT_CHECK([$abs_builddir/dmr-test -x -p $input || true], [], [stdout], [stderr])
31        AT_CHECK([diff -b -B $baseline stdout || diff -b -B $baseline stderr], [], [ignore],[],[])
32        AT_XFAIL_IF([test "$2" = "xfail"])
33        ])
34
35    AT_CLEANUP
36])
37
38# Test if the given  CE parses. This was added to test errant CEs to
39# ensure that the parser does not leak CE text into the error messages.
40# jhrg 4/15/20
41#
42# Usage DMR_PARSE_CE $1 <test_input> $2 <ce> $3 <baseline> $4 <pass/xfail>
43# The baseline is assumed to be $1.baseline
44m4_define([DMR_PARSE_CE], [
45
46    AT_SETUP([parse ce $1 $2])
47    AT_KEYWORDS([parse_ce])
48
49    input=$abs_srcdir/dmr-testsuite/$1
50    ce=$2
51    baseline=$abs_srcdir/dmr-testsuite/$3
52
53    AS_IF([test -n "$baselines" -a x$baselines = xyes],
54        [
55        AT_CHECK([$abs_builddir/dmr-test -x -p $input -c $ce], [ignore], [stdout], [stderr])
56        AT_CHECK([cat stdout stderr > $baseline.tmp])
57        ],
58        [
59        AT_CHECK([$abs_builddir/dmr-test -x -p $input -c $ce], [ignore], [stdout], [stderr])
60        AT_CHECK([cat stdout stderr > tmp])
61        AT_CHECK([diff -b -B $baseline tmp], [0])
62        AT_XFAIL_IF([test "z$3" = "zxfail"])
63        ])
64
65    AT_CLEANUP
66])
67
68
69
70# Usage DMR_TRANS $1 <test_input> $2 <pass/xfail>
71# This code tests the values printed when the received document is decoded.
72m4_define([DMR_TRANS], [
73    # Test transmitting data (i.e., writing the Data DMR to a file and then decoding it)
74    AT_SETUP([trans $1])
75    AT_KEYWORDS([trans])
76
77    # WORD_ORDER is set by configure in atlocal.
78    # This is a fix for the issue where the CRC32 checksum is different
79    # on little- and big-endian machines, so we use different baseline
80    # files.  jhrg 9/30/15
81
82    input=$abs_srcdir/dmr-testsuite/$1
83    baseline=$abs_srcdir/dmr-testsuite/$WORD_ORDER/$1.trans_base
84
85    AS_IF([test -n "$baselines" -a x$baselines = xyes],
86        [
87        # // old version - sbl 9.4.19
88        # AT_CHECK([$abs_builddir/dmr-test -x -t $input], [0], [stdout], [ignore])
89
90        AT_CHECK([$abs_builddir/dmr-test -x -t $input], [ignore], [stdout], [stderr])
91        AT_CHECK([cat stdout stderr > $baseline.tmp])
92        ],
93        [
94        AT_CHECK([$abs_builddir/dmr-test -x -t $input || true], [], [stdout], [stderr])
95        AT_CHECK([diff -b -B $baseline stdout || diff -b -B $baseline stderr], [], [ignore],[],[])
96
97        AT_XFAIL_IF([test "$2" = "xfail"])
98        ])
99
100    AT_CLEANUP
101])
102
103# Usage DMR_TRANS_UNIVERSAL $1 <test_input> $2 <pass/xfail>
104# This code tests the values printed when the received document is decoded.
105m4_define([DMR_TRANS_UNIVERSAL], [
106    # Test transmitting data (i.e., writing the Data DMR to a file and then decoding it)
107    AT_SETUP([trans $1])
108    AT_KEYWORDS([trans])
109
110    # WORD_ORDER is set by configure in atlocal.
111    # This is a fix for the issue where the CRC32 checksum is different
112    # on little- and big-endian machines, so we use different baseline
113    # files.  jhrg 9/30/15
114
115    input=$abs_srcdir/dmr-testsuite/$1
116    baseline=$abs_srcdir/dmr-testsuite/universal/$1.trans_base
117
118    AS_IF([test -n "$baselines" -a x$baselines = xyes],
119        [
120        echo "The command <>$abs_builddir/dmr-test -x -t $input $checksum_filt<>"
121
122        # // old version - sbl 9.4.19
123        # AT_CHECK([$abs_builddir/dmr-test -x -t $input | sed 's@<Value>[[0-9a-f]][[0-9a-f]]*</Value>@@' ], [0], [stdout], [ignore])
124
125        AT_CHECK([$abs_builddir/dmr-test -x -t $input | sed 's@<Value>[[0-9a-f]][[0-9a-f]]*</Value>@@' ], [ignore], [stdout], [stderr])
126        AT_CHECK([cat stdout stderr > $baseline.tmp])
127        ],
128        [
129        AT_CHECK([$abs_builddir/dmr-test -x -t $input | sed 's@<Value>[[0-9a-f]][[0-9a-f]]*</Value>@@' ], [], [stdout], [ignore])
130        AT_CHECK([diff -b -B $baseline stdout], [], [ignore],[],[])
131
132        AT_XFAIL_IF([test "$2" = "xfail"])
133        ])
134
135    AT_CLEANUP
136])
137
138# Usage DMR_TRANS_CE <test_input> <ce> <baseline> <pass/xfail>
139# This code tests the values printed when the received document is decoded.
140m4_define([DMR_TRANS_CE], [
141    # Test transmitting data (i.e., writing the Data DMR to a file and then decoding it)
142    # after applying a constraint expression to the source DMR.
143    AT_SETUP([trans ce $1 $2 $3])
144    AT_KEYWORDS([trans_ce])
145
146    # See above regarding $WORD_ORDER
147    input=$abs_srcdir/dmr-testsuite/$1
148    baseline=$abs_srcdir/dmr-testsuite/$WORD_ORDER/$3
149
150    AS_IF([test -n "$baselines" -a x$baselines = xyes],
151        [
152        # // old version - sbl 9.4.19
153        # AT_CHECK([$abs_builddir/dmr-test -x -t $input -c "$2"], [], [stdout], []) old version
154
155        AT_CHECK([$abs_builddir/dmr-test -x -t $input -c "$2"], [ignore], [stdout], [stderr])
156        AT_CHECK([cat stdout stderr > $baseline.tmp])
157        ],
158        [
159        AT_CHECK([$abs_builddir/dmr-test -x -t $input -c "$2" || true], [], [stdout], [stderr])
160        AT_CHECK([diff -b -B $baseline stdout || diff -b -B $baseline stderr], [], [ignore],[],[])
161        AT_XFAIL_IF([test "X$4" = "Xxfail"])
162        ])
163
164    AT_CLEANUP
165])
166
167# Usage DMR_TRANS_FUNC_CE <test_input> <func expr> <ce> <baseline> <pass/xfail>
168# This code tests the values printed when the received document is decoded.
169m4_define([DMR_TRANS_FUNC_CE], [
170    # Test transmitting data (i.e., writing the Data DMR to a file and then decoding it)
171    # after applying a function and constraint expression to the source DMR. If either
172    # the function or constraint are empty strings, they will be ignored.
173    AT_SETUP([trans $1 $2 $3 $4])
174    AT_KEYWORDS([trans_func_ce])
175
176    input=$abs_srcdir/dmr-testsuite/$1
177    fe="$2"
178    ce="$3"
179    baseline=$abs_srcdir/dmr-testsuite/$WORD_ORDER/$4
180
181    AS_IF([test -n "$baselines" -a x$baselines = xyes],
182        [
183        # // old version - sbl 9.4.19
184        # AT_CHECK([$abs_builddir/dmr-test -x -t $input -f "$fe" -c "$ce"], [], [stdout], [])
185
186        AT_CHECK([$abs_builddir/dmr-test -x -t $input -f "$fe" -c "$ce"], [ignore], [stdout], [stderr])
187        AT_CHECK([cat stdout stderr > $baseline.tmp])
188        ],
189        [
190        AT_CHECK([$abs_builddir/dmr-test -x -t $input -f "$fe" -c "$ce" || true], [], [stdout], [stderr])
191        AT_CHECK([diff -b -B $baseline stdout || diff -b -B $baseline stderr], [], [ignore],[],[])
192        AT_XFAIL_IF([test "X$5" = "Xxfail"])
193        ])
194
195    AT_CLEANUP
196])
197
198# Usage DMR_TRANS_SERIES_CE <test_input> <ce> <baseline> <pass/xfail>
199# This macro tests CEs using the series values from the Test classes.
200# It's intended to be used to test the filter expressions.
201#
202# This is a 'universal' test - the baselines do not differ for word order
203# because the checksums are removed. jhrg 5/5/16
204m4_define([DMR_TRANS_SERIES_CE], [
205    AT_SETUP([filter $1 $2 $3])
206    AT_KEYWORDS([filter])
207
208    input=$abs_srcdir/dmr-testsuite/$1
209    ce="$2"
210    baseline=$abs_srcdir/dmr-testsuite/universal/$3
211
212    AS_IF([test -n "$baselines" -a x$baselines = xyes],
213        [
214        # // old version - sbl 9.4.19
215        # AT_CHECK([$abs_builddir/dmr-test -x -e -t $input -c "$ce" | sed 's@<Value>[[0-9a-f]][[0-9a-f]]*</Value>@@' ], [], [stdout], [])
216
217        AT_CHECK([$abs_builddir/dmr-test -x -e -t $input -c "$ce" | sed 's@<Value>[[0-9a-f]][[0-9a-f]]*</Value>@@' ], [ignore], [stdout], [stderr])
218        AT_CHECK([cat stdout stderr > $baseline.tmp])
219        ],
220        [
221        AT_CHECK([$abs_builddir/dmr-test -x -e -t $input -c "$ce" | sed 's@<Value>[[0-9a-f]][[0-9a-f]]*</Value>@@' ], [], [stdout], [])
222        AT_CHECK([diff -b -B $baseline stdout], [], [ignore],[],[])
223        AT_XFAIL_IF([test "X$4" = "Xxfail"])
224        ])
225
226    AT_CLEANUP
227])
228
229# Usage DMR_INTERN $1 <test_input> $2 <pass/xfail>
230# This code tests the values printed when the received document is decoded.
231m4_define([DMR_INTERN], [
232    # Test reading/interning data (i.e., using the read() methods to load up objects with
233    # values without running them through serialize/deserialize)
234    AT_SETUP([intern $1])
235    AT_KEYWORDS([intern])
236
237    # WORD_ORDER is set by configure in atlocal.
238    # This is a fix for the issue where the CRC32 checksum is different
239    # on little- and big-endian machines, so we use different baseline
240    # files.  jhrg 9/30/15
241    input=$abs_srcdir/dmr-testsuite/$1
242    baseline=$abs_srcdir/dmr-testsuite/$WORD_ORDER/$1.intern_base
243
244    AS_IF([test -n "$baselines" -a x$baselines = xyes],
245        [
246        # // old version - sbl 9.4.19
247        # AT_CHECK([$abs_builddir/dmr-test -x -i $input], [], [stdout], [])
248
249        AT_CHECK([$abs_builddir/dmr-test -x -i $input], [ignore], [stdout], [stderr])
250        AT_CHECK([cat stdout stderr > $baseline.tmp])
251        ],
252        [
253        AT_CHECK([$abs_builddir/dmr-test -x -i $input || true], [], [stdout], [stderr])
254        AT_CHECK([diff -b -B $baseline stdout], [], [ignore], [], [])
255
256        AT_XFAIL_IF([test "$2" = "xfail"])
257        ])
258
259    AT_CLEANUP
260])
261
262DMR_PARSE([dmr-testsuite/test_simple_1.xml], [pass])
263DMR_PARSE([dmr-testsuite/test_simple_2.xml], [pass])
264DMR_PARSE([dmr-testsuite/test_simple_3.xml], [pass])
265
266DMR_PARSE([dmr-testsuite/test_simple_3_error_1.xml], [pass])
267DMR_PARSE([dmr-testsuite/test_simple_3_error_2.xml], [pass])
268DMR_PARSE([dmr-testsuite/test_simple_3_error_3.xml], [pass])
269
270DMR_PARSE([dmr-testsuite/test_simple_4.xml], [pass])
271DMR_PARSE([dmr-testsuite/test_simple_5.xml], [pass])
272DMR_PARSE([dmr-testsuite/test_simple_6.xml], [pass])
273DMR_PARSE([dmr-testsuite/test_simple_7.xml], [pass])
274DMR_PARSE([dmr-testsuite/test_simple_8.xml], [pass])
275DMR_PARSE([dmr-testsuite/test_simple_9.xml], [pass])
276DMR_PARSE([dmr-testsuite/test_simple_9.1.xml], [pass])
277DMR_PARSE([dmr-testsuite/test_simple_10.xml], [pass])
278
279DMR_PARSE([dmr-testsuite/test_array_1.xml], [pass])
280DMR_PARSE([dmr-testsuite/test_array_2.xml], [pass])
281DMR_PARSE([dmr-testsuite/test_array_3.xml], [pass])
282DMR_PARSE([dmr-testsuite/test_array_4.xml], [pass])
283DMR_PARSE([dmr-testsuite/test_array_5.xml], [pass])
284DMR_PARSE([dmr-testsuite/test_array_6.xml], [pass])
285DMR_PARSE([dmr-testsuite/test_array_7.xml], [pass])
286DMR_PARSE([dmr-testsuite/test_array_8.xml], [pass])
287DMR_PARSE([dmr-testsuite/test_array_10.xml], [pass])
288DMR_PARSE([dmr-testsuite/test_array_11.xml], [pass])
289
290DMR_PARSE([dmr-testsuite/ignore_foreign_xml_1.xml], [pass])
291DMR_PARSE([dmr-testsuite/ignore_foreign_xml_2.xml], [pass])
292DMR_PARSE([dmr-testsuite/ignore_foreign_xml_3.xml], [pass])
293
294# Transmit: Test building and then decoding the response
295# These calls don't include the 'dmr-testsuite' directory because the tests
296# need to choose baselines based on the word order. We could probably re-
297# organize these so that the dir names where here - which I prefer, but
298# the new 'baselines' option makes it far easier to build the baselines, and
299# that was the primary reason for keeping the directory names here and explicit;
300# it made it much easier to sort out what input to use when building a baseline.
301
302DMR_TRANS([test_simple_1.xml], [pass])
303DMR_TRANS([test_simple_2.xml], [pass])
304DMR_TRANS([test_simple_3.xml], [pass])
305DMR_TRANS([test_simple_4.xml], [pass])
306DMR_TRANS([test_simple_5.xml], [pass])
307DMR_TRANS([test_simple_6.xml], [pass])
308DMR_TRANS([test_simple_7.xml], [pass])
309DMR_TRANS([test_simple_8.xml], [xfail])
310DMR_TRANS([test_simple_9.xml], [pass])
311DMR_TRANS([test_simple_9.1.xml], [pass])
312DMR_TRANS([test_simple_10.xml], [pass])
313
314DMR_TRANS([test_array_1.xml], [pass])
315DMR_TRANS([test_array_2.xml], [pass])
316DMR_TRANS([test_array_3.xml], [pass])
317DMR_TRANS([test_array_4.xml], [pass])
318DMR_TRANS([test_array_5.xml], [pass])
319DMR_TRANS([test_array_6.xml], [pass])
320DMR_TRANS([test_array_7.xml], [pass])
321DMR_TRANS([test_array_8.xml], [pass])
322DMR_TRANS([test_array_10.xml], [pass])
323DMR_TRANS([test_array_11.xml], [pass])
324
325DMR_INTERN([test_simple_1.xml], [pass])
326DMR_INTERN([test_simple_2.xml], [pass])
327DMR_INTERN([test_simple_3.xml], [pass])
328DMR_INTERN([test_simple_4.xml], [pass])
329DMR_INTERN([test_simple_5.xml], [pass])
330DMR_INTERN([test_simple_6.xml], [pass])
331DMR_INTERN([test_simple_7.xml], [pass])
332DMR_INTERN([test_simple_8.xml], [pass])
333DMR_INTERN([test_simple_9.xml], [pass])
334DMR_INTERN([test_simple_9.1.xml], [pass])
335DMR_INTERN([test_simple_10.xml], [pass])
336
337DMR_INTERN([test_array_1.xml], [pass])
338DMR_INTERN([test_array_2.xml], [pass])
339DMR_INTERN([test_array_3.xml], [pass])
340DMR_INTERN([test_array_4.xml], [pass])
341DMR_INTERN([test_array_5.xml], [pass])
342DMR_INTERN([test_array_6.xml], [pass])
343DMR_INTERN([test_array_7.xml], [pass])
344DMR_INTERN([test_array_8.xml], [pass])
345DMR_INTERN([test_array_10.xml], [pass])
346DMR_INTERN([test_array_11.xml], [pass])
347
348# Test zero-length arrays. jhrg 1/28/16
349DMR_PARSE([dmr-testsuite/test_array_9.xml], [pass])
350DMR_PARSE([dmr-testsuite/test_array_12.xml], [pass])
351DMR_PARSE([dmr-testsuite/test_array_13.xml], [pass])
352DMR_PARSE([dmr-testsuite/test_array_14.xml], [pass])
353
354# Test empty Structures. jhrg 1/29/16
355DMR_PARSE([dmr-testsuite/test_simple_6.2.xml], [pass])
356DMR_PARSE([dmr-testsuite/test_simple_6.3.xml], [pass])
357
358DMR_TRANS([test_array_9.xml], [pass])
359DMR_TRANS([test_array_12.xml], [pass])
360DMR_TRANS([test_array_13.xml], [pass])
361DMR_TRANS([test_array_14.xml], [pass])
362
363DMR_TRANS([test_simple_6.2.xml], [pass])
364DMR_TRANS([test_simple_6.3.xml], [pass])
365
366# Test out the 'universal' tests
367DMR_TRANS_UNIVERSAL([test_array_9.xml], [pass])
368DMR_TRANS_UNIVERSAL([test_array_12.xml], [pass])
369DMR_TRANS_UNIVERSAL([test_array_13.xml], [pass])
370DMR_TRANS_UNIVERSAL([test_array_14.xml], [pass])
371
372DMR_TRANS_UNIVERSAL([test_simple_6.2.xml], [pass])
373DMR_TRANS_UNIVERSAL([test_simple_6.3.xml], [pass])
374
375DMR_INTERN([test_array_9.xml], [pass])
376DMR_INTERN([test_array_12.xml], [pass])
377DMR_INTERN([test_array_13.xml], [pass])
378DMR_INTERN([test_array_14.xml], [pass])
379
380DMR_INTERN([test_simple_6.2.xml], [pass])
381DMR_INTERN([test_simple_6.3.xml], [pass])
382
383# These tests only work for little-endian machines at this time. If baselines for
384# big-endian machines are built, this AS_IF can be removed.
385
386# Added these tests as part of https://opendap.atlassian.net/browse/HYRAX-98.
387# jhrg 4/13/16
388
389AS_IF([test "$WORD_ORDER" = "little-endian"],
390[
391DMR_TRANS_CE([test_array_3.1.dmr], [row;x], [test_array_3.1.dmr.1.trans_base], [pass])
392DMR_TRANS_CE([test_array_3.1.dmr], [row=[[2:3]];x], [test_array_3.1.dmr.2.trans_base], [pass])
393DMR_TRANS_CE([test_array_3.1.dmr], [row=[[2:3]];x[[0:1]]], [test_array_3.1.dmr.3.trans_base], [pass])
394DMR_TRANS_CE([test_array_3.1.dmr], [x[[0:1]]], [test_array_3.1.dmr.4.trans_base], [pass])
395DMR_TRANS_CE([test_array_3.1.dmr], [x], [test_array_3.1.dmr.5.trans_base], [pass])
396],
397[])
398
399# Test various facets of the CE parser and evaluation engine
400
401DMR_TRANS_CE([test_array_4.xml], [a], [test_array_4.xml.1.trans_base], [pass])
402DMR_TRANS_CE([test_array_4.xml], [a[[]][[]] ], [test_array_4.xml.1.trans_base], [pass])
403
404DMR_TRANS_CE([test_array_4.xml], [/row=[[0:1]];/col=[[3]];a],  [test_array_4.xml.3.trans_base], [pass])
405
406DMR_TRANS_CE([test_array_4.xml], [/row=[[0:1]];/col=[[3]];a[[]][[]] ],  [test_array_4.xml.4.trans_base], [pass])
407
408DMR_TRANS_CE([test_array_4.xml], [/row=[[0:1]];/col=[[3]];a[[]][[]];b[[0]][[]];c[[0:]][[0:]] ],  [test_array_4.xml.5.trans_base], [pass])
409
410DMR_TRANS_CE([test_array_4.xml], [x[[]][[]] ], [/test_array_4.xml.6.trans_base], [pass])
411DMR_TRANS_CE([test_array_4.xml], [/row=[[0:1]];x[[]][[]] ], [test_array_4.xml.7.trans_base], [pass])
412
413DMR_TRANS_CE([test_array_4.xml], [c[[2:]][[2:]] ], [test_array_4.xml.8.trans_base], [pass])
414
415DMR_TRANS_CE([test_simple_6.xml], [s], [test_simple_6.xml.1.trans_base], [pass])
416DMR_TRANS_CE([test_simple_6.xml], [s.i1], [test_simple_6.xml.2.trans_base], [pass])
417DMR_TRANS_CE([test_simple_6.xml], [s.s], [test_simple_6.xml.3.trans_base], [pass])
418DMR_TRANS_CE([test_simple_6.1.xml], [s.inner.i2], [test_simple_6.1.xml.1.trans_base], [pass])
419
420DMR_TRANS_CE([test_simple_6.xml], [s{i1}], [test_simple_6.xml.2.trans_base], [pass])
421DMR_TRANS_CE([test_simple_6.xml], [s{s}], [test_simple_6.xml.3.trans_base], [pass])
422DMR_TRANS_CE([test_simple_6.1.xml], [s{inner.i2}], [test_simple_6.1.xml.1.trans_base], [pass])
423DMR_TRANS_CE([test_simple_6.1.xml], [s{inner{i2}}], [test_simple_6.1.xml.1.trans_base], [pass])
424
425# test_array_6 holds a 2D array of Structure
426DMR_TRANS_CE([test_array_6.xml], [a], [test_array_6.xml.1.trans_base], [pass])
427DMR_TRANS_CE([test_array_6.xml], [a[[]][[]] ], [test_array_6.xml.1.trans_base], [pass])
428DMR_TRANS_CE([test_array_6.xml], [/row=[[0:1]];a[[]][[]] ], [test_array_6.xml.2.trans_base], [pass])
429DMR_TRANS_CE([test_array_6.xml], [/row=[[0:1]];a[[]][[1:2]] ], [test_array_6.xml.3.trans_base], [pass])
430
431# test_array holds a Structure that has a 2D array for a field
432DMR_TRANS_CE([test_array_6.2.xml], [a], [test_array_6.2.xml.1.trans_base], [pass])
433DMR_TRANS_CE([test_array_6.2.xml], [a{i;j}], [test_array_6.2.xml.1.trans_base], [pass])
434DMR_TRANS_CE([test_array_6.2.xml], [a.i], [test_array_6.2.xml.2.trans_base], [pass])
435DMR_TRANS_CE([test_array_6.2.xml], [a{i}], [test_array_6.2.xml.2.trans_base], [pass])
436DMR_TRANS_CE([test_array_6.2.xml], [a.i[[0]][[1:2]] ], [test_array_6.2.xml.3.trans_base], [pass])
437DMR_TRANS_CE([test_array_6.2.xml], [a{i[[0]][[1:2]]} ], [test_array_6.2.xml.3.trans_base], [pass])
438DMR_TRANS_CE([test_array_6.2.xml], [/row=[[0:1]];a.i[[]][[1:2]] ], [test_array_6.2.xml.4.trans_base], [pass])
439DMR_TRANS_CE([test_array_6.2.xml], [/row=[[0:1]];a{i[[]][[1:2]]} ], [test_array_6.2.xml.4.trans_base], [pass])
440
441DMR_TRANS_CE([test_array_6.2.xml], [a.j], [test_array_6.2.xml.5.trans_base], [pass])
442
443# test_array_6.1 is an array of Structure that holds an array and a scalar
444DMR_TRANS_CE([test_array_6.1.xml], [a], [test_array_6.1.xml.1.trans_base], [pass])
445
446# slice the structure but not the field
447DMR_TRANS_CE([test_array_6.1.xml], [/row=[[1:2]];a[[]][[0]] ], [test_array_6.1.xml.2.trans_base], [pass])
448DMR_TRANS_CE([test_array_6.1.xml], [/row=[[1:2]];a[[]][[0]]{i;j} ], [test_array_6.1.xml.2.trans_base], [pass])
449# Do we really need the FQN?
450DMR_TRANS_CE([test_array_6.1.xml], [row=[[1:2]];a[[]][[0]]{i;j} ], [test_array_6.1.xml.2.trans_base], [pass])
451
452# slice the field but not the structure
453DMR_TRANS_CE([test_array_6.1.xml], [a{i[[1:2]][[1:3]];j} ], [test_array_6.1.xml.3.trans_base], [pass])
454DMR_TRANS_CE([test_array_6.1.xml], [a[[]][[]]{i[[1:2]][[1:3]];j} ], [test_array_6.1.xml.3.trans_base], [pass])
455
456# slice both the structure and the array it contains using both the shared dim and
457# a local slice for each
458DMR_TRANS_CE([test_array_6.1.xml], [/row=[[1]];a[[]][[0]]{i[[]][[0:1]]} ], [test_array_6.1.xml.4.trans_base], [pass])
459
460# Test sequences and arrays of sequences
461DMR_TRANS_CE([test_simple_7.xml], [s], [test_simple_7.xml.1.trans_base], [pass])
462DMR_TRANS_CE([test_simple_7.xml], [s{i1;s}], [test_simple_7.xml.1.trans_base], [pass])
463
464DMR_TRANS_CE([test_simple_7.xml], [s.i1], [test_simple_7.xml.2.trans_base], [pass])
465DMR_TRANS_CE([test_simple_7.xml], [s{i1}], [test_simple_7.xml.2.trans_base], [pass])
466
467DMR_TRANS_CE([test_simple_8.xml], [outer], [test_simple_8.xml.1.trans_base], [xfail])
468DMR_TRANS_CE([test_simple_8.xml], [outer.s.s], [test_simple_8.xml.2.trans_base], [xfail])
469DMR_TRANS_CE([test_simple_8.xml], [outer{s{s}}], [test_simple_8.xml.2.trans_base], [xfail])
470
471DMR_TRANS_CE([test_array_7.xml], [s], [test_array_7.xml.1.trans_base], [pass])
472DMR_TRANS_CE([test_array_7.xml], [s{i1;s}], [test_array_7.xml.1.trans_base], [pass])
473
474DMR_TRANS_CE([test_array_7.xml], [s.i1], [test_array_7.xml.2.trans_base], [pass])
475DMR_TRANS_CE([test_array_7.xml], [s{i1}], [test_array_7.xml.2.trans_base], [pass])
476
477DMR_TRANS_CE([test_array_7.xml], [s[[1]] ], [test_array_7.xml.3.trans_base], [pass])
478DMR_TRANS_CE([test_array_7.xml], [s[[1]]{i1;s}], [test_array_7.xml.3.trans_base], [pass])
479
480DMR_TRANS_CE([test_array_7.xml], [s[[1]]{i1}], [test_array_7.xml.4.trans_base], [pass])
481
482# test_array_8 has a 2D Sequence that uses a shared dim
483DMR_TRANS_CE([test_array_8.xml], [/col=[[1:2]];s[[1]][[]]{i1}], [test_array_8.xml.1.trans_base], [pass])
484DMR_TRANS_CE([test_array_8.xml], [col=[[1:2]];s[[1]][[]]{i1}], [test_array_8.xml.1.trans_base], [pass])
485
486# test_array_7.1 holds a sequence that has an array for one of its fields
487DMR_TRANS_CE([test_array_7.1.xml], [], [test_array_7.1.xml.1.trans_base], [pass])
488DMR_TRANS_CE([test_array_7.1.xml], [s], [test_array_7.1.xml.1.trans_base], [pass])
489
490DMR_TRANS_CE([test_array_7.1.xml], [s.i1], [test_array_7.1.xml.2.trans_base], [pass])
491DMR_TRANS_CE([test_array_7.1.xml], [s.i1[[]][[]] ], [test_array_7.1.xml.2.trans_base], [pass])
492DMR_TRANS_CE([test_array_7.1.xml], [s{i1}], [test_array_7.1.xml.2.trans_base], [pass])
493DMR_TRANS_CE([test_array_7.1.xml], [s{i1[[]][[]]} ], [test_array_7.1.xml.2.trans_base], [pass])
494
495DMR_TRANS_CE([test_array_7.1.xml], [s.i1[[0]][[0]] ], [test_array_7.1.xml.3.trans_base], [pass])
496DMR_TRANS_CE([test_array_7.1.xml], [s{i1[[0]][[0]]} ], [test_array_7.1.xml.3.trans_base], [pass])
497
498DMR_TRANS_CE([test_array_7.1.xml], [s.i1[[0:2]][[1:2]] ], [test_array_7.1.xml.4.trans_base], [pass])
499
500# Should this CE be supported? jhrg 12/23/13
501# DMR_TRANS_CE([test_array_7.1.xml], [/row=[[2:3]];/col=[[2:3]] ], [test_array_7.1.xml.5.trans_base], [pass])
502DMR_TRANS_CE([test_array_7.1.xml], [/row=[[2:3]];/col=[[2:3]];s ], [test_array_7.1.xml.5.trans_base], [pass])
503
504DMR_TRANS_CE([test_array_7.1.xml], [/row=[[2:3]];/col=[[2:3]];s.i1 ], [test_array_7.1.xml.6.trans_base], [pass])
505DMR_TRANS_CE([test_array_7.1.xml], [/row=[[2:3]];/col=[[2:3]];s.i1[[]][[]] ], [test_array_7.1.xml.6.trans_base], [pass])
506DMR_TRANS_CE([test_array_7.1.xml], [/row=[[2:3]];/col=[[2:3]];s{i1} ], [test_array_7.1.xml.6.trans_base], [pass])
507DMR_TRANS_CE([test_array_7.1.xml], [/row=[[2:3]];/col=[[2:3]];s{i1[[]][[]]} ], [test_array_7.1.xml.6.trans_base], [pass])
508
509# test_array_7.2 is a sequence array that holds an array as one of its fields
510DMR_TRANS_CE([test_array_7.2.xml], [/col=[[1:2]];s[[]]{i1}], [test_array_7.2.xml.1.trans_base], [pass])
511DMR_TRANS_CE([test_array_7.2.xml], [/col=[[1:2]];s[[]]{i1[[]][[]]}], [test_array_7.2.xml.1.trans_base], [pass])
512DMR_TRANS_CE([test_array_7.2.xml], [/col=[[1:2]];s{i1[[]][[]]}], [test_array_7.2.xml.1.trans_base], [pass])
513
514DMR_TRANS_CE([test_array_7.2.xml], [/col=[[1:2]];s[[]]{i1[[0]][[]]}], [test_array_7.2.xml.2.trans_base], [pass])
515DMR_TRANS_CE([test_array_7.2.xml], [/col=[[1:2]];s{i1[[0]][[]]}], [test_array_7.2.xml.2.trans_base], [pass])
516
517DMR_TRANS_CE([test_array_7.2.xml], [/col=[[1:2]];s[[0]]{i1}], [test_array_7.2.xml.3.trans_base], [pass])
518DMR_TRANS_CE([test_array_7.2.xml], [/col=[[1:2]];s[[0]]{i1[[]][[]]}], [test_array_7.2.xml.3.trans_base], [pass])
519
520DMR_TRANS_CE([test_array_7.2.xml], [/col=[[1:2]];s[[0]]{i1[[0]][[]]}], [test_array_7.2.xml.4.trans_base], [pass])
521
522# Test the function parser and evaluator. The function 'scale' is defined
523# for both DAP2 and DAP4 in D4TestFunction.cc/h
524DMR_TRANS_FUNC_CE([test_array_1.xml], [scale(x,1)], [], [test_array_1.xml.1.func_base], [pass])
525DMR_TRANS_FUNC_CE([test_array_1.xml], [scale(x,10)], [], [test_array_1.xml.2.func_base], [pass])
526DMR_TRANS_FUNC_CE([test_array_1.xml], [scale(x,-10)], [], [test_array_1.xml.3.func_base], [pass])
527DMR_TRANS_FUNC_CE([test_array_1.xml], [scale(x,0.001)], [], [test_array_1.xml.4.func_base], [pass])
528DMR_TRANS_FUNC_CE([test_array_1.xml], [scale(x,-0.001)], [], [test_array_1.xml.5.func_base], [pass])
529
530# Test the largest signed int64 value (it will be stored in a D4RValue that
531# holds a Int64 variable).
532DMR_TRANS_FUNC_CE([test_array_1.xml], [scale(x,0x7fffffffffffffff)], [], [test_array_1.xml.6.func_base], [pass])
533# This only fits in a unsigned long long (DAP4's UInt64)
534DMR_TRANS_FUNC_CE([test_array_1.xml], [scale(x,0x8fffffffffffffff)], [], [test_array_1.xml.7.func_base], [pass])
535
536# test_array_5 has 64 bit ints in c and d; a and b are Int8 and UInt8 types
537# all of these test arrays that use named dimensions
538DMR_TRANS_FUNC_CE([test_array_5.xml], [scale(a,0.001)], [], [test_array_5.xml.1.func_base], [pass])
539DMR_TRANS_FUNC_CE([test_array_5.xml], [scale(b,0.001)], [], [test_array_5.xml.2.func_base], [pass])
540
541DMR_TRANS_FUNC_CE([test_array_5.xml], [scale(c,0.001)], [], [test_array_5.xml.3.func_base], [pass])
542DMR_TRANS_FUNC_CE([test_array_5.xml], [scale(d,0.001)], [], [test_array_5.xml.4.func_base], [pass])
543
544# Use the vol_1_ce_* datasets for tests
545
546# Test using variables for source values and functional composition
547DMR_TRANS_FUNC_CE([vol_1_ce_1.xml], [scale(u,10)], [], [vol_1_ce_1.xml.1.func_base], [pass])
548DMR_TRANS_FUNC_CE([vol_1_ce_1.xml], [scale(u,v)], [], [vol_1_ce_1.xml.2.func_base], [pass])
549DMR_TRANS_FUNC_CE([vol_1_ce_1.xml], [scale(scale(u,10),0.01)], [], [vol_1_ce_1.xml.3.func_base], [pass])
550
551# Test name parsing for Structure members
552DMR_TRANS_FUNC_CE([vol_1_ce_1.xml], [scale(Point.x,10)], [], [vol_1_ce_1.xml.4.func_base], [pass])
553DMR_TRANS_FUNC_CE([vol_1_ce_1.xml], [scale(Point.x,Point.y)], [], [vol_1_ce_1.xml.5.func_base], [pass])
554DMR_TRANS_FUNC_CE([vol_1_ce_1.xml], [scale(scale(Point.x,10),0.01)], [], [vol_1_ce_1.xml.6.func_base], [pass])
555
556# Test the 'array constant' special form (we need a dataset only because the parser needs a DMR to run)
557DMR_TRANS_FUNC_CE([vol_1_ce_1.xml], [scale(\$Byte(20:1,2,3,4),10)], [], [vol_1_ce_1.xml.7.func_base], [pass])
558DMR_TRANS_FUNC_CE([vol_1_ce_1.xml], [scale(\$Int8(20:10,11,12,-9),10)], [], [vol_1_ce_1.xml.8.func_base], [pass])
559DMR_TRANS_FUNC_CE([vol_1_ce_1.xml], [scale(\$UInt16(20:1,2,3,4),10)], [], [vol_1_ce_1.xml.9.func_base], [pass])
560DMR_TRANS_FUNC_CE([vol_1_ce_1.xml], [scale(\$Int16(20:1,2,3,-4),10)], [], [vol_1_ce_1.xml.10.func_base], [pass])
561DMR_TRANS_FUNC_CE([vol_1_ce_1.xml], [scale(\$UInt32(20:1,2,3,4),10)], [], [vol_1_ce_1.xml.11.func_base], [pass])
562DMR_TRANS_FUNC_CE([vol_1_ce_1.xml], [scale(\$Int32(20:1,2,3,-4),10)], [], [vol_1_ce_1.xml.12.func_base], [pass])
563DMR_TRANS_FUNC_CE([vol_1_ce_1.xml], [scale(\$UInt64(20:1,2,3,0xffffffffffffffff),1)], [], [vol_1_ce_1.xml.13.func_base], [pass])
564DMR_TRANS_FUNC_CE([vol_1_ce_1.xml], [scale(\$Int64(20:1,2,3,0x7fffffffffffffff),1)], [], [vol_1_ce_1.xml.14.func_base], [pass])
565DMR_TRANS_FUNC_CE([vol_1_ce_1.xml], [scale(\$Float32(20:1,2,3,4.55),10)], [], [vol_1_ce_1.xml.15.func_base], [pass])
566DMR_TRANS_FUNC_CE([vol_1_ce_1.xml], [scale(\$Float64(20:1,2,3,4.55),10)], [], [vol_1_ce_1.xml.16.func_base], [pass])
567
568# Test a sequence of function calls and the application of a Constraint to
569# a function result
570DMR_TRANS_FUNC_CE([vol_1_ce_10.xml], [scale(lat,10)], [], [vol_1_ce_10.xml.1.func_base], [pass])
571DMR_TRANS_FUNC_CE([vol_1_ce_10.xml], [scale(lat,10);scale(lon,10)], [], [vol_1_ce_10.xml.2.func_base], [pass])
572DMR_TRANS_FUNC_CE([vol_1_ce_10.xml], [scale(lat,10);scale(lon,10)], [lat[[10:11]][[10:11]];lon[[10:11]][[10:11]]], [vol_1_ce_10.xml.3.func_base], [pass])
573
574# Tests added for the D4Sequence filter support. jhrg 4/28/16
575# These will be 'universal' tests (the idea was introduced on the
576# master branch and tested out up above. See the calls to
577# DMR_TRANS_UNIVERSAL jhrg 5/5/16
578
579DMR_TRANS_SERIES_CE([test_simple_7.xml], [s], [test_simple_7.xml.f.trans_base], [pass])
580
581DMR_TRANS_SERIES_CE([test_simple_7.xml], [s|i1==1024], [test_simple_7.xml.f1.trans_base], [pass])
582DMR_TRANS_SERIES_CE([test_simple_7.xml], [s|i1!=1024], [test_simple_7.xml.f2.trans_base], [pass])
583DMR_TRANS_SERIES_CE([test_simple_7.xml], [s|i1<=1024], [test_simple_7.xml.f3.trans_base], [pass])
584DMR_TRANS_SERIES_CE([test_simple_7.xml], [s|i1<1024], [test_simple_7.xml.f4.trans_base], [pass])
585DMR_TRANS_SERIES_CE([test_simple_7.xml], [s|i1<=1024], [test_simple_7.xml.f5.trans_base], [pass])
586DMR_TRANS_SERIES_CE([test_simple_7.xml], [s|i1>1024], [test_simple_7.xml.f6.trans_base], [pass])
587DMR_TRANS_SERIES_CE([test_simple_7.xml], [s|i1>=1024], [test_simple_7.xml.f7.trans_base], [pass])
588
589DMR_TRANS_SERIES_CE([test_simple_7.xml], [s|1024<i1], [test_simple_7.xml.f8.trans_base], [pass])
590DMR_TRANS_SERIES_CE([test_simple_7.xml], [s|1024<=i1<=32768], [test_simple_7.xml.f9.trans_base], [pass])
591DMR_TRANS_SERIES_CE([test_simple_7.xml], [s|i1>=1024.0], [test_simple_7.xml.fa.trans_base], [pass])
592
593DMR_TRANS_SERIES_CE([test_simple_7.xml], [s|s==\"Silly test string: 2\"], [test_simple_7.xml.fs1.trans_base], [pass])
594DMR_TRANS_SERIES_CE([test_simple_7.xml], [s|s!=\"Silly test string: 2\"], [test_simple_7.xml.fs2.trans_base], [pass])
595DMR_TRANS_SERIES_CE([test_simple_7.xml], [s|s<\"Silly test string: 2\"], [test_simple_7.xml.fs3.trans_base], [pass])
596DMR_TRANS_SERIES_CE([test_simple_7.xml], [s|s<=\"Silly test string: 2\"], [test_simple_7.xml.fs4.trans_base], [pass])
597DMR_TRANS_SERIES_CE([test_simple_7.xml], [s|s>\"Silly test string: 2\"], [test_simple_7.xml.fs5.trans_base], [pass])
598DMR_TRANS_SERIES_CE([test_simple_7.xml], [s|s>=\"Silly test string: 2\"], [test_simple_7.xml.fs6.trans_base], [pass])
599DMR_TRANS_SERIES_CE([test_simple_7.xml], [s|s~=\".*2\"], [test_simple_7.xml.fs7.trans_base], [pass])
600
601# Test filtering a sequence that has only one field projected, including filtering on the values
602# of a filed not projected.
603DMR_TRANS_SERIES_CE([test_simple_7.xml], [s{i1}|i1<32768], [test_simple_7.xml.g1.trans_base], [pass])
604DMR_TRANS_SERIES_CE([test_simple_7.xml], [s{i1}|s<=\"Silly test string: 2\"], [test_simple_7.xml.g1.trans_base], [pass])
605
606# A nested sequence with flots in the outer sequence and the int, string combination in the inner
607DMR_TRANS_SERIES_CE([test_simple_8.1.xml], [outer], [test_simple_8.1.xml.f1.trans_base], [pass])
608DMR_TRANS_SERIES_CE([test_simple_8.1.xml], [outer{x;y}], [test_simple_8.1.xml.f2.trans_base], [pass])
609DMR_TRANS_SERIES_CE([test_simple_8.1.xml], [outer{x;y;inner}], [test_simple_8.1.xml.f3.trans_base], [pass])
610DMR_TRANS_SERIES_CE([test_simple_8.1.xml], [outer{x;y;inner|i1<1000}], [test_simple_8.1.xml.f4.trans_base], [pass])
611DMR_TRANS_SERIES_CE([test_simple_8.1.xml], [outer{x;y;inner|i1<1000}|x<0.0], [test_simple_8.1.xml.f5.trans_base], [pass])
612
613# These tests are regression tests for bug Hyrax-267. Spaces in variables names
614# broke the DAP4 CE parser
615
616# These mostly fail because thee's a second bug where the variables in a group are
617# not printing values.
618DMR_TRANS_SERIES_CE([names_with_spaces.dmr], [/u], [names_with_spaces.dmr.1.trans_base], [pass])
619DMR_TRANS_SERIES_CE([names_with_spaces.dmr], [/inst2/u], [names_with_spaces.dmr.2.trans_base], [xfail])
620DMR_TRANS_SERIES_CE([names_with_spaces.dmr], [/inst2/Point.x], [names_with_spaces.dmr.3.trans_base], [xfail])
621
622DMR_TRANS_SERIES_CE([names_with_spaces2.dmr], [/inst2/\"Point Break\".x], [names_with_spaces2.dmr.1.trans_base], [xfail])
623DMR_TRANS_SERIES_CE([names_with_spaces2.dmr], [/inst2/Point%20Break.x], [names_with_spaces2.dmr.1.trans_base], [xfail])
624DMR_TRANS_SERIES_CE([names_with_spaces2.dmr], [/inst2/\"Point%20Break\".x], [names_with_spaces2.dmr.1.trans_base], [xfail])
625
626DMR_TRANS_SERIES_CE([names_with_spaces3.dmr], [/inst2/\"New Group\"/x], [names_with_spaces3.dmr.1.trans_base], [xfail])
627DMR_TRANS_SERIES_CE([names_with_spaces3.dmr], [/inst2/New%20Group/x], [names_with_spaces3.dmr.1.trans_base], [xfail])
628
629# Test DAP CE parse errors - ensure they don't leak the supplied
630# CE text into the error message. jhrg 4/15/20
631DMR_PARSE_CE([test_simple_1.xml], [nasty], [test_simple_1.xml.parse_ce_1])
632# This string is 'd1rox<script>alert(1)</script>d55je=1' (%25 --> '%')
633# That is, the % is escaped in this text: %253c --> %3c --> '<'
634DMR_PARSE_CE([test_simple_1.xml], [d1rox%253cscript%253ealert%25281%2529%253c%252fscript%253ed55je=1],
635    [test_simple_1.xml.parse_ce_2])
636
637DMR_PARSE_CE([test_simple_6.3.xml], [s.nasty], [test_simple_6.3.xml.parse_ce_1])
638DMR_PARSE_CE([test_simple_6.3.xml], [s.d1rox%253cscript%253ealert%25281%2529%253c%252fscript%253ed55je=1],
639    [test_simple_6.3.xml.parse_ce_2])
640
641DMR_PARSE_CE([vol_1_ce_12.xml], [temp[[nasty]]], [vol_1_ce_12.xml.parse_ce_1])
642DMR_PARSE_CE([vol_1_ce_12.xml], [temp[[d1rox%253cscript%253ealert%25281%2529%253c%252fscript%253ed55je=1]]],
643    [vol_1_ce_12.xml.parse_ce_2])