File: EXPRTest.at

package info (click to toggle)
libdap 3.20.11-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 24,568 kB
  • sloc: cpp: 50,809; sh: 41,536; xml: 23,511; ansic: 20,030; yacc: 2,508; exp: 1,544; makefile: 990; lex: 309; perl: 52; fortran: 8
file content (209 lines) | stat: -rw-r--r-- 9,530 bytes parent folder | download | duplicates (2)
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
# Process with autom4te to create an -*- Autotest -*- test suite.

AT_INIT([expr-test])
# AT_COPYRIGHT([])

# AT_TESTED([expr-test])

AT_ARG_OPTION_ARG([baselines],
    [--baselines=yes|no   Build the baseline file for parser test 'arg'],
    [echo "baselines set to $at_arg_baselines";
     baselines=$at_arg_baselines],[baselines=])

# Usage: _EXPR_TEST(<flags>, <dds>, <constraint>, <baseline file>, <xfail?>)

m4_define([_EXPR_TEST], [
    # AT_BANNER([Test $1 $2 $3])
    AT_SETUP([expr-test $1 $2 -k $3 ($5)])
    AT_KEYWORDS([expr])

    # Added || true because expr-test returns 0 (failure) for some of
    # these tests which is correct for the test - we expect some of
    # the input to trigger an error response from the parser, et
    # cetera. That's also why we capture both stdout and stderr -
    # successful runs are sent to stdout while the errors are sent to
    # stderr.

    AS_IF([test -n "$baselines" -a x$baselines = xyes],
        [
        AT_CHECK([$abs_builddir/expr-test $1 $2 -k $3 -f "dummy" || true], [0], [stdout], [stderr])
        AT_CHECK([mv stdout $4.tmp])
        ],
        [
        AT_CHECK([$abs_builddir/expr-test $1 $2 -k $3 -f "dummy" || true], [0], [stdout], [stderr])
        AT_CHECK([diff -b -B $4 stdout || diff -b -B $4 stderr], [0], [ignore])
        AT_XFAIL_IF([test "$5" = "xfail"])
        ])
    
    AT_CLEANUP
])

m4_define([EXPR_RESPONSE_P], [
    # AT_BANNER([EXPR response for $1, $2, $4.])
    # Test the serialize/deserialize methods
    _EXPR_TEST([-w], [$abs_srcdir/expr-testsuite/$1], [$2], [$abs_srcdir/expr-testsuite/$3.base], $4)
    # Test the intern_data method (which combines serialize and deserialze)
    _EXPR_TEST([-W], [$abs_srcdir/expr-testsuite/$1], [$2], [$abs_srcdir/expr-testsuite/$3.base], $4)
])

# The -b option to expr-test uses the 'series values' feature of the Test
# classes.
m4_define([EXPR_RESPONSE_B], [
    # AT_BANNER([EXPR response for $1, $2, $4.])
    _EXPR_TEST([-b -w], [$abs_srcdir/expr-testsuite/$1], [$2], [$abs_srcdir/expr-testsuite/$3.base], $4)
    _EXPR_TEST([-b -W], [$abs_srcdir/expr-testsuite/$1], [$2], [$abs_srcdir/expr-testsuite/$3.base], $4)
])

# Tests that capture/evaluate the error text from the parser. jhrg 4/15/20
#
# Usage: EXPR_RESPONSE_E(DDS, CE, BASELINE, [pass/xfail])
#
m4_define([EXPR_RESPONSE_E], [dnl
    AT_SETUP([Error: $1 $2 ($4)])
    AT_KEYWORDS([expr])

    AS_IF([test -z "$at_verbose"], [echo "COMMAND: expr-test -e -p expr-testsuite/$1 -k $2"])

    dds=$abs_srcdir/expr-testsuite/$1
    ce=$2

    AS_IF([test -n "$baselines" -a x$baselines = xyes],
        [
        AT_CHECK([$abs_builddir/expr-test -e -p $dds -k $ce], [0], [stdout], [stderr])
        AT_CHECK([mv stderr $abs_srcdir/expr-testsuite/$3.tmp])
        ],
        [
        AT_CHECK([$abs_builddir/expr-test -e -p $dds -k $ce], [0], [stdout], [stderr])
        AT_CHECK([diff -b -B $abs_srcdir/expr-testsuite/$3 stderr], [0])
        AT_XFAIL_IF([test z$4 = zxfail])
        ])

    AT_CLEANUP
])

EXPR_RESPONSE_P([test.1], [i], [test.1], [pass])
EXPR_RESPONSE_P([test.1], [i,j], [test.1a], [pass])
EXPR_RESPONSE_P([test.1], ['i,j&i=j'], [test.1b], [pass])
EXPR_RESPONSE_P([test.1], ['i&i=j'], [test.1d], [pass])
EXPR_RESPONSE_P([test.2], [s1], [test.2], [pass])
EXPR_RESPONSE_P([test.2], [s2], [test.2a], [pass])
EXPR_RESPONSE_P([test.2], [s2,s3], [test.2b], [pass])
EXPR_RESPONSE_P([test.2], [s2[[2:2:4]],s3.o], [test.2c], [pass])

EXPR_RESPONSE_P([test.2], [s2[[2:2:4]].m], [test.2d], [pass])
EXPR_RESPONSE_P([test.2], [s2[[2:2:4]].m,s2[[2:2:4]].l], [test.2e], [pass])

EXPR_RESPONSE_P([test.2a], [s2[[2:4]].m[[0:4]],s2[[2:4]].l[[0:5]]], [test.2f], [pass])
EXPR_RESPONSE_P([test.3], [i[[1:10]]], [test.3], [pass])

dnl Test the new code to limit reversed index values. 10:10 should pass. jhrg 2/3/11
EXPR_RESPONSE_P([test.3], [i[[10:10]]], [test.3a], [pass])

EXPR_RESPONSE_P([test.4], ['s&s=~"^Silly.*"'], [test.4], [pass])

dnl In changing the TestStr class so that it writes a constant value (Silly ...: 1)
dnl I had to hack this test to use the -b option to expr-test. EXPR_RESPONSE_P uses
dnl only the -w/-W options, so I dropped using that macro kluge and went right for the
dnl actual test macro. 12/2/13/ jhrg
dnl
dnl EXPR_RESPONSE_P([test.e], ['names.s&names.s=~".*: 3"'], [test.ea], [pass])
    
_EXPR_TEST([-b -w], [$abs_srcdir/expr-testsuite/test.e], ['names.s&names.s=~".*: 3"'], 
    [$abs_srcdir/expr-testsuite/test.ea.base], [pass])
    
_EXPR_TEST([-b -W], [$abs_srcdir/expr-testsuite/test.e], ['names.s&names.s=~".*: 3"'], 
    [$abs_srcdir/expr-testsuite/test.ea.base], [pass])

dnl since 'Silly ...:5' will never be produced, this tests what happens when the sequence
dnl does not contain the value. Note that this test does not have to be rewritten because
dnl of the change to the TestStr code. 12/2/13 jhrg
EXPR_RESPONSE_P([test.e], ['names.s&names.s=~".*: 5"'], [test.eb], [pass])

EXPR_RESPONSE_P([test.5], [g[[0:2:4]][[0]][[0]]], [test.5], [pass])
EXPR_RESPONSE_P([test.5], [g[[0:2:4]][[0:2:4]][[0:2:4]]], [test.5a], [pass])
EXPR_RESPONSE_P([test.6], [i], [test.6], [pass])
EXPR_RESPONSE_P([test.6], [i[[1:2]][[2:4]]], [test.6a], [pass])
dnl Added test of '*' DAP2 syntax. jhrg 2/4/22
EXPR_RESPONSE_P([test.6], [i[[1:2]][[*]]], [test.6b], [pass])

EXPR_RESPONSE_P([test.5], [g.val[[0:1]][[0:1]][[0:1]]], [test.5b], [pass])
EXPR_RESPONSE_P([test.5], [g.length], [test.5c], [pass])
EXPR_RESPONSE_P([test.5], [g.length,g.width], [test.5d], [pass])
EXPR_RESPONSE_P([test.2], [j,o], [test.2g], [pass])
EXPR_RESPONSE_P([test.8], ["data%23i[[0:2:9]][[0:2]]"], [test.8], [pass])
EXPR_RESPONSE_P([test.7], [x,y,f], [test.7], [pass])
EXPR_RESPONSE_P([test.8], ["x%23y,y"], [test.8a], [pass])
EXPR_RESPONSE_P([test.8], ["data%20name,y"], [test.8b], [pass])
EXPR_RESPONSE_P([test.9], ["Data-Set-2.fakeDim0[[0:3]],Data-Set-2.fakeDim1[[0:3]]"], [test.9], [pass])
EXPR_RESPONSE_P([test.5], [g[[1:4:9]]], [test.5e], [pass])
EXPR_RESPONSE_P([test.6], [i[[1:4:9]]], [test.6c], [pass])

# New tests for server functions that take arrays and include array projections
# Added 10/23/13 jhrg
EXPR_RESPONSE_P([test.6], [scale\(i,2\)], [test.6.func1], [pass])
EXPR_RESPONSE_P([test.6], [scale\(i[[2:4]][[3:6]],2\)], [test.6.func2], [pass])

EXPR_RESPONSE_P([test.5], [scale\(i[[3]],2\)], [test.5.func3], [pass])
# This doesn't work yet 10/23/13 jhrg 
EXPR_RESPONSE_P([test.5], [scale\(j,2\)], [test.5.func4], [pass])

EXPR_RESPONSE_P([test.a], ["" -b], [test.a], [pass])
EXPR_RESPONSE_P([test.a], ["&i<2000" -b], [test.aa], [pass])
EXPR_RESPONSE_P([test.a], ["j&i>2000" -b], [test.ab], [pass])
EXPR_RESPONSE_P([test.a], ["i,j&i<0" -b], [test.ac], [pass])
dnl Added 2/3/22 jhrg
EXPR_RESPONSE_P([test.a], [[s[0:3]] -b], [test.ad], [pass])
EXPR_RESPONSE_P([test.b], ["" -b], [test.b], [pass])
EXPR_RESPONSE_P([test.b], ["i,f" -b], [test.ba], [pass])
EXPR_RESPONSE_P([test.b], ["i,f&i<2000" -b], [test.bb], [pass])
EXPR_RESPONSE_P([test.b], ["i,f&f<0" -b], [test.bc], [pass])
EXPR_RESPONSE_P([test.b], ["i,j&i<2000" -b], [test.bd], [pass])
EXPR_RESPONSE_P([test.b], ["&i<0" -b], [test.be], [pass])
EXPR_RESPONSE_P([test.d], ["" -b], [test.d], [pass])
EXPR_RESPONSE_P([test.d], ["i,f,a" -b], [test.da], [pass])
EXPR_RESPONSE_P([test.d], ["i,f,a&i<2000" -b], [test.db], [pass])
EXPR_RESPONSE_P([test.d], ["i,f,a&f<0" -b], [test.dc], [pass])
EXPR_RESPONSE_P([test.d], ["i,f,a&a<10" -b], [test.dd], [pass])
EXPR_RESPONSE_P([test.d], ["i,f&i<2000" -b], [test.de], [pass])
EXPR_RESPONSE_P([test.d], ["i&i<2000" -b], [test.df], [pass])
EXPR_RESPONSE_P([test.d], ["i,f,a&i<0" -b], [test.dg], [pass])

EXPR_RESPONSE_B([test.61], [i], [data.61a], [pass])
EXPR_RESPONSE_B([test.61], [ i[[0:2]][[0:2]] ], [data.61b], [pass])
EXPR_RESPONSE_B([test.61], [ i[[1:2]][[0:2]] ], [data.61c], [pass])
EXPR_RESPONSE_B([test.61], [ i[[1:2]][[1:2]] ], [data.61d], [pass])
EXPR_RESPONSE_B([test.c0], [SST], [data.z1], [pass])

EXPR_RESPONSE_B([test.f], [""], [test.fa], [pass])
EXPR_RESPONSE_B([test.f], ["&i<3000"], [test.fb], [pass])

# tests for zero-length arrays. jhrg 1/28/16

EXPR_RESPONSE_B([test.21.dds], [""], [data.21], [pass])
EXPR_RESPONSE_B([test.22.dds], [""], [data.22], [pass])
EXPR_RESPONSE_B([test.23.dds], [""], [data.23], [pass])
EXPR_RESPONSE_B([test.24.dds], [""], [data.24], [pass])

# Empty Structures. jhrg 1/29/16

EXPR_RESPONSE_B([test.25.dds], [""], [data.25], [pass])
EXPR_RESPONSE_B([test.26.dds], [""], [data.26], [pass])

# Test error responses. None of the parsers should allow any part of
# the malformed CE into the error messages. jhrg 4/15/20

EXPR_RESPONSE_E([test.1], [d1rox%253cscript%253ealert%25281%2529%253c%252fscript%253ed55je=1], [test.1.error], [pass])
EXPR_RESPONSE_E([test.2], [d1rox%253cscript%253ealert%25281%2529%253c%252fscript%253ed55je=1], [test.2.error], [pass])
EXPR_RESPONSE_E([test.3], [d1rox%253cscript%253ealert%25281%2529%253c%252fscript%253ed55je=1], [test.3.error], [pass])
EXPR_RESPONSE_E([test.5], [d1rox%253cscript%253ealert%25281%2529%253c%252fscript%253ed55je=1], [test.5.error], [pass])

dnl Test errant array and grid index values (stop < start).
dnl These tests should show the parser returning an error message. jhrg 2/3/22

EXPR_RESPONSE_E([test.3], [i[[10:9]]], [test.3b.error], [pass])
EXPR_RESPONSE_E([test.3], [i[[4:1]]], [test.3c.error], [pass])

EXPR_RESPONSE_E([test.5], [g[[2:2:1]][[0]][[0]]], [test.5a.error], [pass])
EXPR_RESPONSE_E([test.5], [g[[2:4]][[0]][[1:0]]], [test.5b.error], [pass])

EXPR_RESPONSE_P([test.a], [[s[3:0]] -b], [test.a.error], [pass])