diff --git a/test/3pdata/.gitignore b/test/3pdata/.gitignore new file mode 100644 index 00000000..f4213d5b --- /dev/null +++ b/test/3pdata/.gitignore @@ -0,0 +1,5 @@ +# Ignore everything without a dot. +# +# This ignores "pngsuite" but not "fetch-pngsuite.sh". +* +!*.* diff --git a/test/3pdata/README.md b/test/3pdata/README.md new file mode 100644 index 00000000..d7f5816c --- /dev/null +++ b/test/3pdata/README.md @@ -0,0 +1,5 @@ +This directory contains third party test data, not checked into the repository +directly for download size and copyright reasons. + +It also contains derived summary data files (such as `nia-checksums-of-*.txt`) +which *are* checked into the repository, for regression testing. diff --git a/test/3pdata/fetch-pngsuite.sh b/test/3pdata/fetch-pngsuite.sh new file mode 100755 index 00000000..c22e8fc5 --- /dev/null +++ b/test/3pdata/fetch-pngsuite.sh @@ -0,0 +1,26 @@ +#!/bin/bash -eu +# Copyright 2021 The Wuffs Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# ---------------- + +# This script fetches the PngSuite collection of PNG images. + +if [ ! -e ../../wuffs-root-directory.txt ]; then + echo "$0 should be run from the Wuffs test/3pdata directory." + exit 1 +fi + +mkdir -p pngsuite +curl --silent http://www.schaik.com/pngsuite/PngSuite-2017jul19.tgz | tar -xzf /dev/stdin -C pngsuite diff --git a/test/3pdata/nia-checksums-of-pngsuite.commentary.md b/test/3pdata/nia-checksums-of-pngsuite.commentary.md new file mode 100644 index 00000000..906a20e0 --- /dev/null +++ b/test/3pdata/nia-checksums-of-pngsuite.commentary.md @@ -0,0 +1,29 @@ +As per [the PngSuite page](http://www.schaik.com/pngsuite/#corrupted), every +`x*.png` file in the test suite is invalid PNG. + +Nonetheless, `nia-checksums-of-pngsuite.txt` contains an entry for +`xcsn0g01.png`, meaning that `convert-to-nia` decoded *some* pixels for it. +This is working as intended, because the `xcsn0g01.png` invalidity is in its +`IDAT` chunk's checksum (compared to `xhdn0g08.png`'s corruption in its `IHDR` +chunk's checksum). + +The `convert-to-nia` semantics are that, provided that it can decode a complete +image configuration (width, height, pixel format, etc which, for PNG, comes +from the `IHDR` chunk), it outputs *as many pixels as possible* (even if that's +zero pixels) so that it gives a 'best effort' decoding for truncated images. +Indeed, the NIA conversion for `xcsn0g01.png` holds all-zero pixels (and a +"png: bad checksum" error message on stderr) but also a zero exit code. + +``` +$ gen/bin/example-convert-to-nia < test/3pdata/pngsuite/xcsn0g01.png | hd +00000000 6e c3 af 41 ff 62 6e 34 20 00 00 00 20 00 00 00 |n..A.bn4 ... ...| +00000010 00 00 00 00 00 00 00 00 6e c3 af 45 ff 62 6e 34 |........n..E.bn4| +00000020 20 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 | ... ...........| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +* +00001020 00 00 00 00 00 00 00 00 |........| +00001028 +png: bad checksum +$ echo $? +0 +``` diff --git a/test/3pdata/nia-checksums-of-pngsuite.txt b/test/3pdata/nia-checksums-of-pngsuite.txt new file mode 100644 index 00000000..f8c7184e --- /dev/null +++ b/test/3pdata/nia-checksums-of-pngsuite.txt @@ -0,0 +1,162 @@ +# Generated by script/print-nia-checksums.sh +aac44167 test/3pdata/pngsuite/PngSuite.png +926d3aa2 test/3pdata/pngsuite/basi0g01.png +8f50bdc6 test/3pdata/pngsuite/basi0g02.png +6d612626 test/3pdata/pngsuite/basi0g04.png +024cf410 test/3pdata/pngsuite/basi0g08.png +5a525ac0 test/3pdata/pngsuite/basi0g16.png +d1ae61d3 test/3pdata/pngsuite/basi2c08.png +84bc9be8 test/3pdata/pngsuite/basi2c16.png +49bc6b98 test/3pdata/pngsuite/basi3p01.png +ad12897b test/3pdata/pngsuite/basi3p02.png +81c22b59 test/3pdata/pngsuite/basi3p04.png +e59ecea5 test/3pdata/pngsuite/basi3p08.png +6be1b716 test/3pdata/pngsuite/basi4a08.png +05ac622b test/3pdata/pngsuite/basi4a16.png +3c337968 test/3pdata/pngsuite/basi6a08.png +04188ea5 test/3pdata/pngsuite/basi6a16.png +926d3aa2 test/3pdata/pngsuite/basn0g01.png +8f50bdc6 test/3pdata/pngsuite/basn0g02.png +6d612626 test/3pdata/pngsuite/basn0g04.png +024cf410 test/3pdata/pngsuite/basn0g08.png +bb956205 test/3pdata/pngsuite/basn0g16.png +d1ae61d3 test/3pdata/pngsuite/basn2c08.png +84bc9be8 test/3pdata/pngsuite/basn2c16.png +49bc6b98 test/3pdata/pngsuite/basn3p01.png +ad12897b test/3pdata/pngsuite/basn3p02.png +81c22b59 test/3pdata/pngsuite/basn3p04.png +e59ecea5 test/3pdata/pngsuite/basn3p08.png +6be1b716 test/3pdata/pngsuite/basn4a08.png +05ac622b test/3pdata/pngsuite/basn4a16.png +3c337968 test/3pdata/pngsuite/basn6a08.png +04188ea5 test/3pdata/pngsuite/basn6a16.png +6be1b716 test/3pdata/pngsuite/bgai4a08.png +05ac622b test/3pdata/pngsuite/bgai4a16.png +3c337968 test/3pdata/pngsuite/bgan6a08.png +04188ea5 test/3pdata/pngsuite/bgan6a16.png +6be1b716 test/3pdata/pngsuite/bgbn4a08.png +05ac622b test/3pdata/pngsuite/bggn4a16.png +3c337968 test/3pdata/pngsuite/bgwn6a08.png +04188ea5 test/3pdata/pngsuite/bgyn6a16.png +b58985e2 test/3pdata/pngsuite/ccwn2c08.png +b7f7127d test/3pdata/pngsuite/ccwn3p08.png +c7b4c0fa test/3pdata/pngsuite/cdfn2c08.png +dabf7a40 test/3pdata/pngsuite/cdhn2c08.png +8491ddf5 test/3pdata/pngsuite/cdsn2c08.png +d9282a90 test/3pdata/pngsuite/cdun2c08.png +81c22b59 test/3pdata/pngsuite/ch1n3p04.png +e59ecea5 test/3pdata/pngsuite/ch2n3p08.png +b3334ede test/3pdata/pngsuite/cm0n0g04.png +b3334ede test/3pdata/pngsuite/cm7n0g04.png +b3334ede test/3pdata/pngsuite/cm9n0g04.png +8ce6e28c test/3pdata/pngsuite/cs3n2c16.png +d565507c test/3pdata/pngsuite/cs3n3p08.png +2f5a21b9 test/3pdata/pngsuite/cs5n2c08.png +2f5a21b9 test/3pdata/pngsuite/cs5n3p08.png +8ce6e28c test/3pdata/pngsuite/cs8n2c08.png +8ce6e28c test/3pdata/pngsuite/cs8n3p08.png +b3334ede test/3pdata/pngsuite/ct0n0g04.png +b3334ede test/3pdata/pngsuite/ct1n0g04.png +1bfcb6e6 test/3pdata/pngsuite/cten0g04.png +8e493daf test/3pdata/pngsuite/ctfn0g04.png +417a539e test/3pdata/pngsuite/ctgn0g04.png +28033324 test/3pdata/pngsuite/cthn0g04.png +71a82501 test/3pdata/pngsuite/ctjn0g04.png +b3334ede test/3pdata/pngsuite/ctzn0g04.png +aa5328d3 test/3pdata/pngsuite/exif2c08.png +b81f03cc test/3pdata/pngsuite/f00n0g08.png +4a12368c test/3pdata/pngsuite/f00n2c08.png +7fe4a9d8 test/3pdata/pngsuite/f01n0g08.png +36758edc test/3pdata/pngsuite/f01n2c08.png +e0ab5774 test/3pdata/pngsuite/f02n0g08.png +5e613513 test/3pdata/pngsuite/f02n2c08.png +0719e3fa test/3pdata/pngsuite/f03n0g08.png +c4709cc1 test/3pdata/pngsuite/f03n2c08.png +457f1dab test/3pdata/pngsuite/f04n0g08.png +7ec3c986 test/3pdata/pngsuite/f04n2c08.png +1f319e46 test/3pdata/pngsuite/f99n0g04.png +6000bb5b test/3pdata/pngsuite/g03n0g16.png +aa019a24 test/3pdata/pngsuite/g03n2c08.png +8f0a3383 test/3pdata/pngsuite/g03n3p04.png +f3a44153 test/3pdata/pngsuite/g04n0g16.png +3e852c56 test/3pdata/pngsuite/g04n2c08.png +edb3555b test/3pdata/pngsuite/g04n3p04.png +6b105de1 test/3pdata/pngsuite/g05n0g16.png +938803a0 test/3pdata/pngsuite/g05n2c08.png +9f7ad612 test/3pdata/pngsuite/g05n3p04.png +28816978 test/3pdata/pngsuite/g07n0g16.png +fedb8920 test/3pdata/pngsuite/g07n2c08.png +9373010e test/3pdata/pngsuite/g07n3p04.png +58eb5aca test/3pdata/pngsuite/g10n0g16.png +8c5550d0 test/3pdata/pngsuite/g10n2c08.png +a6120550 test/3pdata/pngsuite/g10n3p04.png +14cc7e1c test/3pdata/pngsuite/g25n0g16.png +fd0f349f test/3pdata/pngsuite/g25n2c08.png +eb13812a test/3pdata/pngsuite/g25n3p04.png +bb956205 test/3pdata/pngsuite/oi1n0g16.png +84bc9be8 test/3pdata/pngsuite/oi1n2c16.png +bb956205 test/3pdata/pngsuite/oi2n0g16.png +84bc9be8 test/3pdata/pngsuite/oi2n2c16.png +bb956205 test/3pdata/pngsuite/oi4n0g16.png +84bc9be8 test/3pdata/pngsuite/oi4n2c16.png +bb956205 test/3pdata/pngsuite/oi9n0g16.png +84bc9be8 test/3pdata/pngsuite/oi9n2c16.png +024cf410 test/3pdata/pngsuite/ps1n0g08.png +84bc9be8 test/3pdata/pngsuite/ps1n2c16.png +024cf410 test/3pdata/pngsuite/ps2n0g08.png +84bc9be8 test/3pdata/pngsuite/ps2n2c16.png +7cf2b7b2 test/3pdata/pngsuite/s01i3p01.png +7cf2b7b2 test/3pdata/pngsuite/s01n3p01.png +ffa30c78 test/3pdata/pngsuite/s02i3p01.png +ffa30c78 test/3pdata/pngsuite/s02n3p01.png +ad298c62 test/3pdata/pngsuite/s03i3p01.png +ad298c62 test/3pdata/pngsuite/s03n3p01.png +2c30132c test/3pdata/pngsuite/s04i3p01.png +2c30132c test/3pdata/pngsuite/s04n3p01.png +5fb20358 test/3pdata/pngsuite/s05i3p02.png +5fb20358 test/3pdata/pngsuite/s05n3p02.png +4b1198df test/3pdata/pngsuite/s06i3p02.png +764e90bd test/3pdata/pngsuite/s06n3p02.png +9eebca92 test/3pdata/pngsuite/s07i3p02.png +9eebca92 test/3pdata/pngsuite/s07n3p02.png +222e5ceb test/3pdata/pngsuite/s08i3p02.png +d57f2e84 test/3pdata/pngsuite/s08n3p02.png +7585127f test/3pdata/pngsuite/s09i3p02.png +7585127f test/3pdata/pngsuite/s09n3p02.png +034051a8 test/3pdata/pngsuite/s32i3p04.png +034051a8 test/3pdata/pngsuite/s32n3p04.png +a377dcdd test/3pdata/pngsuite/s33i3p04.png +a377dcdd test/3pdata/pngsuite/s33n3p04.png +88952d26 test/3pdata/pngsuite/s34i3p04.png +5bcd998d test/3pdata/pngsuite/s34n3p04.png +1cefbbe2 test/3pdata/pngsuite/s35i3p04.png +1cefbbe2 test/3pdata/pngsuite/s35n3p04.png +97c763a3 test/3pdata/pngsuite/s36i3p04.png +97c763a3 test/3pdata/pngsuite/s36n3p04.png +2d6bd687 test/3pdata/pngsuite/s37i3p04.png +2d6bd687 test/3pdata/pngsuite/s37n3p04.png +169951e5 test/3pdata/pngsuite/s38i3p04.png +169951e5 test/3pdata/pngsuite/s38n3p04.png +17a92eb2 test/3pdata/pngsuite/s39i3p04.png +17a92eb2 test/3pdata/pngsuite/s39n3p04.png +8cc6b93d test/3pdata/pngsuite/s40i3p04.png +8cc6b93d test/3pdata/pngsuite/s40n3p04.png +4e406947 test/3pdata/pngsuite/tbbn0g04.png +c6e83019 test/3pdata/pngsuite/tbbn2c16.png +ea7d20e2 test/3pdata/pngsuite/tbbn3p08.png +c6e83019 test/3pdata/pngsuite/tbgn2c16.png +ea7d20e2 test/3pdata/pngsuite/tbgn3p08.png +c6e83019 test/3pdata/pngsuite/tbrn2c08.png +2289ed1e test/3pdata/pngsuite/tbwn0g16.png +ea7d20e2 test/3pdata/pngsuite/tbwn3p08.png +ea7d20e2 test/3pdata/pngsuite/tbyn3p08.png +9b9384c7 test/3pdata/pngsuite/tm3n3p02.png +f2457b64 test/3pdata/pngsuite/tp0n0g08.png +05846c5f test/3pdata/pngsuite/tp0n2c08.png +3d7708a8 test/3pdata/pngsuite/tp0n3p08.png +ea7d20e2 test/3pdata/pngsuite/tp1n3p08.png +f286cbfc test/3pdata/pngsuite/xcsn0g01.png +9098c4d8 test/3pdata/pngsuite/z00n2c08.png +9098c4d8 test/3pdata/pngsuite/z03n2c08.png +9098c4d8 test/3pdata/pngsuite/z06n2c08.png +9098c4d8 test/3pdata/pngsuite/z09n2c08.png