Update vendor/libarchive to git 629358182b04d7de2316bbd29708c58ddf797fd2

Libarchive 3.2.2
This commit is contained in:
Martin Matuska 2016-10-24 13:51:45 +00:00
parent 62583e4b79
commit 930550a55e
26 changed files with 490 additions and 63 deletions

View File

@ -1,20 +1,13 @@
language: C
sudo: true
sudo: required
dist: trusty
compiler:
- gcc
- clang
before_install:
- sudo add-apt-repository ppa:kubuntu-ppa/backports -y
- sudo apt-get update -qq
env:
- BUILD_SYSTEM=cmake
- BUILD_SYSTEM=autotools
install:
- sudo apt-get install -y cmake=2.8.12.2-0ubuntu1~ubuntu12.04.1~ppa2
- sudo apt-get install -y libbz2-dev libzip-dev liblzma-dev
before_script:
- BUILD_DIR=`pwd`/BUILD
- mkdir -p ${BUILD_DIR}
- cd ${BUILD_DIR}
- cmake ..
script:
- cd ${BUILD_DIR}
- make
- make test
- build/ci_build.sh

View File

@ -23,7 +23,7 @@ TESTS_ENVIRONMENT= $(libarchive_TESTS_ENVIRONMENT) $(bsdtar_TESTS_ENVIRONMENT) $
DISTCHECK_CONFIGURE_FLAGS = --enable-bsdtar --enable-bsdcpio
# The next line is commented out by default in shipping libarchive releases.
# It is uncommented by default in trunk.
DEV_CFLAGS=-Werror -Wextra -Wunused -Wshadow -Wmissing-prototypes -Wcast-qual -g
# DEV_CFLAGS=-Werror -Wextra -Wunused -Wshadow -Wmissing-prototypes -Wcast-qual -g
AM_CFLAGS=$(DEV_CFLAGS)
PLATFORMCPPFLAGS = @PLATFORMCPPFLAGS@
AM_CPPFLAGS=$(PLATFORMCPPFLAGS)
@ -662,6 +662,7 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_read_filter_lrzip.tar.lrz.uu \
libarchive/test/test_read_filter_lzop.tar.lzo.uu \
libarchive/test/test_read_filter_lzop_multiple_parts.tar.lzo.uu \
libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu \
libarchive/test/test_read_format_7zip_bcj2_bzip2.7z.uu \
libarchive/test/test_read_format_7zip_bcj2_copy_1.7z.uu \
libarchive/test/test_read_format_7zip_bcj2_copy_2.7z.uu \
@ -787,6 +788,7 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_read_format_zip_filename_utf8_jp.zip.uu \
libarchive/test/test_read_format_zip_filename_utf8_ru.zip.uu \
libarchive/test/test_read_format_zip_filename_utf8_ru2.zip.uu \
libarchive/test/test_read_format_zip_high_compression.zip.uu \
libarchive/test/test_read_format_zip_length_at_end.zip.uu \
libarchive/test/test_read_format_zip_mac_metadata.zip.uu \
libarchive/test/test_read_format_zip_malformed1.zip.uu \

3
NEWS
View File

@ -1,3 +1,6 @@
Oct 23, 2016: libarchive 3.2.2 released
Security release
Jun 20, 2016: libarchive 3.2.1 released
This fixes a handful of security and other critical issues with 3.2.0

103
build/ci_build.sh Executable file
View File

@ -0,0 +1,103 @@
#!/bin/sh
#
# Automated build and test of libarchive on CI systems
#
# Variables that can be passed via environment:
# BUILD_SYSTEM=
# BUILDDIR=
# SRCDIR=
# CONFIGURE_ARGS=
# MAKE_ARGS=
#
ACTIONS=
BUILD_SYSTEM="${BUILD_SYSTEM:-autotools}"
CURDIR=`pwd`
SRCDIR="${SRCDIR:-`pwd`}"
RET=0
usage () {
echo "Usage: $0 [-b autotools|cmake] [-a autogen|configure|build|test ] [ -a ... ] [ -d builddir ] [-s srcdir ]"
}
inputerror () {
echo $1
usage
exit 1
}
while getopts a:b:d:s: opt; do
case ${opt} in
a)
case "${OPTARG}" in
autogen) ;;
configure) ;;
build) ;;
test) ;;
*) inputerror "Invalid action (-a)" ;;
esac
ACTIONS="${ACTIONS} ${OPTARG}"
;;
b) BUILD_SYSTEM="${OPTARG}"
case "${BUILD_SYSTEM}" in
autotools) ;;
cmake) ;;
*) inputerror "Invalid build system (-b)" ;;
esac
;;
d)
BUILDDIR="${OPTARG}"
;;
s)
SRCDIR="${OPTARG}"
if [ ! -f "${SRCDIR}/build/version" ]; then
inputerror "Missing file: ${SRCDIR}/build/version"
fi
;;
esac
done
if [ -z "${ACTIONS}" ]; then
ACTIONS="autogen configure build test"
fi
if [ -z "${BUILD_SYSTEM}" ]; then
inputerror "Missing type (-t) parameter"
fi
if [ -z "${BUILDDIR}" ]; then
BUILDDIR="${CURDIR}/BUILD/${BUILD_SYSTEM}"
fi
mkdir -p "${BUILDDIR}"
for action in ${ACTIONS}; do
cd "${BUILDDIR}"
case "${action}" in
autogen)
case "${BUILD_SYSTEM}" in
autotools)
cd "${SRCDIR}"
sh build/autogen.sh
RET="$?"
;;
esac
;;
configure)
case "${BUILD_SYSTEM}" in
autotools) "${SRCDIR}/configure" ${CONFIGURE_ARGS} ;;
cmake) cmake ${CONFIGURE_ARGS} "${SRCDIR}" ;;
esac
RET="$?"
;;
build)
make ${MAKE_ARGS}
RET="$?"
;;
test)
case "${BUILD_SYSTEM}" in
autotools) make ${MAKE_ARGS} check ;;
cmake) make ${MAKE_ARGS} test ;;
esac
RET="$?"
;;
esac
if [ "${RET}" != "0" ]; then
exit "${RET}"
fi
cd "${CURDIR}"
done
exit "${RET}"

View File

@ -1 +1 @@
3002001
3002002

View File

@ -58,7 +58,8 @@ IF(ENABLE_CAT AND ENABLE_TEST)
# Experimental new test handling
ADD_CUSTOM_TARGET(run_bsdcat_test
COMMAND bsdcat_test -p $<TARGET_FILE:bsdcat>
-r ${CMAKE_CURRENT_SOURCE_DIR})
-r ${CMAKE_CURRENT_SOURCE_DIR}
-vv)
ADD_DEPENDENCIES(run_bsdcat_test bsdcat)
ADD_DEPENDENCIES(run_all_tests run_bsdcat_test)

View File

@ -129,6 +129,13 @@
# include <crtdbg.h>
#endif
mode_t umasked(mode_t expected_mode)
{
mode_t mode = umask(0);
umask(mode);
return expected_mode & ~mode;
}
/* Path to working directory for current test */
const char *testworkdir;
#ifdef PROGRAM
@ -1156,6 +1163,35 @@ assertion_file_contains_lines_any_order(const char *file, int line,
return (0);
}
/* Verify that a text file does not contains the specified strings */
int
assertion_file_contains_no_invalid_strings(const char *file, int line,
const char *pathname, const char *strings[])
{
char *buff;
int i;
buff = slurpfile(NULL, "%s", pathname);
if (buff == NULL) {
failure_start(file, line, "Can't read file: %s", pathname);
failure_finish(NULL);
return (0);
}
for (i = 0; strings[i] != NULL; ++i) {
if (strstr(buff, strings[i]) != NULL) {
failure_start(file, line, "Invalid string in %s: %s", pathname,
strings[i]);
failure_finish(NULL);
free(buff);
return(0);
}
}
free(buff);
return (0);
}
/* Test that two paths point to the same file. */
/* As a side-effect, asserts that both files exist. */
static int
@ -1293,6 +1329,11 @@ assertion_file_time(const char *file, int line,
switch (type) {
case 'a': filet_nsec = st.st_atimespec.tv_nsec; break;
case 'b': filet = st.st_birthtime;
/* FreeBSD filesystems that don't support birthtime
* (e.g., UFS1) always return -1 here. */
if (filet == -1) {
return (1);
}
filet_nsec = st.st_birthtimespec.tv_nsec; break;
case 'm': filet_nsec = st.st_mtimespec.tv_nsec; break;
default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type);
@ -1370,6 +1411,8 @@ assertion_file_mode(const char *file, int line, const char *pathname, int expect
assertion_count(file, line);
#if defined(_WIN32) && !defined(__CYGWIN__)
failure_start(file, line, "assertFileMode not yet implemented for Windows");
(void)mode; /* UNUSED */
(void)r; /* UNUSED */
#else
{
struct stat st;
@ -1424,7 +1467,7 @@ assertion_file_nlinks(const char *file, int line,
assertion_count(file, line);
r = lstat(pathname, &st);
if (r == 0 && (int)st.st_nlink == nlinks)
return (1);
return (1);
failure_start(file, line, "File %s has %d links, expected %d",
pathname, st.st_nlink, nlinks);
failure_finish(NULL);
@ -1660,6 +1703,7 @@ assertion_make_file(const char *file, int line,
if (0 != chmod(path, mode)) {
failure_start(file, line, "Could not chmod %s", path);
failure_finish(NULL);
close(fd);
return (0);
}
if (contents != NULL) {
@ -1674,6 +1718,7 @@ assertion_make_file(const char *file, int line,
failure_start(file, line,
"Could not write to %s", path);
failure_finish(NULL);
close(fd);
return (0);
}
}

View File

@ -174,6 +174,9 @@
/* Assert that file contents match a string. */
#define assertFileContents(data, data_size, pathname) \
assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname)
/* Verify that a file does not contain invalid strings */
#define assertFileContainsNoInvalidStrings(pathname, strings) \
assertion_file_contains_no_invalid_strings(__FILE__, __LINE__, pathname, strings)
#define assertFileMtime(pathname, sec, nsec) \
assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec)
#define assertFileMtimeRecent(pathname) \
@ -182,6 +185,8 @@
assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks)
#define assertFileSize(pathname, size) \
assertion_file_size(__FILE__, __LINE__, pathname, size)
#define assertFileMode(pathname, mode) \
assertion_file_mode(__FILE__, __LINE__, pathname, mode)
#define assertTextFileContents(text, pathname) \
assertion_text_file_contents(__FILE__, __LINE__, text, pathname)
#define assertFileContainsLinesAnyOrder(pathname, lines) \
@ -239,6 +244,7 @@ int assertion_file_atime_recent(const char *, int, const char *);
int assertion_file_birthtime(const char *, int, const char *, long, long);
int assertion_file_birthtime_recent(const char *, int, const char *);
int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **);
int assertion_file_contains_no_invalid_strings(const char *, int, const char *, const char **);
int assertion_file_contents(const char *, int, const void *, int, const char *);
int assertion_file_exists(const char *, int, const char *);
int assertion_file_mode(const char *, int, const char *, int);
@ -327,6 +333,9 @@ void copy_reference_file(const char *);
*/
void extract_reference_files(const char **);
/* Subtract umask from mode */
mode_t umasked(mode_t expected_mode);
/* Path to working directory for current test */
extern const char *testworkdir;

View File

@ -4,8 +4,8 @@ dnl First, define all of the version numbers up front.
dnl In particular, this allows the version macro to be used in AC_INIT
dnl These first two version numbers are updated automatically on each release.
m4_define([LIBARCHIVE_VERSION_S],[3.2.1])
m4_define([LIBARCHIVE_VERSION_N],[3002001])
m4_define([LIBARCHIVE_VERSION_S],[3.2.2])
m4_define([LIBARCHIVE_VERSION_N],[3002002])
dnl bsdtar and bsdcpio versioning tracks libarchive
m4_define([BSDTAR_VERSION_S],LIBARCHIVE_VERSION_S())

View File

@ -91,7 +91,8 @@ IF(ENABLE_CPIO AND ENABLE_TEST)
# Experimental new test handling
ADD_CUSTOM_TARGET(run_bsdcpio_test
COMMAND bsdcpio_test -p $<TARGET_FILE:bsdcpio>
-r ${CMAKE_CURRENT_SOURCE_DIR})
-r ${CMAKE_CURRENT_SOURCE_DIR}
-vv)
ADD_DEPENDENCIES(run_bsdcpio_test bsdcpio)
ADD_DEPENDENCIES(run_all_tests run_bsdcpio_test)
ENDIF(ENABLE_CPIO AND ENABLE_TEST)

View File

@ -1164,6 +1164,35 @@ assertion_file_contains_lines_any_order(const char *file, int line,
return (0);
}
/* Verify that a text file does not contains the specified strings */
int
assertion_file_contains_no_invalid_strings(const char *file, int line,
const char *pathname, const char *strings[])
{
char *buff;
int i;
buff = slurpfile(NULL, "%s", pathname);
if (buff == NULL) {
failure_start(file, line, "Can't read file: %s", pathname);
failure_finish(NULL);
return (0);
}
for (i = 0; strings[i] != NULL; ++i) {
if (strstr(buff, strings[i]) != NULL) {
failure_start(file, line, "Invalid string in %s: %s", pathname,
strings[i]);
failure_finish(NULL);
free(buff);
return(0);
}
}
free(buff);
return (0);
}
/* Test that two paths point to the same file. */
/* As a side-effect, asserts that both files exist. */
static int
@ -1383,6 +1412,8 @@ assertion_file_mode(const char *file, int line, const char *pathname, int expect
assertion_count(file, line);
#if defined(_WIN32) && !defined(__CYGWIN__)
failure_start(file, line, "assertFileMode not yet implemented for Windows");
(void)mode; /* UNUSED */
(void)r; /* UNUSED */
#else
{
struct stat st;

View File

@ -174,6 +174,9 @@
/* Assert that file contents match a string. */
#define assertFileContents(data, data_size, pathname) \
assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname)
/* Verify that a file does not contain invalid strings */
#define assertFileContainsNoInvalidStrings(pathname, strings) \
assertion_file_contains_no_invalid_strings(__FILE__, __LINE__, pathname, strings)
#define assertFileMtime(pathname, sec, nsec) \
assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec)
#define assertFileMtimeRecent(pathname) \
@ -241,6 +244,7 @@ int assertion_file_atime_recent(const char *, int, const char *);
int assertion_file_birthtime(const char *, int, const char *, long, long);
int assertion_file_birthtime_recent(const char *, int, const char *);
int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **);
int assertion_file_contains_no_invalid_strings(const char *, int, const char *, const char **);
int assertion_file_contents(const char *, int, const void *, int, const char *);
int assertion_file_exists(const char *, int, const char *);
int assertion_file_mode(const char *, int, const char *, int);

View File

@ -36,7 +36,7 @@
* assert that ARCHIVE_VERSION_NUMBER >= 2012108.
*/
/* Note: Compiler will complain if this does not match archive_entry.h! */
#define ARCHIVE_VERSION_NUMBER 3002001
#define ARCHIVE_VERSION_NUMBER 3002002
#include <sys/stat.h>
#include <stddef.h> /* for wchar_t */
@ -155,7 +155,7 @@ __LA_DECL int archive_version_number(void);
/*
* Textual name/version of the library, useful for version displays.
*/
#define ARCHIVE_VERSION_ONLY_STRING "3.2.1"
#define ARCHIVE_VERSION_ONLY_STRING "3.2.2"
#define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
__LA_DECL const char * archive_version_string(void);

View File

@ -29,7 +29,7 @@
#define ARCHIVE_ENTRY_H_INCLUDED
/* Note: Compiler will complain if this does not match archive.h! */
#define ARCHIVE_VERSION_NUMBER 3002001
#define ARCHIVE_VERSION_NUMBER 3002002
/*
* Note: archive_entry.h is for use outside of libarchive; the

View File

@ -300,7 +300,7 @@ IF(ENABLE_TEST)
# Experimental new test handling
ADD_CUSTOM_TARGET(run_libarchive_test
COMMAND libarchive_test -r ${CMAKE_CURRENT_SOURCE_DIR})
COMMAND libarchive_test -r ${CMAKE_CURRENT_SOURCE_DIR} -vv)
ADD_DEPENDENCIES(run_all_tests run_libarchive_test)
ENDIF(ENABLE_TEST)

View File

@ -1162,6 +1162,35 @@ assertion_file_contains_lines_any_order(const char *file, int line,
return (0);
}
/* Verify that a text file does not contains the specified strings */
int
assertion_file_contains_no_invalid_strings(const char *file, int line,
const char *pathname, const char *strings[])
{
char *buff;
int i;
buff = slurpfile(NULL, "%s", pathname);
if (buff == NULL) {
failure_start(file, line, "Can't read file: %s", pathname);
failure_finish(NULL);
return (0);
}
for (i = 0; strings[i] != NULL; ++i) {
if (strstr(buff, strings[i]) != NULL) {
failure_start(file, line, "Invalid string in %s: %s", pathname,
strings[i]);
failure_finish(NULL);
free(buff);
return(0);
}
}
free(buff);
return (0);
}
/* Test that two paths point to the same file. */
/* As a side-effect, asserts that both files exist. */
static int
@ -1381,6 +1410,8 @@ assertion_file_mode(const char *file, int line, const char *pathname, int expect
assertion_count(file, line);
#if defined(_WIN32) && !defined(__CYGWIN__)
failure_start(file, line, "assertFileMode not yet implemented for Windows");
(void)mode; /* UNUSED */
(void)r; /* UNUSED */
#else
{
struct stat st;

View File

@ -174,6 +174,9 @@
/* Assert that file contents match a string. */
#define assertFileContents(data, data_size, pathname) \
assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname)
/* Verify that a file does not contain invalid strings */
#define assertFileContainsNoInvalidStrings(pathname, strings) \
assertion_file_contains_no_invalid_strings(__FILE__, __LINE__, pathname, strings)
#define assertFileMtime(pathname, sec, nsec) \
assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec)
#define assertFileMtimeRecent(pathname) \
@ -241,6 +244,7 @@ int assertion_file_atime_recent(const char *, int, const char *);
int assertion_file_birthtime(const char *, int, const char *, long, long);
int assertion_file_birthtime_recent(const char *, int, const char *);
int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **);
int assertion_file_contains_no_invalid_strings(const char *, int, const char *, const char **);
int assertion_file_contents(const char *, int, const void *, int, const char *);
int assertion_file_exists(const char *, int, const char *);
int assertion_file_mode(const char *, int, const char *, int);

View File

@ -33,6 +33,11 @@ DEFINE_TEST(test_read_format_mtree_crash747)
const char *reffile = "test_read_format_mtree_crash747.mtree.bz2";
struct archive *a;
if (archive_bzlib_version() == NULL) {
skipping("This test requires bzlib");
return;
}
extract_reference_file(reffile);
assert((a = archive_read_new()) != NULL);

View File

@ -50,6 +50,11 @@ DEFINE_TEST(test_read_format_zip_high_compression)
size_t s;
int64_t o;
if (archive_zlib_version() == NULL) {
skipping("Zip compression test requires zlib");
return;
}
extract_reference_file(refname);
p = slurpfile(&archive_size, refname);
@ -82,6 +87,11 @@ DEFINE_TEST(test_read_format_zip_high_compression2)
char *body, *body_read, *buff;
int n;
if (archive_zlib_version() == NULL) {
skipping("Zip compression test requires zlib");
return;
}
assert((body = malloc(body_size)) != NULL);
assert((body_read = malloc(body_size)) != NULL);
assert((buff = malloc(buff_size)) != NULL);

View File

@ -133,11 +133,12 @@ DEFINE_TEST(test_read_append_filter)
assert((a = archive_read_new()) != NULL);
assertA(0 == archive_read_set_format(a, ARCHIVE_FORMAT_TAR));
r = archive_read_append_filter(a, ARCHIVE_FILTER_GZIP);
if (r == ARCHIVE_WARN && !canGzip()) {
skipping("gzip reading not fully supported on this platform");
if (r != ARCHIVE_OK && archive_zlib_version() == NULL && !canGzip()) {
skipping("gzip tests require zlib or working gzip command");
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
return;
}
assertEqualIntA(a, ARCHIVE_OK, r);
assertEqualInt(ARCHIVE_OK,
archive_read_open_memory(a, archive, sizeof(archive)));
assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae));
@ -200,8 +201,11 @@ DEFINE_TEST(test_read_append_filter_wrong_program)
{
struct archive_entry *ae;
struct archive *a;
#if !defined(_WIN32) || defined(__CYGWIN__)
FILE * fp;
int fd;
fpos_t pos;
#endif
/*
* If we have "bunzip2 -q", try using that.
@ -211,11 +215,13 @@ DEFINE_TEST(test_read_append_filter_wrong_program)
return;
}
#if !defined(_WIN32) || defined(__CYGWIN__)
/* bunzip2 will write to stderr, redirect it to a file */
fflush(stderr);
fgetpos(stderr, &pos);
fd = dup(fileno(stderr));
freopen("stderr1", "w", stderr);
fp = freopen("stderr1", "w", stderr);
#endif
assert((a = archive_read_new()) != NULL);
assertA(0 == archive_read_set_format(a, ARCHIVE_FORMAT_TAR));
@ -227,12 +233,15 @@ DEFINE_TEST(test_read_append_filter_wrong_program)
assertEqualIntA(a, ARCHIVE_WARN, archive_read_close(a));
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
/* restore stderr */
fflush(stderr);
dup2(fd, fileno(stderr));
close(fd);
clearerr(stderr);
fsetpos(stderr, &pos);
#if !defined(_WIN32) || defined(__CYGWIN__)
/* restore stderr and verify results */
if (fp != NULL) {
fflush(stderr);
dup2(fd, fileno(stderr));
close(fd);
clearerr(stderr);
fsetpos(stderr, &pos);
}
assertTextFileContents("bunzip2: (stdin) is not a bzip2 file.\n", "stderr1");
#endif
}

View File

@ -117,8 +117,8 @@ DEFINE_TEST(test_write_format_iso9660)
*/
dirname[0] = '\0';
strcpy(dir, "/dir0");
for (i = 0; i < 10; i++) {
dir[4] = '0' + i;
for (i = 0; i < 13; i++) {
dir[4] = "0123456789ABCDEF"[i];
if (i == 0)
strcat(dirname, dir+1);
else
@ -134,6 +134,19 @@ DEFINE_TEST(test_write_format_iso9660)
archive_entry_free(ae);
}
strcat(dirname, "/file");
assert((ae = archive_entry_new()) != NULL);
archive_entry_set_atime(ae, 2, 20);
archive_entry_set_birthtime(ae, 3, 30);
archive_entry_set_ctime(ae, 4, 40);
archive_entry_set_mtime(ae, 5, 50);
archive_entry_copy_pathname(ae, dirname);
archive_entry_set_mode(ae, S_IFREG | 0755);
archive_entry_set_size(ae, 8);
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
archive_entry_free(ae);
assertEqualIntA(a, 8, archive_write_data(a, "12345678", 9));
/*
* "dir0/dir1/file1" has 8 bytes of data.
*/
@ -332,6 +345,45 @@ DEFINE_TEST(test_write_format_iso9660)
assert((S_IFDIR | 0555) == archive_entry_mode(ae));
assertEqualInt(2048, archive_entry_size(ae));
/*
* Read "dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA"
*/
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualInt(2, archive_entry_atime(ae));
assertEqualInt(3, archive_entry_birthtime(ae));
assertEqualInt(4, archive_entry_ctime(ae));
assertEqualInt(5, archive_entry_mtime(ae));
assertEqualString("dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA",
archive_entry_pathname(ae));
assert((S_IFDIR | 0555) == archive_entry_mode(ae));
assertEqualInt(2048, archive_entry_size(ae));
/*
* Read "dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB"
*/
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualInt(2, archive_entry_atime(ae));
assertEqualInt(3, archive_entry_birthtime(ae));
assertEqualInt(4, archive_entry_ctime(ae));
assertEqualInt(5, archive_entry_mtime(ae));
assertEqualString("dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB",
archive_entry_pathname(ae));
assert((S_IFDIR | 0555) == archive_entry_mode(ae));
assertEqualInt(2048, archive_entry_size(ae));
/*
* Read "dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB/dirC"
*/
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualInt(2, archive_entry_atime(ae));
assertEqualInt(3, archive_entry_birthtime(ae));
assertEqualInt(4, archive_entry_ctime(ae));
assertEqualInt(5, archive_entry_mtime(ae));
assertEqualString("dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB/dirC",
archive_entry_pathname(ae));
assert((S_IFDIR | 0555) == archive_entry_mode(ae));
assertEqualInt(2048, archive_entry_size(ae));
/*
* Read "hardlnk"
*/
@ -385,6 +437,21 @@ DEFINE_TEST(test_write_format_iso9660)
assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
assertEqualMem(buff2, "12345678", 8);
/*
* Read "dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB/dirC/file"
*/
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualInt(2, archive_entry_atime(ae));
assertEqualInt(3, archive_entry_birthtime(ae));
assertEqualInt(4, archive_entry_ctime(ae));
assertEqualInt(5, archive_entry_mtime(ae));
assertEqualString("dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB/dirC/file", archive_entry_pathname(ae));
assert((AE_IFREG | 0555) == archive_entry_mode(ae));
assertEqualInt(1, archive_entry_nlink(ae));
assertEqualInt(8, archive_entry_size(ae));
assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
assertEqualMem(buff2, "12345678", 8);
/*
* Read "dir0/dir1/file1"
*/
@ -580,18 +647,40 @@ DEFINE_TEST(test_write_format_iso9660)
assertEqualInt(2048, archive_entry_size(ae));
/*
* Read "hardlnk"
* Read "dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA"
*/
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualInt(5, archive_entry_atime(ae));
assertEqualInt(5, archive_entry_ctime(ae));
assertEqualInt(5, archive_entry_mtime(ae));
assertEqualString("hardlnk", archive_entry_pathname(ae));
assert((AE_IFREG | 0400) == archive_entry_mode(ae));
assertEqualInt(2, archive_entry_nlink(ae));
assertEqualInt(8, archive_entry_size(ae));
assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
assertEqualMem(buff2, "12345678", 8);
assertEqualString("dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA",
archive_entry_pathname(ae));
assert((S_IFDIR | 0700) == archive_entry_mode(ae));
assertEqualInt(2048, archive_entry_size(ae));
/*
* Read "dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB"
*/
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualInt(5, archive_entry_atime(ae));
assertEqualInt(5, archive_entry_ctime(ae));
assertEqualInt(5, archive_entry_mtime(ae));
assertEqualString("dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB",
archive_entry_pathname(ae));
assert((S_IFDIR | 0700) == archive_entry_mode(ae));
assertEqualInt(2048, archive_entry_size(ae));
/*
* Read "dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB/dirC"
*/
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualInt(5, archive_entry_atime(ae));
assertEqualInt(5, archive_entry_ctime(ae));
assertEqualInt(5, archive_entry_mtime(ae));
assertEqualString("dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB/dirC",
archive_entry_pathname(ae));
assert((S_IFDIR | 0700) == archive_entry_mode(ae));
assertEqualInt(2048, archive_entry_size(ae));
/*
* Read "file"
@ -601,8 +690,22 @@ DEFINE_TEST(test_write_format_iso9660)
assertEqualInt(5, archive_entry_ctime(ae));
assertEqualInt(5, archive_entry_mtime(ae));
assertEqualString("file", archive_entry_pathname(ae));
assertEqualString("hardlnk", archive_entry_hardlink(ae));
assert((AE_IFREG | 0400) == archive_entry_mode(ae));
assertEqualInt(8, archive_entry_size(ae));
assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
assertEqualMem(buff2, "12345678", 8);
/*
* Read "hardlnk"
*/
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualInt(5, archive_entry_atime(ae));
assertEqualInt(5, archive_entry_ctime(ae));
assertEqualInt(5, archive_entry_mtime(ae));
assertEqualString("hardlnk", archive_entry_pathname(ae));
assertEqualString("file", archive_entry_hardlink(ae));
assert((AE_IFREG | 0400) == archive_entry_mode(ae));
assertEqualInt(2, archive_entry_nlink(ae));
assertEqualInt(0, archive_entry_size(ae));
assertEqualIntA(a, 0, archive_read_data(a, buff2, 10));
@ -624,6 +727,22 @@ DEFINE_TEST(test_write_format_iso9660)
assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
assertEqualMem(buff2, "12345678", 8);
/*
* Read "dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB/dirC/file"
*/
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualInt(5, archive_entry_atime(ae));
assertEqualInt(5, archive_entry_ctime(ae));
assertEqualInt(5, archive_entry_mtime(ae));
assertEqualString(
"dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB/dirC/file",
archive_entry_pathname(ae));
assert((AE_IFREG | 0400) == archive_entry_mode(ae));
assertEqualInt(1, archive_entry_nlink(ae));
assertEqualInt(8, archive_entry_size(ae));
assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
assertEqualMem(buff2, "12345678", 8);
/*
* Read "dir0/dir1/file1"
*/
@ -745,6 +864,42 @@ DEFINE_TEST(test_write_format_iso9660)
assert((S_IFDIR | 0700) == archive_entry_mode(ae));
assertEqualInt(2048, archive_entry_size(ae));
/*
* Read "rr_moved/dir7/dir8/dir9/dira"
*/
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualInt(5, archive_entry_atime(ae));
assertEqualInt(5, archive_entry_ctime(ae));
assertEqualInt(5, archive_entry_mtime(ae));
assertEqualString("RR_MOVED/DIR7/DIR8/DIR9/DIRA",
archive_entry_pathname(ae));
assert((S_IFDIR | 0700) == archive_entry_mode(ae));
assertEqualInt(2048, archive_entry_size(ae));
/*
* Read "rr_moved/dir7/dir8/dir9/dira/dirB"
*/
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualInt(5, archive_entry_atime(ae));
assertEqualInt(5, archive_entry_ctime(ae));
assertEqualInt(5, archive_entry_mtime(ae));
assertEqualString("RR_MOVED/DIR7/DIR8/DIR9/DIRA/DIRB",
archive_entry_pathname(ae));
assert((S_IFDIR | 0700) == archive_entry_mode(ae));
assertEqualInt(2048, archive_entry_size(ae));
/*
* Read "rr_moved/dir7/dir8/dir9/dirA/dirB/dirC"
*/
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualInt(5, archive_entry_atime(ae));
assertEqualInt(5, archive_entry_ctime(ae));
assertEqualInt(5, archive_entry_mtime(ae));
assertEqualString("RR_MOVED/DIR7/DIR8/DIR9/DIRA/DIRB/DIRC",
archive_entry_pathname(ae));
assert((S_IFDIR | 0700) == archive_entry_mode(ae));
assertEqualInt(2048, archive_entry_size(ae));
/*
* Read "dir0"
*/
@ -826,6 +981,20 @@ DEFINE_TEST(test_write_format_iso9660)
assert((S_IFDIR | 0700) == archive_entry_mode(ae));
assertEqualInt(2048, archive_entry_size(ae));
/*
* Read "hardlink"
*/
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualInt(5, archive_entry_atime(ae));
assertEqualInt(5, archive_entry_ctime(ae));
assertEqualInt(5, archive_entry_mtime(ae));
assertEqualString("HARDLNK", archive_entry_pathname(ae));
assertEqualString(NULL, archive_entry_hardlink(ae));
assert((AE_IFREG | 0400) == archive_entry_mode(ae));
assertEqualInt(8, archive_entry_size(ae));
assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
assertEqualMem(buff2, "12345678", 8);
/*
* Read "file"
*/
@ -835,25 +1004,13 @@ DEFINE_TEST(test_write_format_iso9660)
assertEqualInt(5, archive_entry_ctime(ae));
assertEqualInt(5, archive_entry_mtime(ae));
assertEqualString("FILE", archive_entry_pathname(ae));
assertEqualString("HARDLNK", archive_entry_hardlink(ae));
assert((AE_IFREG | 0400) == archive_entry_mode(ae));
assertEqualInt(2, archive_entry_nlink(ae));
assertEqualInt(8, archive_entry_size(ae));
assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
assertEqualMem(buff2, "12345678", 8);
/*
* Read "hardlink"
*/
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualInt(5, archive_entry_atime(ae));
assertEqualInt(5, archive_entry_ctime(ae));
assertEqualInt(5, archive_entry_mtime(ae));
assertEqualString("HARDLNK", archive_entry_pathname(ae));
assertEqualString("FILE", archive_entry_hardlink(ae));
assert((AE_IFREG | 0400) == archive_entry_mode(ae));
assertEqualInt(0, archive_entry_size(ae));
assertEqualIntA(a, 0, archive_read_data(a, buff2, 10));
/*
* Read longname
*/
@ -870,6 +1027,22 @@ DEFINE_TEST(test_write_format_iso9660)
assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
assertEqualMem(buff2, "12345678", 8);
/*
* Read "rr_moved/dir7/dir8/dir9/dirA/dirB/dirC/file"
*/
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualInt(5, archive_entry_atime(ae));
assertEqualInt(5, archive_entry_ctime(ae));
assertEqualInt(5, archive_entry_mtime(ae));
assertEqualString(
"RR_MOVED/DIR7/DIR8/DIR9/DIRA/DIRB/DIRC/FILE",
archive_entry_pathname(ae));
assert((AE_IFREG | 0400) == archive_entry_mode(ae));
assertEqualInt(1, archive_entry_nlink(ae));
assertEqualInt(8, archive_entry_size(ae));
assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
assertEqualMem(buff2, "12345678", 8);
/*
* Read "dir0/dir1/file1"
*/

View File

@ -100,7 +100,8 @@ IF(ENABLE_TAR AND ENABLE_TEST)
# Experimental new test handling
ADD_CUSTOM_TARGET(run_bsdtar_test
COMMAND bsdtar_test -p $<TARGET_FILE:bsdtar>
-r ${CMAKE_CURRENT_SOURCE_DIR})
-r ${CMAKE_CURRENT_SOURCE_DIR}
-vv)
ADD_DEPENDENCIES(run_bsdtar_test bsdtar)
ADD_DEPENDENCIES(run_all_tests run_bsdtar_test)

View File

@ -1188,7 +1188,7 @@ assertion_file_contains_no_invalid_strings(const char *file, int line,
return(0);
}
}
free(buff);
return (0);
}
@ -1412,6 +1412,8 @@ assertion_file_mode(const char *file, int line, const char *pathname, int expect
assertion_count(file, line);
#if defined(_WIN32) && !defined(__CYGWIN__)
failure_start(file, line, "assertFileMode not yet implemented for Windows");
(void)mode; /* UNUSED */
(void)r; /* UNUSED */
#else
{
struct stat st;

View File

@ -244,7 +244,7 @@ int assertion_file_atime_recent(const char *, int, const char *);
int assertion_file_birthtime(const char *, int, const char *, long, long);
int assertion_file_birthtime_recent(const char *, int, const char *);
int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **);
int assertion_file_contains_no_invalid_strings(const char *, int, const char *, const char **);
int assertion_file_contains_no_invalid_strings(const char *, int, const char *, const char **);
int assertion_file_contents(const char *, int, const void *, int, const char *);
int assertion_file_exists(const char *, int, const char *);
int assertion_file_mode(const char *, int, const char *, int);

View File

@ -33,7 +33,7 @@ DEFINE_TEST(test_option_b)
assertMakeFile("file1", 0644, "file1");
if (systemf("cat file1 > test_cat.out 2> test_cat.err") != 0) {
skipping("Platform doesn't have cat");
skipping("This test requires a `cat` program");
return;
}
testprog_ustar = malloc(strlen(testprog) + sizeof(USTAR_OPT) + 1);

View File

@ -63,7 +63,7 @@ DEFINE_TEST(test_symlink_dir)
/* "dir2" is a symlink to a non-existing "real_dir2" */
assertMakeSymlink("dest1/dir2", "real_dir2");
} else {
skipping("some symlink checks");
skipping("Symlinks are not supported on this platform");
}
/* "dir3" is a symlink to an existing "non_dir3" */
assertMakeFile("dest1/non_dir3", 0755, "abcdef");