-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestsuite.at
369 lines (354 loc) · 12.1 KB
/
testsuite.at
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
AT_INIT()
AT_COPYRIGHT([Copyright 2016-2019, Alistair Boyle, 3-clause BSD License])
AT_COLOR_TESTS
AT_TESTED(AT_PACKAGE_NAME)
m4_define(HOST_OS,m4_tolower(m4_esyscmd_s(uname -s | sed 's/_.*//')))
echo "[HOST_OS] = HOST_OS"
m4_case(HOST_OS,mingw64,[
m4_define(MINGW_CWD,m4_esyscmd_s(pwd -W | sed 's|\/|\\|g'))
echo "[MINGW_CWD] = MINGW_CWD"
])
m4_define(ZH_UNIT_TEST,[
AT_SETUP([$1 - $2])
AT_KEYWORDS([unittest $1])
AT_CHECK([$1 unittest],0,ignore,[[[ PASSED ] $3 test(s).
]])
AT_CLEANUP
])
m4_define(ZH_LIB_TEST,[
AT_SETUP([$1 - $2])
AT_KEYWORDS([libs $1])
AT_CHECK(lib[$1]_[$2],0,ignore)
AT_CLEANUP
])
m4_define(ZH_HELP_SHORT, [AT_PACKAGE_NAME @<:@options@:>@])
m4_define(ZH_HELP_LONG,
[ZH_HELP_SHORT
--help -h this help
--version -V version info
--forward-solver --fwd -f <fwd.zh>
simulate measurements for model in fwd.zh
--inverse-solver --inv -i <inv.zh>
solve for model parameters using model and data from inv.zh
--tolerance --tol -t <#.##e#>
for checking --fwd and --inv solutions when available
])
AT_BANNER([libs])
ZH_LIB_TEST(cblas,dgemm)
ZH_LIB_TEST(lapacke,dgels)
ZH_LIB_TEST(umfpack,solve)
ZH_LIB_TEST(cholmod,solve)
AT_BANNER([unit tests])
ZH_UNIT_TEST(file, zedhat file format I/O, 9)
ZH_UNIT_TEST(matrix, dense and sparse matrices, 15)
ZH_UNIT_TEST(model, system matrix calculator, 19)
ZH_UNIT_TEST(fwd, forward solver, 6)
ZH_UNIT_TEST(inv, inverse solver, 2)
AT_BANNER([args])
AT_SETUP([badargs])
AT_KEYWORDS([badargs args install])
AT_CHECK(AT_PACKAGE_NAME,1,ignore,ignore)
AT_CHECK(AT_PACKAGE_NAME asdf asdf,1,ignore,ignore)
AT_CHECK(AT_PACKAGE_NAME --unhandled-arg,1,ignore,ignore)
AT_CHECK(AT_PACKAGE_NAME asdf,1,ignore,ignore) dnl test: bad config file
AT_CLEANUP
AT_SETUP([--help])
AT_KEYWORDS([help args install])
AT_CHECK(AT_PACKAGE_NAME --help,0,ZH_HELP_LONG)
AT_CHECK(AT_PACKAGE_NAME -h,0,ZH_HELP_LONG)
AT_CHECK(AT_PACKAGE_NAME -?,1,ZH_HELP_LONG)
AT_CLEANUP
AT_SETUP(--version)
AT_KEYWORDS([version args install])
AT_CHECK(AT_PACKAGE_NAME --version,0,AT_PACKAGE_NAME[ ]AT_PACKAGE_VERSION[
])
AT_CHECK(AT_PACKAGE_NAME -V,0,AT_PACKAGE_NAME[ ]AT_PACKAGE_VERSION[
])
AT_CLEANUP
AT_SETUP(--tolerance)
AT_KEYWORDS([tolerance args install])
m4_define([ZH_TOLERANCE_ERR],m4_n(AT_PACKAGE_NAME[: option '--tolerance' requires an argument]))
m4_define([ZH_SHORT_TOLERANCE_ERR],m4_n(AT_PACKAGE_NAME[: option requires an argument -- 't']))
m4_case(HOST_OS,
darwin,[
m4_define([ZH_TOLERANCE_ERR],m4_n(AT_PACKAGE_NAME[: option `--tolerance' requires an argument]))
m4_define([ZH_SHORT_TOLERANCE_ERR],m4_n(AT_PACKAGE_NAME[: option requires an argument -- t]))
],
mingw64,[
m4_define([ZH_TOLERANCE_ERR],m4_n(MINGW_CWD[\]AT_PACKAGE_NAME[.exe: option requires an argument -- tolerance]))
m4_define([ZH_SHORT_TOLERANCE_ERR],m4_n(MINGW_CWD[\]AT_PACKAGE_NAME[.exe: option requires an argument -- t]))
])
AT_CHECK(AT_PACKAGE_NAME --tolerance,1,ZH_HELP_LONG,ZH_TOLERANCE_ERR)
AT_CHECK(AT_PACKAGE_NAME -t,1,ZH_HELP_LONG,ZH_SHORT_TOLERANCE_ERR)
AT_CHECK(AT_PACKAGE_NAME -t asdf,1,ZH_HELP_LONG,[error: --tolerance asdf: not a number
])
AT_CHECK(AT_PACKAGE_NAME -t -10,1,ZH_HELP_LONG,[error: --tolerance -10: must be non-negative
])
AT_CHECK(AT_PACKAGE_NAME -t 10,0,,)
AT_CHECK(AT_PACKAGE_NAME -t +10,0,,)
AT_CHECK(AT_PACKAGE_NAME -t 10e-100,0,,)
AT_CHECK(AT_PACKAGE_NAME -t 10e+100,0,,)
AT_CHECK(AT_PACKAGE_NAME -t 1.04e-100,0,,)
AT_CHECK(AT_PACKAGE_NAME -t 1.04e+100,0,,)
AT_CLEANUP
AT_SETUP(--forward-solver)
AT_KEYWORDS([fwd args install])
AT_DATA([m1f.zh],m4_include(tests/m1f.zh))
AT_DATA([m2f.zh],m4_include(tests/m2f.zh))
m4_define([ZH_FORWARD_ERR],m4_n(AT_PACKAGE_NAME[: option '--forward-solver' requires an argument]))
m4_define([ZH_FORWARD_SOLVER_ERR],ZH_FORWARD_ERR)
m4_define([ZH_MID_FORWARD_ERR],m4_n(AT_PACKAGE_NAME[: option '--fwd' requires an argument]))
m4_define([ZH_SHORT_FORWARD_ERR],m4_n(AT_PACKAGE_NAME[: option requires an argument -- 'f']))
m4_case(HOST_OS,darwin,[
m4_define([ZH_FORWARD_SOLVER_ERR],m4_n(AT_PACKAGE_NAME[: option `--forward-solver' requires an argument]))
m4_define([ZH_FORWARD_ERR],m4_n(AT_PACKAGE_NAME[: option `--forward' requires an argument]))
m4_define([ZH_MID_FORWARD_ERR],m4_n(AT_PACKAGE_NAME[: option `--fwd' requires an argument]))
m4_define([ZH_SHORT_FORWARD_ERR],m4_n(AT_PACKAGE_NAME[: option requires an argument -- f]))
],
mingw64,[
m4_define([ZH_FORWARD_SOLVER_ERR],m4_n(MINGW_CWD[\]AT_PACKAGE_NAME[.exe: option requires an argument -- forward-solver]))
m4_define([ZH_FORWARD_ERR],m4_n(MINGW_CWD[\]AT_PACKAGE_NAME[.exe: option requires an argument -- forward]))
m4_define([ZH_MID_FORWARD_ERR],m4_n(MINGW_CWD[\]AT_PACKAGE_NAME[.exe: option requires an argument -- fwd]))
m4_define([ZH_SHORT_FORWARD_ERR],m4_n(MINGW_CWD[\]AT_PACKAGE_NAME[.exe: option requires an argument -- f]))
])
AT_CHECK(AT_PACKAGE_NAME --forward-solver,1,ZH_HELP_LONG,ZH_FORWARD_SOLVER_ERR)
AT_CHECK(AT_PACKAGE_NAME --forward,1,ZH_HELP_LONG,ZH_FORWARD_ERR)
AT_CHECK(AT_PACKAGE_NAME --fwd,1,ZH_HELP_LONG,ZH_MID_FORWARD_ERR)
AT_CHECK(AT_PACKAGE_NAME -f,1,ZH_HELP_LONG,ZH_SHORT_FORWARD_ERR)
AT_CHECK(AT_PACKAGE_NAME -f balony,1,ignore,m4_n([error: read balony failed]))
AT_CHECK(AT_PACKAGE_NAME -f m1f.zh --tol 1e-16,1,ignore,
m4_n([fail: calculated measurements do not match expected]))
AT_CHECK(AT_PACKAGE_NAME -f m1f.zh --tol 1e-10,0,ignore,)
AT_CHECK(AT_PACKAGE_NAME -f m2f.zh --tol 1e-6,0,ignore,)
sed 's/^1 3 1 2 3/1 3 1 2 1/' m1f.zh > m1f-mutate.zh
AT_CHECK(AT_PACKAGE_NAME -f m1f-mutate.zh,1,ignore,m4_n([error: bad forward solve]))
sed '/^data/,/^$/d' m1f.zh > m1f-cropdata.zh
AT_CHECK(AT_PACKAGE_NAME -f m1f-cropdata.zh --tol 1e-13,0,ignore,)
sed '/^parameters/,/^#/d' m1f.zh > m1f-cropparams.zh
AT_CHECK(AT_PACKAGE_NAME -f m1f-cropparams.zh --tol 1e-13,1,ignore,m4_n([error: nothing to do]))
AT_CLEANUP
AT_SETUP(--inverse-solver)
AT_KEYWORDS([inv args install])
AT_DATA([m1i.zh],m4_include(tests/m1i.zh))
AT_DATA([m2i.zh],m4_include(tests/m2i.zh))
m4_define([ZH_INVERSE_ERR],m4_n(AT_PACKAGE_NAME[: option '--inverse-solver' requires an argument]))
m4_define([ZH_INVERSE_SOLVER_ERR],ZH_INVERSE_ERR)
m4_define([ZH_MID_INVERSE_ERR],m4_n(AT_PACKAGE_NAME[: option '--inv' requires an argument]))
m4_define([ZH_SHORT_INVERSE_ERR],m4_n(AT_PACKAGE_NAME[: option requires an argument -- 'i']))
m4_case(HOST_OS,
darwin,[
m4_define([ZH_INVERSE_SOLVER_ERR],m4_n(AT_PACKAGE_NAME[: option `--inverse-solver' requires an argument]))
m4_define([ZH_INVERSE_ERR],m4_n(AT_PACKAGE_NAME[: option `--inverse' requires an argument]))
m4_define([ZH_MID_INVERSE_ERR],m4_n(AT_PACKAGE_NAME[: option `--inv' requires an argument]))
m4_define([ZH_SHORT_INVERSE_ERR],m4_n(AT_PACKAGE_NAME[: option requires an argument -- i]))
],
mingw64,[
m4_define([ZH_INVERSE_SOLVER_ERR],m4_n(MINGW_CWD[\]AT_PACKAGE_NAME[.exe: option requires an argument -- inverse-solver]))
m4_define([ZH_INVERSE_ERR],m4_n(MINGW_CWD[\]AT_PACKAGE_NAME[.exe: option requires an argument -- inverse]))
m4_define([ZH_MID_INVERSE_ERR],m4_n(MINGW_CWD[\]AT_PACKAGE_NAME[.exe: option requires an argument -- inv]))
m4_define([ZH_SHORT_INVERSE_ERR],m4_n(MINGW_CWD[\]AT_PACKAGE_NAME[.exe: option requires an argument -- i]))
])
AT_CHECK(AT_PACKAGE_NAME --inverse-solver,1,ZH_HELP_LONG,ZH_INVERSE_SOLVER_ERR)
AT_CHECK(AT_PACKAGE_NAME --inverse,1,ZH_HELP_LONG,ZH_INVERSE_ERR)
AT_CHECK(AT_PACKAGE_NAME --inv,1,ZH_HELP_LONG,ZH_MID_INVERSE_ERR)
AT_CHECK(AT_PACKAGE_NAME -i,1,ZH_HELP_LONG,ZH_SHORT_INVERSE_ERR)
AT_CHECK(AT_PACKAGE_NAME -i balony,1,ignore,m4_n([error: read balony failed]))
AT_CHECK(AT_PACKAGE_NAME -i m1i.zh --tol 1e-16,1,ignore,
m4_n([fail: calculated parameters do not match expected]))
sed '/^parametermap/,/^256 64 /d' m1i.zh > m1ie.zh
sed '/^parameters/,/^# measurements/d' m1ie.zh > m1ie-noparams.zh
AT_CHECK(AT_PACKAGE_NAME -i m1ie-noparams.zh,0,ignore,)
AT_CHECK(AT_PACKAGE_NAME -i m1i.zh --tol 4e-6,0,ignore,)
AT_CHECK(AT_PACKAGE_NAME -i m2i.zh --tol 4e-6,0,ignore,)
sed 's/^1 3 1 2 3/1 3 1 2 1/' m1i.zh > m1i-mutate.zh
AT_CHECK(AT_PACKAGE_NAME -i m1i-mutate.zh,1,ignore,m4_n([error: bad inverse solve]))
sed '/^data/,/^$/d' m1i.zh > m1i-cropdata.zh
AT_CHECK(AT_PACKAGE_NAME -i m1i-cropdata.zh --tol 1e-13,1,ignore,m4_n([error: nothing to do]))
sed '/^parameters/,/^#/d' m1i.zh > m1i-cropparams.zh
AT_CHECK(AT_PACKAGE_NAME -i m1i-cropparams.zh --tol 1e-13,0,ignore,)
AT_CLEANUP
AT_BANNER([mesh loading])
AT_SETUP([netgen .vol])
AT_KEYWORDS([netgen])
AT_DATA([ngcube.vol],m4_include(tests/ngcube.vol))
gzip -k ngcube.vol
printf "gibberish file\r\nyup just junk some more" > junk1.not.vol
printf "mesh3d\r\nyup just junk some more" > junk2.not.vol
printf "mesh3d\ndimension\n1" > junk3.not.vol
printf "mesh3d\ngeomtype\n11" > junk4.not.vol
printf "mesh3d\ndimension\n2\nsurfaceelements\n5" > junk5.not.vol
printf "mesh3d\ndimension\n2\npoints\n5" > junk6.not.vol
printf "mesh3d\ndimension\n2\nvolumeelements\n5" > junk7.not.vol
printf "mesh3d\ndimension\n2\nvolumeelements\nXXX" > junk8.not.vol
printf "mesh3d\n\nsurfaceelements\n5" > junk5nd.not.vol
printf "mesh3d\n\npoints\n5" > junk6nd.not.vol
printf "mesh3d\n\nvolumeelements\n5" > junk7nd.not.vol
printf "mesh3d\n\nvolumeelements\nXXX" > junk8nd.not.vol
printf "mesh3d\ndimension\n3\ngeomtype\n0\nvolumeelements\n0\n" > junk9a.not.vol
printf "mesh3d\ndimension\n3\ngeomtype\n0\nsurfaceelements\n0\n" > junk9b.not.vol
printf "mesh3d\ndimension\n3\ngeomtype\n0\npoints\n0\n" > junk9c.not.vol
printf "asdf\n" > junk1.not.zh
printf "zedhat\nformat\n10\n" > junk2.not.zh
AT_CHECK([file ngcube.vol],0,
[reading ngcube.vol
mesh3d
dimension 3
geomtype 0
surfaceelements 12
volumeelements 6
points 8
],)
AT_CHECK([file ngcube.vol.gz],0,
[reading ngcube.vol.gz
mesh3d
dimension 3
geomtype 0
surfaceelements 12
volumeelements 6
points 8
],)
AT_CHECK([file nofile.vol],1,
[err: failed to open nofile.vol
],
[error: failed to load nofile.vol
])
AT_CHECK([file junk1.not.vol],1,
[reading junk1.not.vol
err: junk1.not.vol: missing header mesh3d
],
[error: failed to load junk1.not.vol
])
AT_CHECK([file junk2.not.vol],1,
[reading junk2.not.vol
mesh3d
err: junk2.not.vol: missing dimension
],
[error: failed to load junk2.not.vol
])
AT_CHECK([file junk3.not.vol],1,
[reading junk3.not.vol
mesh3d
dimension 1
err: bad dimension
],
[error: failed to load junk3.not.vol
])
AT_CHECK([file junk4.not.vol],1,
[reading junk4.not.vol
mesh3d
geomtype 11
err: bad geomtype
],
[error: failed to load junk4.not.vol
])
AT_CHECK([file junk5.not.vol],1,
[reading junk5.not.vol
mesh3d
dimension 2
surfaceelements 5
err: bad surfaceelements
],
[error: failed to load junk5.not.vol
])
AT_CHECK([file junk6.not.vol],1,
[reading junk6.not.vol
mesh3d
dimension 2
points 5
err: bad points
],
[error: failed to load junk6.not.vol
])
AT_CHECK([file junk7.not.vol],1,
[reading junk7.not.vol
mesh3d
dimension 2
volumeelements 5
err: bad volumeelements
],
[error: failed to load junk7.not.vol
])
AT_CHECK([file junk8.not.vol],1,
[reading junk8.not.vol
mesh3d
dimension 2
err: bad volumeelements
],
[error: failed to load junk8.not.vol
])
AT_CHECK([file junk5nd.not.vol],1,
[reading junk5nd.not.vol
mesh3d
surfaceelements 5
err: expect dimension before surfaceelements
],
[error: failed to load junk5nd.not.vol
])
AT_CHECK([file junk6nd.not.vol],1,
[reading junk6nd.not.vol
mesh3d
points 5
err: expect dimension before points
],
[error: failed to load junk6nd.not.vol
])
AT_CHECK([file junk7nd.not.vol],1,
[reading junk7nd.not.vol
mesh3d
volumeelements 5
err: expect dimension before volumeelements
],
[error: failed to load junk7nd.not.vol
])
AT_CHECK([file junk8nd.not.vol],1,
[reading junk8nd.not.vol
mesh3d
err: bad volumeelements
],
[error: failed to load junk8nd.not.vol
])
AT_CHECK([file junk9a.not.vol],1,
[reading junk9a.not.vol
mesh3d
dimension 3
geomtype 0
volumeelements 0
err: bad volumeelements
],
[error: failed to load junk9a.not.vol
])
AT_CHECK([file junk9b.not.vol],1,
[reading junk9b.not.vol
mesh3d
dimension 3
geomtype 0
surfaceelements 0
err: bad surfaceelements
],
[error: failed to load junk9b.not.vol
])
AT_CHECK([file junk9c.not.vol],1,
[reading junk9c.not.vol
mesh3d
dimension 3
geomtype 0
points 0
err: bad points
],
[error: failed to load junk9c.not.vol
])
AT_CHECK([file junk1.not.zh],1,
[reading junk1.not.zh
err: junk1.not.zh: missing header zedhat
],
[error: failed to load junk1.not.zh
])
AT_CHECK([file junk2.not.zh],1,
[reading junk2.not.zh
zedhat
format 10
err: bad format
],
[error: failed to load junk2.not.zh
])
AT_CLEANUP