From 8e1fbe44dde847482ecdf54f97d31a5322a2fd92 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Fri, 31 Jan 2014 00:01:40 -0500 Subject: [PATCH] tests: Add test for truncated archives. If a real EOF is encountered while reading an archive member this will not be properly reported as a read error. So we'll never notice if extracted files are missing a chunk because the archive is truncated. Add a test which exposes this behaviour. --- Makefile.am | 6 +++--- tests/broken-archives.tap | 27 +++++++++++++++++++++++++++ tests/testdata/arch-trunc.lbx | Bin 0 -> 16 bytes 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 tests/broken-archives.tap create mode 100644 tests/testdata/arch-trunc.lbx diff --git a/Makefile.am b/Makefile.am index cd7d373..5d40a75 100644 --- a/Makefile.am +++ b/Makefile.am @@ -55,9 +55,9 @@ TAP_LOG_COMPILER = $(SHELL) TAP_LOG_DRIVER = AM_TAP_AWK='$(AWK)' \ $(SHELL) $(srcdir)/tests/util/tap-driver.sh -TESTS = tests/empty-image.tap tests/pam-formats.tap tests/moo2-mainmenu.tap \ - tests/moo2-logo.tap tests/moo2-starbg.tap tests/moo2-ships.tap \ - tests/moo2-monster.tap +TESTS = tests/broken-archives.tap tests/empty-image.tap tests/pam-formats.tap \ + tests/moo2-mainmenu.tap tests/moo2-logo.tap tests/moo2-starbg.tap \ + tests/moo2-ships.tap tests/moo2-monster.tap mostlyclean-local: clean-testdirs clean-testdirs: diff --git a/tests/broken-archives.tap b/tests/broken-archives.tap new file mode 100644 index 0000000..3997ca3 --- /dev/null +++ b/tests/broken-archives.tap @@ -0,0 +1,27 @@ +#!/bin/sh +# +# 2ooM: The Master of Orion II Reverse Engineering Project +# Test that EOF when unpacking an archive is an error. +# Copyright © 2014 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 . + +. "$srcdir/tests/util/test-init.sh" || exit 99 + +plan_ 1 +dx_create_testdir + +failed=false +$LBXTOOL -xf "$testdata/arch-trunc.lbx" || failed=true +command_ok_ "EOF handled in archive" -D TODO $failed diff --git a/tests/testdata/arch-trunc.lbx b/tests/testdata/arch-trunc.lbx new file mode 100644 index 0000000000000000000000000000000000000000..8307f438bf2dc646e6d360f099858e8b0474c0de GIT binary patch literal 16 QcmZQ%So@Cw3jPCW02+7#tN;K2 literal 0 HcmV?d00001 -- 2.43.0