### -*-autotest-*- ### ### Test script for test machinery ### ### (c) 2023 Straylight/Edgeware ### ###----- Licensing notice --------------------------------------------------- ### ### This file is part of the mLib utilities library. ### ### mLib 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. ### ### mLib 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 mLib; if not, write to the Free ### Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, ### MA 02111-1307, USA. ###-------------------------------------------------------------------------- ### tvec dnl test_filter(CMD, SED, RC, STDOUT, STDERR) m4_define([test_filter], [ AT_CHECK([$1], [$3], [stdout-nolog], [stderr-nolog]) ##mv stdout rawout; mv stderr rawerr AT_CHECK([sed "AS_ESCAPE([$2])" stdout], [0], [$4]) AT_CHECK([sed "AS_ESCAPE([$2])" stderr], [0], [$5])]) dnl mismatch_filter m4_define([mismatch_filter], [s/\(@%:@<@<:@0-9a-zA-Z_-@:>@*\) @<:@^>@:>@*>/\1 ...>/g]) dnl test_parse(TY, IN, OUT) m4_define([test_parse], [ AT_DATA([tv], [;;; -*-conf-*- [[$1]] $1 = $2 @status = ? ]) test_filter([BUILDDIR/t/tvec.t -fh tv], [mismatch_filter], [1], [tv:3: `$1' FAILED actual status = `.' expected status = `?' matched $1 = $3 $1: 1/1 FAILED FAILED 1 out of 1 test in 1 out of 1 group ])]) dnl test_parserr(TY, IN, LNO, ERR) m4_define([test_parserr], [ AT_DATA([tv], [;;; -*-conf-*- [[$1]] $1 = $2 @status = ? ]) AT_CHECK([BUILDDIR/t/tvec.t -fh tv], [2], [], [tvec.t: tv:$3: $4 ])]) AT_SETUP(tvec type-int) test_parse([int], [4], [4 ; = 0x04]) test_parse([int], [ 17; comment], [17 ; = 0x11]) test_parserr([int], [17 : badness], [3], [syntax error: expected end-of-line but found `:']) test_parserr([int], [17: badness], [3], [syntax error: expected end-of-line but found `:']) test_parse([int], [0x234], [564 ; = 0x0234]) test_parse([int], [033], [27 ; = 0x1b]) test_parse([int], [ +192], [192 ; = 0xc0]) test_parse([int], [ -192], [-192 ; = -0xc0]) test_parserr([int], [xyzzy], [3], [syntax error: expected signed integer but found `x']) test_parserr([int], [-splat], [3], [syntax error: expected signed integer but found `s']) test_parserr([int], [0xq], [3], [syntax error: expected end-of-line but found `x']) test_parserr([int], [0x], [3], [syntax error: expected end-of-line but found `x']) test_parserr([int], [], [3], [syntax error: expected signed integer but found ]) test_parserr([int], [123456], [3], [integer 123456 out of range (must be in [[-32768 .. 32767]])]) AT_CLEANUP AT_SETUP(tvec type-uint) test_parse([uint], [4], [4 ; = 0x04]) test_parse([uint], [ 17; comment], [17 ; = 0x11]) test_parserr([uint], [17 : badness], [3], [syntax error: expected end-of-line but found `:']) test_parserr([uint], [17: badness], [3], [syntax error: expected end-of-line but found `:']) test_parse([uint], [0x234], [564 ; = 0x0234]) test_parse([uint], [033], [27 ; = 0x1b]) test_parserr([uint], [ +192], [3], [syntax error: expected unsigned integer but found `+']) test_parserr([uint], [ -192], [3], [syntax error: expected unsigned integer but found `-']) test_parserr([uint], [xyzzy], [3], [syntax error: expected unsigned integer but found `x']) test_parserr([uint], [0xq], [3], [syntax error: expected end-of-line but found `x']) test_parserr([uint], [0x], [3], [syntax error: expected end-of-line but found `x']) test_parserr([uint], [], [3], [syntax error: expected unsigned integer but found ]) test_parserr([uint], [123456], [3], [integer 123456 out of range (must be in [[0 .. 65535]])]) AT_CLEANUP AT_SETUP([tvec type-enum]) test_parse([ienum], [less], [less ; = -1 = -0x01]) test_parse([ienum], [+1], [greater ; = 1 = 0x01]) test_parse([ienum], [17], [17 ; = 0x11]) test_parse([uenum], [banana], [banana ; = 1 = 0x01]) test_parse([uenum], [clementine], [clementine ; = 2 = 0x02]) test_parse([uenum], [17], [17 ; = 0x11]) test_parse([penum], [carol], [carol ; = @%:@]) test_parse([penum], [alice], [alice ; = @%:@]) test_parse([penum], [@%:@nil], [@%:@nil]) AT_CLEANUP ###----- That's all, folks --------------------------------------------------