X-Git-Url: https://git.draconx.ca/gitweb/liblbx.git/blobdiff_plain/efc068f39f6811cdc0e004d2acf4ef08b2b71c3e..9969a6cd8e946ea3bbcd7f4b357b0e60fc02fe43:/tests/images.at diff --git a/tests/images.at b/tests/images.at new file mode 100644 index 0000000..f953d21 --- /dev/null +++ b/tests/images.at @@ -0,0 +1,131 @@ +# Copyright © 2013, 2021 Nick Bowler +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +AT_BANNER([Image format tests]) + +m4_divert_push([PREPARE_TESTS])dnl +# Read the header from a PAM image (from standard input) and set declared +# parameters in shell variables. For example, if the PAM header specifies +# DEPTH 2, the shell variable pam_DEPTH will be set to 2. +# +# Returns a nonzero status if the header could not be parsed. +pam_read_header () { + pam_save_IFS=$IFS + pam_p7_seen=false pam_endhdr_seen=false + + while IFS= read a; do + case $a in + P7) + $pam_p7_seen && break # duplicated header + pam_p7_seen=true + ;; + ENDHDR) + pam_endhdr_seen=true + break + ;; + *) + IFS=$pam_save_IFS read b c <