summaryrefslogtreecommitdiff
path: root/archivers/libarchive/files/libarchive
diff options
context:
space:
mode:
Diffstat (limited to 'archivers/libarchive/files/libarchive')
-rw-r--r--archivers/libarchive/files/libarchive/archive_entry.38
-rw-r--r--archivers/libarchive/files/libarchive/archive_entry.c14
-rw-r--r--archivers/libarchive/files/libarchive/archive_entry.h4
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_compression_program.c7
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_format_tar.c16
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_format_zip.c9
-rw-r--r--archivers/libarchive/files/libarchive/archive_string.c13
-rw-r--r--archivers/libarchive/files/libarchive/archive_string_sprintf.c6
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_disk.c7
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_format_ar.c8
-rw-r--r--archivers/libarchive/files/libarchive/test/main.c112
-rw-r--r--archivers/libarchive/files/libarchive/test/test.h14
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse.c28
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_tar.c439
-rw-r--r--archivers/libarchive/files/libarchive/test/test_tar_filenames.c20
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_disk_perms.c4
16 files changed, 585 insertions, 124 deletions
diff --git a/archivers/libarchive/files/libarchive/archive_entry.3 b/archivers/libarchive/files/libarchive/archive_entry.3
index 11b9356264c..6b1b270f1a5 100644
--- a/archivers/libarchive/files/libarchive/archive_entry.3
+++ b/archivers/libarchive/files/libarchive/archive_entry.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/lib/libarchive/archive_entry.3,v 1.14 2007/05/29 01:00:18 kientzle Exp $
+.\" $FreeBSD: src/lib/libarchive/archive_entry.3,v 1.15 2007/07/15 19:10:34 kientzle Exp $
.\"
.Dd December 15, 2003
.Dt archive_entry 3
@@ -41,6 +41,7 @@
.Nm archive_entry_clear ,
.Nm archive_entry_clone ,
.Nm archive_entry_copy_fflags_text_w ,
+.Nm archive_entry_copy_gname ,
.Nm archive_entry_copy_gname_w ,
.Nm archive_entry_copy_hardlink ,
.Nm archive_entry_copy_hardlink_w ,
@@ -48,6 +49,7 @@
.Nm archive_entry_copy_stat ,
.Nm archive_entry_copy_symlink ,
.Nm archive_entry_copy_symlink_w ,
+.Nm archive_entry_copy_uname ,
.Nm archive_entry_copy_uname_w ,
.Nm archive_entry_dev ,
.Nm archive_entry_devmajor ,
@@ -125,6 +127,8 @@
.Ft const wchar_t *
.Fn archive_entry_copy_fflags_text_w "struct archive_entry *" "const wchar_t *"
.Ft void
+.Fn archive_entry_copy_gname "struct archive_entry *" "const char *"
+.Ft void
.Fn archive_entry_copy_gname_w "struct archive_entry *" "const wchar_t *"
.Ft void
.Fn archive_entry_copy_hardlink "struct archive_entry *" "const char *"
@@ -139,6 +143,8 @@
.Ft void
.Fn archive_entry_copy_symlink_w "struct archive_entry *" "const wchar_t *"
.Ft void
+.Fn archive_entry_copy_uname "struct archive_entry *" "const char *"
+.Ft void
.Fn archive_entry_copy_uname_w "struct archive_entry *" "const wchar_t *"
.Ft dev_t
.Fn archive_entry_dev "struct archive_entry *"
diff --git a/archivers/libarchive/files/libarchive/archive_entry.c b/archivers/libarchive/files/libarchive/archive_entry.c
index 6772d7f01f4..0ef2a18dd7b 100644
--- a/archivers/libarchive/files/libarchive/archive_entry.c
+++ b/archivers/libarchive/files/libarchive/archive_entry.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry.c,v 1.43 2007/05/29 01:00:18 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry.c,v 1.44 2007/07/15 19:10:34 kientzle Exp $");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -652,6 +652,12 @@ archive_entry_set_gname(struct archive_entry *entry, const char *name)
}
void
+archive_entry_copy_gname(struct archive_entry *entry, const char *name)
+{
+ aes_copy_mbs(&entry->ae_gname, name);
+}
+
+void
archive_entry_copy_gname_w(struct archive_entry *entry, const wchar_t *name)
{
aes_copy_wcs(&entry->ae_gname, name);
@@ -836,6 +842,12 @@ archive_entry_set_uname(struct archive_entry *entry, const char *name)
}
void
+archive_entry_copy_uname(struct archive_entry *entry, const char *name)
+{
+ aes_copy_mbs(&entry->ae_uname, name);
+}
+
+void
archive_entry_copy_uname_w(struct archive_entry *entry, const wchar_t *name)
{
aes_copy_wcs(&entry->ae_uname, name);
diff --git a/archivers/libarchive/files/libarchive/archive_entry.h b/archivers/libarchive/files/libarchive/archive_entry.h
index 69467515383..a6f3291b65c 100644
--- a/archivers/libarchive/files/libarchive/archive_entry.h
+++ b/archivers/libarchive/files/libarchive/archive_entry.h
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/archive_entry.h,v 1.22 2007/05/29 01:00:18 kientzle Exp $
+ * $FreeBSD: src/lib/libarchive/archive_entry.h,v 1.23 2007/07/15 19:10:34 kientzle Exp $
*/
#ifndef ARCHIVE_ENTRY_H_INCLUDED
@@ -135,6 +135,7 @@ const wchar_t *archive_entry_copy_fflags_text_w(struct archive_entry *,
const wchar_t *);
void archive_entry_set_gid(struct archive_entry *, gid_t);
void archive_entry_set_gname(struct archive_entry *, const char *);
+void archive_entry_copy_gname(struct archive_entry *, const char *);
void archive_entry_copy_gname_w(struct archive_entry *, const wchar_t *);
void archive_entry_set_hardlink(struct archive_entry *, const char *);
void archive_entry_copy_hardlink(struct archive_entry *, const char *);
@@ -156,6 +157,7 @@ void archive_entry_copy_symlink(struct archive_entry *, const char *);
void archive_entry_copy_symlink_w(struct archive_entry *, const wchar_t *);
void archive_entry_set_uid(struct archive_entry *, uid_t);
void archive_entry_set_uname(struct archive_entry *, const char *);
+void archive_entry_copy_uname(struct archive_entry *, const char *);
void archive_entry_copy_uname_w(struct archive_entry *, const wchar_t *);
/*
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_program.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_program.c
index 6815a3bd8b1..58b4bbddf0b 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_compression_program.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_compression_program.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_program.c,v 1.1 2007/05/29 01:00:19 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_program.c,v 1.2 2007/07/20 01:28:50 kientzle Exp $");
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
@@ -113,6 +113,7 @@ child_read(struct archive_read *a, char *buf, size_t buf_len)
{
struct archive_decompress_program *state = a->decompressor->data;
ssize_t ret, requested;
+ const void *child_buf;
if (state->child_stdout == -1)
return (-1);
@@ -138,8 +139,10 @@ restart_read:
return (-1);
if (state->child_in_buf_avail == 0) {
+ child_buf = state->child_in_buf;
ret = (a->client_reader)(&a->archive,
- a->client_data, (const void **)&state->child_in_buf);
+ a->client_data,&child_buf);
+ state->child_in_buf = (const char *)child_buf;
if (ret < 0) {
close(state->child_stdin);
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c b/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c
index 679e4eeef19..9124592ae8a 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_tar.c,v 1.58 2007/07/12 15:00:28 cperciva Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_tar.c,v 1.60 2007/07/15 19:13:59 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -895,8 +895,14 @@ read_body_to_string(struct archive_read *a, struct tar *tar,
return (ARCHIVE_FATAL);
}
+ /* Fail if we can't make our buffer big enough. */
+ if (archive_string_ensure(as, size+1) == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "No memory");
+ return (ARCHIVE_FATAL);
+ }
+
/* Read the body into the string. */
- archive_string_ensure(as, size+1);
padded_size = (size + 511) & ~ 511;
dest = as->s;
while (padded_size > 0) {
@@ -2020,7 +2026,11 @@ readline(struct archive_read *a, struct tar *tar, const char **start)
}
/* Otherwise, we need to accumulate in a line buffer. */
for (;;) {
- archive_string_ensure(&tar->line, total_size + bytes_read);
+ if (archive_string_ensure(&tar->line, total_size + bytes_read) == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate working buffer");
+ return (ARCHIVE_FATAL);
+ }
memcpy(tar->line.s + total_size, t, bytes_read);
(a->decompressor->consume)(a, bytes_read);
total_size += bytes_read;
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_zip.c b/archivers/libarchive/files/libarchive/archive_read_support_format_zip.c
index 651e8dd793f..0d8df370e35 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_format_zip.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_format_zip.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_zip.c,v 1.13 2007/05/29 01:00:19 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_zip.c,v 1.14 2007/07/15 19:13:59 kientzle Exp $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -302,7 +302,8 @@ zip_read_file_header(struct archive_read *a, struct archive_entry *entry,
"Truncated ZIP file header");
return (ARCHIVE_FATAL);
}
- archive_string_ensure(&zip->pathname, zip->filename_length);
+ if (archive_string_ensure(&zip->pathname, zip->filename_length) == NULL)
+ __archive_errx(1, "Out of memory");
archive_strncpy(&zip->pathname, (const char *)h, zip->filename_length);
(a->decompressor->consume)(a, zip->filename_length);
archive_entry_set_pathname(entry, zip->pathname.s);
@@ -756,8 +757,8 @@ process_extra(const void* extra, struct zip* zip)
if (flags & 0x01)
{
#ifdef DEBUG
- fprintf(stderr, "mtime: %d -> %d\n",
- zip->mtime, i4(p + offset));
+ fprintf(stderr, "mtime: %lld -> %d\n",
+ (long long)zip->mtime, i4(p + offset));
#endif
if (datasize < 4)
break;
diff --git a/archivers/libarchive/files/libarchive/archive_string.c b/archivers/libarchive/files/libarchive/archive_string.c
index eb26a74935a..7e43b360a4d 100644
--- a/archivers/libarchive/files/libarchive/archive_string.c
+++ b/archivers/libarchive/files/libarchive/archive_string.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_string.c,v 1.10 2007/05/29 01:00:19 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_string.c,v 1.11 2007/07/15 19:13:59 kientzle Exp $");
/*
* Basic resizable string support, to simplify manipulating arbitrary-sized
@@ -44,7 +44,8 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_string.c,v 1.10 2007/05/29 01:00:
struct archive_string *
__archive_string_append(struct archive_string *as, const char *p, size_t s)
{
- __archive_string_ensure(as, as->length + s + 1);
+ if (__archive_string_ensure(as, as->length + s + 1) == NULL)
+ __archive_errx(1, "Out of memory");
memcpy(as->s + as->length, p, s);
as->s[as->length + s] = 0;
as->length += s;
@@ -54,7 +55,8 @@ __archive_string_append(struct archive_string *as, const char *p, size_t s)
void
__archive_string_copy(struct archive_string *dest, struct archive_string *src)
{
- __archive_string_ensure(dest, src->length + 1);
+ if (__archive_string_ensure(dest, src->length + 1) == NULL)
+ __archive_errx(1, "Out of memory");
memcpy(dest->s, src->s, src->length);
dest->length = src->length;
dest->s[dest->length] = 0;
@@ -69,6 +71,7 @@ __archive_string_free(struct archive_string *as)
free(as->s);
}
+/* Returns NULL on any allocation failure. */
struct archive_string *
__archive_string_ensure(struct archive_string *as, size_t s)
{
@@ -80,10 +83,8 @@ __archive_string_ensure(struct archive_string *as, size_t s)
while (as->buffer_length < s)
as->buffer_length *= 2;
as->s = (char *)realloc(as->s, as->buffer_length);
- /* TODO: Return null instead and fix up all of our callers to
- * handle this correctly. */
if (as->s == NULL)
- __archive_errx(1, "Out of memory");
+ return (NULL);
return (as);
}
diff --git a/archivers/libarchive/files/libarchive/archive_string_sprintf.c b/archivers/libarchive/files/libarchive/archive_string_sprintf.c
index 13eff5c103a..763e75dcd84 100644
--- a/archivers/libarchive/files/libarchive/archive_string_sprintf.c
+++ b/archivers/libarchive/files/libarchive/archive_string_sprintf.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_string_sprintf.c,v 1.8 2007/01/09 08:05:55 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_string_sprintf.c,v 1.9 2007/07/15 19:13:59 kientzle Exp $");
/*
* The use of printf()-family functions can be troublesome
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_string_sprintf.c,v 1.8 2007/01/09
#include <stdio.h>
#include "archive_string.h"
+#include "archive_private.h"
/*
* Like 'vsprintf', but ensures the target is big enough, resizing if
@@ -56,7 +57,8 @@ __archive_string_vsprintf(struct archive_string *as, const char *fmt,
uintmax_t u; /* Unsigned integer temp. */
const char *p, *p2;
- __archive_string_ensure(as, 64);
+ if (__archive_string_ensure(as, 64) == NULL)
+ __archive_errx(1, "Out of memory");
if (fmt == NULL) {
as->s[0] = 0;
diff --git a/archivers/libarchive/files/libarchive/archive_write_disk.c b/archivers/libarchive/files/libarchive/archive_write_disk.c
index 691dfe48a07..331bfe3b1cd 100644
--- a/archivers/libarchive/files/libarchive/archive_write_disk.c
+++ b/archivers/libarchive/files/libarchive/archive_write_disk.c
@@ -25,7 +25,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.12 2007/05/29 01:00:19 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.13 2007/07/15 19:13:59 kientzle Exp $");
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -610,7 +610,10 @@ archive_write_disk_new(void)
a->lookup_uid = trivial_lookup_uid;
a->lookup_gid = trivial_lookup_gid;
a->user_uid = geteuid();
- archive_string_ensure(&a->path_safe, 64);
+ if (archive_string_ensure(&a->path_safe, 512) == NULL) {
+ free(a);
+ return (NULL);
+ }
return (&a->archive);
}
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_ar.c b/archivers/libarchive/files/libarchive/archive_write_set_format_ar.c
index bf3ea4de5d7..404b651311e 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_format_ar.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_format_ar.c
@@ -76,7 +76,7 @@ static ssize_t archive_write_ar_data(struct archive_write *,
const void *buff, size_t s);
static int archive_write_ar_destroy(struct archive_write *);
static int archive_write_ar_finish_entry(struct archive_write *);
-static const char *basename(const char *path);
+static const char *ar_basename(const char *path);
static int format_octal(int64_t v, char *p, int s);
static int format_decimal(int64_t v, char *p, int s);
@@ -192,11 +192,11 @@ archive_write_ar_header(struct archive_write *a, struct archive_entry *entry)
goto size;
}
- /*
+ /*
* Otherwise, entry is a normal archive member.
* Strip leading paths from filenames, if any.
*/
- if ((filename = basename(pathname)) == NULL) {
+ if ((filename = ar_basename(pathname)) == NULL) {
/* Reject filenames with trailing "/" */
archive_set_error(&a->archive, EINVAL,
"Invalid filename");
@@ -507,7 +507,7 @@ format_decimal(int64_t v, char *p, int s)
}
static const char *
-basename(const char *path)
+ar_basename(const char *path)
{
const char *endp, *startp;
diff --git a/archivers/libarchive/files/libarchive/test/main.c b/archivers/libarchive/files/libarchive/test/main.c
index be713c61b83..9dd852ffa75 100644
--- a/archivers/libarchive/files/libarchive/test/main.c
+++ b/archivers/libarchive/files/libarchive/test/main.c
@@ -32,7 +32,13 @@
#include <time.h>
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/main.c,v 1.6 2007/07/13 15:09:07 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/main.c,v 1.8 2007/07/31 05:03:27 kientzle Exp $");
+
+/* Interix doesn't define these in a standard header. */
+#if __INTERIX__
+extern char *optarg;
+extern int optind;
+#endif
/* Default is to crash and try to force a core dump on failure. */
static int dump_on_failure = 1;
@@ -60,12 +66,60 @@ static int skips = 0;
*/
static char msg[4096];
+/*
+ * For each test source file, we remember how many times each
+ * failure was reported.
+ */
+static const char *failed_filename;
+static struct line {
+ int line;
+ int count;
+} failed_lines[1000];
+
+
+/* Count this failure; return the number of previous failures. */
+static int
+previous_failures(const char *filename, int line)
+{
+ int i;
+ int count;
+
+ if (failed_filename == NULL || strcmp(failed_filename, filename) != 0)
+ memset(failed_lines, 0, sizeof(failed_lines));
+ failed_filename = filename;
+
+ for (i = 0; i < sizeof(failed_lines)/sizeof(failed_lines[0]); i++) {
+ if (failed_lines[i].line == line) {
+ count = failed_lines[i].count;
+ failed_lines[i].count++;
+ return (count);
+ }
+ if (failed_lines[i].line == 0) {
+ failed_lines[i].line = line;
+ failed_lines[i].count = 1;
+ return (0);
+ }
+ }
+}
/* Inform user that we're skipping a test. */
+static const char *skipped_filename;
+static int skipped_line;
+void skipping_setup(const char *filename, int line)
+{
+ skipped_filename = filename;
+ skipped_line = line;
+}
void
-skipping(const char *fmt, ...)
+test_skipping(const char *fmt, ...)
{
+ int i;
+ int line = skipped_line;
va_list ap;
+
+ if (previous_failures(skipped_filename, skipped_line))
+ return;
+
va_start(ap, fmt);
fprintf(stderr, " *** SKIPPING: ");
vfprintf(stderr, fmt, ap);
@@ -76,8 +130,10 @@ skipping(const char *fmt, ...)
/* Common handling of failed tests. */
static void
-test_failed(struct archive *a)
+test_failed(struct archive *a, int line)
{
+ int i;
+
failures ++;
if (msg[0] != '\0') {
@@ -95,6 +151,39 @@ test_failed(struct archive *a)
}
}
+/* Summarize repeated failures in the just-completed test file. */
+int
+summarize_comparator(const void *a0, const void *b0)
+{
+ const struct line *a = a0, *b = b0;
+ if (a->line == 0 && b->line == 0)
+ return (0);
+ if (a->line == 0)
+ return (1);
+ if (b->line == 0)
+ return (-1);
+ return (a->line - b->line);
+}
+
+void
+summarize(const char *filename)
+{
+ int i;
+
+ qsort(failed_lines, sizeof(failed_lines)/sizeof(failed_lines[0]),
+ sizeof(failed_lines[0]), summarize_comparator);
+ for (i = 0; i < sizeof(failed_lines)/sizeof(failed_lines[0]); i++) {
+ if (failed_lines[i].line == 0)
+ break;
+ if (failed_lines[i].count > 1)
+ fprintf(stderr, "%s:%d: Failed %d times\n",
+ failed_filename, failed_lines[i].line,
+ failed_lines[i].count);
+ }
+ /* Clear the failure history for the next file. */
+ memset(failed_lines, 0, sizeof(failed_lines));
+}
+
/* Set up a message to display only after a test fails. */
void
failure(const char *fmt, ...)
@@ -113,9 +202,11 @@ test_assert(const char *file, int line, int value, const char *condition, struct
msg[0] = '\0';
return;
}
+ if (previous_failures(file, line))
+ return;
fprintf(stderr, "%s:%d: Assertion failed\n", file, line);
fprintf(stderr, " Condition: %s\n", condition);
- test_failed(a);
+ test_failed(a, line);
}
/* assertEqualInt() displays the values of the two integers. */
@@ -127,11 +218,13 @@ test_assert_equal_int(const char *file, int line,
msg[0] = '\0';
return;
}
+ if (previous_failures(file, line))
+ return;
fprintf(stderr, "%s:%d: Assertion failed: Ints not equal\n",
file, line);
fprintf(stderr, " %s=%d\n", e1, v1);
fprintf(stderr, " %s=%d\n", e2, v2);
- test_failed(a);
+ test_failed(a, line);
}
/* assertEqualString() displays the values of the two strings. */
@@ -150,11 +243,13 @@ test_assert_equal_string(const char *file, int line,
msg[0] = '\0';
return;
}
+ if (previous_failures(file, line))
+ return;
fprintf(stderr, "%s:%d: Assertion failed: Strings not equal\n",
file, line);
fprintf(stderr, " %s = \"%s\"\n", e1, v1);
fprintf(stderr, " %s = \"%s\"\n", e2, v2);
- test_failed(a);
+ test_failed(a, line);
}
/* assertEqualWString() displays the values of the two strings. */
@@ -168,11 +263,13 @@ test_assert_equal_wstring(const char *file, int line,
msg[0] = '\0';
return;
}
+ if (previous_failures(file, line))
+ return;
fprintf(stderr, "%s:%d: Assertion failed: Unicode strings not equal\n",
file, line);
fwprintf(stderr, L" %s = \"%ls\"\n", e1, v1);
fwprintf(stderr, L" %s = \"%ls\"\n", e2, v2);
- test_failed(a);
+ test_failed(a, line);
}
/*
@@ -217,6 +314,7 @@ static int test_run(int i, const char *tmpdir)
exit(1);
}
(*tests[i].func)();
+ summarize(tests[i].name);
return (failures == failures_before ? 0 : 1);
}
diff --git a/archivers/libarchive/files/libarchive/test/test.h b/archivers/libarchive/files/libarchive/test/test.h
index 3c4c1ed9540..c4a110c7199 100644
--- a/archivers/libarchive/files/libarchive/test/test.h
+++ b/archivers/libarchive/files/libarchive/test/test.h
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/test/test.h,v 1.5 2007/07/13 15:12:52 kientzle Exp $
+ * $FreeBSD: src/lib/libarchive/test/test.h,v 1.6 2007/07/14 17:52:01 kientzle Exp $
*/
/* Every test program should #include "test.h" as the first thing. */
@@ -116,9 +116,19 @@
#define assertEqualWString(v1,v2) \
test_assert_equal_wstring(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
+/*
+ * This would be simple with C99 variadic macros, but I don't want to
+ * require that. Instead, I insert a function call before each
+ * skipping() call to pass the file and line information down. Crude,
+ * but effective.
+ */
+#define skipping \
+ skipping_setup(__FILE__, __LINE__);test_skipping
+
/* Function declarations. These are defined in test_utility.c. */
void failure(const char *fmt, ...);
-void skipping(const char *fmt, ...);
+void skipping_setup(const char *, int);
+void test_skipping(const char *fmt, ...);
void test_assert(const char *, int, int, const char *, struct archive *);
void test_assert_equal_int(const char *, int, int, const char *, int, const char *, struct archive *);
void test_assert_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, struct archive *);
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse.c b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse.c
index dddf6680115..a3d2a7b75f7 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_gtar_sparse.c,v 1.3 2007/07/13 15:16:26 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_gtar_sparse.c,v 1.4 2007/07/14 17:54:14 kientzle Exp $");
/*
* Each of the following is an archive of a single sparse file
@@ -91,7 +91,12 @@ static unsigned char archive_0_1[] = {
164,'I',243,147,'H','$',18,227,240,1,'Q',127,'c',137,0,14,0,0};
/* GNU tar "1.0" posix format, as written by GNU tar 1.16.1. */
-#if 1
+/*
+ * Uncompressed, as that exercises some of the code better
+ * than compressed does. (The uncompression layers try to work with
+ * large blocks and the parsing code here has sections that have
+ * to work harder if reads return small pieces of data.)
+ */
static unsigned char archive_1_0[] = {
'.','/','P','a','x','H','e','a','d','e','r','s','.','7','2','6','6','8','/',
's','p','a','r','s','e',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -229,25 +234,6 @@ static unsigned char archive_1_0[] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-#else
-static unsigned char archive_1_0[] = {
-31,139,8,0,210,221,'l','F',0,3,237,148,207,'N',195,'0',12,198,'s',206,'S',
-244,9,210,216,206,159,238,208,'+',236,132,144,16,15,16,'A',14,'E',219,'@',
-201,'&','M','<','=','i','G','Q',133,'4','v','`','l',170,240,239,'b',235,'s',
-20,'9','q',190,168,250,'>',236,151,'1','<',199,148,149,'G',231,154,':',191,
-133,148,163,'8',31,186,224,140,233,'#','x',171,167,'q',0,193,10,208,142,8,
-172,'3',30,133,6,178,218,139,'j',127,198,30,142,178,203,219,144,'J','+',191,
-221,231,243,',','_','q','&',' ','V',183,'w',143,234,'0','s',181,14,'/',175,
-169,5,249,'M',237,'6','E',213,18,221,'T',221,132,'u','l',15,185,'$',152,'V',
-'R',12,171,220,189,199,150,192,'X',143,141,'D',']',133,'m','W',150,3,'4',
-'`','i',225,200,244,218,211,'T','3',206,202,'k','_',198,'?','D',213,'e','p',
-15,195,220,'n',186,'U',252,147,'/',224,132,255,169,183,203,232,127,4,'(',
-254,183,224,181,168,'.','b',162,209,255,229,'-',254,184,238,'T','}',166,254,
-'\'',185,'(',144,147,22,'P','B','I',27,143,'C','>','z','W',179,'+',153,227,
-132,'k','7',192,204,26,'~','?',12,195,'0',12,'s','y','>',0,244,'|','e',9,
-0,18,0,0};
-#endif
-
#endif
#define min(a,b) ((a) < (b) ? (a) : (b))
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_tar.c b/archivers/libarchive/files/libarchive/test/test_read_format_tar.c
index 89989211eee..c3b5212d8e7 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_tar.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_tar.c
@@ -23,71 +23,410 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_tar.c,v 1.1 2007/03/03 07:37:37 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_tar.c,v 1.2 2007/07/14 05:35:17 kientzle Exp $");
-static unsigned char archive[] = {
-'.',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0','7','5',
-'5',' ',0,'0','0','1','7','5','0',' ',0,'0','0','1','7','5','0',' ',0,'0',
-'0','0','0','0','0','0','0','0','0','0',' ','1','0','3','3','4','0','4','1',
-'7','3','6',' ','0','1','0','5','6','1',0,' ','5',0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',0,'0','0','t','i','m',0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'t','i','m',0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0','0','0','0',
-' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+/*
+ * Each of these archives is a short archive with a single entry. The
+ * corresponding verify function verifies the entry structure returned
+ * from libarchive is what it should be. The support functions pad with
+ * lots of zeros, so we can trim trailing zero bytes from each hardcoded
+ * archive to save space.
+ *
+ * The naming here follows the tar file type flags. E.g. '1' is a hardlink,
+ * '2' is a symlink, '5' is a dir, etc.
+ */
-DEFINE_TEST(test_read_format_tar)
+/* Single entry with a hardlink. */
+static unsigned char archive1[] = {
+'h','a','r','d','l','i','n','k',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0',
+'0','6','4','4',' ',0,'0','0','1','7','5','0',' ',0,'0','0','1','7','5','0',
+' ',0,'0','0','0','0','0','0','0','0','0','0','0',' ','1','0','6','4','6',
+'0','5','2','6','6','2',' ','0','1','3','0','5','7',0,' ','1','f','i','l',
+'e',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',0,'0',
+'0','t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+'t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0',
+'0','0','0','0','0',' ',0,'0','0','0','0','0','0',' '};
+
+static void verify1(struct archive_entry *ae)
+{
+ /* A hardlink is not a symlink. */
+ assert(!S_ISLNK(archive_entry_mode(ae)));
+ /* Nor is it a directory. */
+ assert(!S_ISDIR(archive_entry_mode(ae)));
+ assertEqualInt(archive_entry_mode(ae) & 0777, 0644);
+ assertEqualInt(archive_entry_uid(ae), 1000);
+ assertEqualInt(archive_entry_gid(ae), 1000);
+ assertEqualString(archive_entry_uname(ae), "tim");
+ assertEqualString(archive_entry_gname(ae), "tim");
+ assertEqualString(archive_entry_pathname(ae), "hardlink");
+ assertEqualString(archive_entry_hardlink(ae), "file");
+ assert(archive_entry_symlink(ae) == NULL);
+ assertEqualInt(archive_entry_mtime(ae), 1184388530);
+}
+
+/* Verify that symlinks are read correctly. */
+static unsigned char archive2[] = {
+'s','y','m','l','i','n','k',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0',
+'0','0','7','5','5',' ','0','0','0','1','7','5','0',' ','0','0','0','1','7',
+'5','0',' ','0','0','0','0','0','0','0','0','0','0','0',' ','1','0','6','4',
+'6','0','5','4','1','0','1',' ','0','0','1','3','3','2','3',' ','2','f','i',
+'l','e',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',0,
+'0','0','t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,'t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+'0','0','0','0','0','0','0',' ','0','0','0','0','0','0','0',' '};
+
+static void verify2(struct archive_entry *ae)
+{
+ assert(S_ISLNK(archive_entry_mode(ae)));
+ assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
+ assertEqualInt(archive_entry_uid(ae), 1000);
+ assertEqualInt(archive_entry_gid(ae), 1000);
+ assertEqualString(archive_entry_uname(ae), "tim");
+ assertEqualString(archive_entry_gname(ae), "tim");
+ assertEqualString(archive_entry_pathname(ae), "symlink");
+ assertEqualString(archive_entry_symlink(ae), "file");
+ assert(archive_entry_hardlink(ae) == NULL);
+ assertEqualInt(archive_entry_mtime(ae), 1184389185);
+}
+
+/* Character device node. */
+static unsigned char archive3[] = {
+'d','e','v','c','h','a','r',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0',
+'0','0','7','5','5',' ','0','0','0','1','7','5','0',' ','0','0','0','1','7',
+'5','0',' ','0','0','0','0','0','0','0','0','0','0','0',' ','1','0','6','4',
+'6','0','5','4','1','0','1',' ','0','0','1','2','4','1','2',' ','3',0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',0,
+'0','0','t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,'t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+'0','0','0','0','0','0','0',' ','0','0','0','0','0','0','0',' '};
+
+static void verify3(struct archive_entry *ae)
+{
+ assert(S_ISCHR(archive_entry_mode(ae)));
+ assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
+ assertEqualInt(archive_entry_uid(ae), 1000);
+ assertEqualInt(archive_entry_gid(ae), 1000);
+ assertEqualString(archive_entry_uname(ae), "tim");
+ assertEqualString(archive_entry_gname(ae), "tim");
+ assertEqualString(archive_entry_pathname(ae), "devchar");
+ assert(archive_entry_symlink(ae) == NULL);
+ assert(archive_entry_hardlink(ae) == NULL);
+ assertEqualInt(archive_entry_mtime(ae), 1184389185);
+}
+
+/* Block device node. */
+static unsigned char archive4[] = {
+'d','e','v','b','l','o','c','k',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0',
+'0','0','7','5','5',' ','0','0','0','1','7','5','0',' ','0','0','0','1','7',
+'5','0',' ','0','0','0','0','0','0','0','0','0','0','0',' ','1','0','6','4',
+'6','0','5','4','1','0','1',' ','0','0','1','2','5','7','0',' ','4',0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',0,
+'0','0','t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,'t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+'0','0','0','0','0','0','0',' ','0','0','0','0','0','0','0',' '};
+
+static void verify4(struct archive_entry *ae)
+{
+ assert(S_ISBLK(archive_entry_mode(ae)));
+ assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
+ assertEqualInt(archive_entry_uid(ae), 1000);
+ assertEqualInt(archive_entry_gid(ae), 1000);
+ assertEqualString(archive_entry_uname(ae), "tim");
+ assertEqualString(archive_entry_gname(ae), "tim");
+ assertEqualString(archive_entry_pathname(ae), "devblock");
+ assert(archive_entry_symlink(ae) == NULL);
+ assert(archive_entry_hardlink(ae) == NULL);
+ assertEqualInt(archive_entry_mtime(ae), 1184389185);
+}
+
+/* Directory. */
+static unsigned char archive5[] = {
+'.',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0',
+'7','5','5',' ',0,'0','0','1','7','5','0',' ',0,'0','0','1','7','5','0',
+' ',0,'0','0','0','0','0','0','0','0','0','0','0',' ','1','0','3','3',
+'4','0','4','1','7','3','6',' ','0','1','0','5','6','1',0,' ','5',0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',0,
+'0','0','t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,'t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0',' '};
+
+static void verify5(struct archive_entry *ae)
+{
+ assert(S_ISDIR(archive_entry_mode(ae)));
+ assertEqualInt(archive_entry_mtime(ae), 1131430878);
+ assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
+ assertEqualInt(archive_entry_uid(ae), 1000);
+ assertEqualInt(archive_entry_gid(ae), 1000);
+ assertEqualString(archive_entry_uname(ae), "tim");
+ assertEqualString(archive_entry_gname(ae), "tim");
+}
+
+/* fifo */
+static unsigned char archive6[] = {
+'f','i','f','o',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0',
+'0','0','7','5','5',' ','0','0','0','1','7','5','0',' ','0','0','0','1','7',
+'5','0',' ','0','0','0','0','0','0','0','0','0','0','0',' ','1','0','6','4',
+'6','0','5','4','1','0','1',' ','0','0','1','1','7','2','4',' ','6',0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',0,
+'0','0','t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,'t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+'0','0','0','0','0','0','0',' ','0','0','0','0','0','0','0',' '};
+
+static void verify6(struct archive_entry *ae)
+{
+ assert(S_ISFIFO(archive_entry_mode(ae)));
+ assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
+ assertEqualInt(archive_entry_uid(ae), 1000);
+ assertEqualInt(archive_entry_gid(ae), 1000);
+ assertEqualString(archive_entry_uname(ae), "tim");
+ assertEqualString(archive_entry_gname(ae), "tim");
+ assertEqualString(archive_entry_pathname(ae), "fifo");
+ assert(archive_entry_symlink(ae) == NULL);
+ assert(archive_entry_hardlink(ae) == NULL);
+ assertEqualInt(archive_entry_mtime(ae), 1184389185);
+}
+
+/* GNU long link name */
+static unsigned char archiveK[] = {
+'.','/','.','/','@','L','o','n','g','L','i','n','k',0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,'0','0','0','0','0','0','0',0,'0','0','0','0','0','0','0',0,'0','0','0',
+'0','0','0','0',0,'0','0','0','0','0','0','0','0','6','6','6',0,'0','0','0',
+'0','0','0','0','0','0','0','0',0,'0','1','1','7','1','5',0,' ','K',0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',' ',' ',
+0,'r','o','o','t',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+'w','h','e','e','l',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'t',
+'h','i','s','_','i','s','_','a','_','v','e','r','y','_','l','o','n','g','_',
+'s','y','m','l','i','n','k','_','b','o','d','y','_','a','b','c','d','e','f',
+'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y',
+'z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
+'r','s','t','u','v','w','x','y','z','_','a','b','c','d','e','f','g','h','i',
+'j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','_','a',
+'b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t',
+'u','v','w','x','y','z','_','a','b','c','d','e','f','g','h','i','j','k','l',
+'m','n','o','p','q','r','s','t','u','v','w','x','y','z','_','a','b','c','d',
+'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w',
+'x','y','z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',
+'p','q','r','s','t','u','v','w','x','y','z','_','a','b','c','d','e','f','g',
+'h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
+'_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r',
+'s','t','u','v','w','x','y','z','_','a','b','c','d','e','f','g','h','i','j',
+'k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','_','a','b',
+'c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u',
+'v','w','x','y','z','_','a','b','c','d','e','f','g','h','i','j','k','l','m',
+'n','o','p','q','r','s','t','u','v','w','x','y','z','_','a','b','c','d','e',
+'f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x',
+'y','z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p',
+'q','r','s','t','u','v','w','x','y','z','_','a','b','c','d','e','f','g','h',
+'i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+'s','y','m','l','i','n','k',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','1',
+'2','0','7','5','5',0,'0','0','0','1','7','5','0',0,'0','0','0','1','7','5',
+'0',0,'0','0','0','0','0','0','0','0','0','0','0',0,'1','0','6','4','6','0',
+'5','6','7','7','0',0,'0','3','5','4','4','7',0,' ','2','t','h','i','s','_',
+'i','s','_','a','_','v','e','r','y','_','l','o','n','g','_','s','y','m','l',
+'i','n','k','_','b','o','d','y','_','a','b','c','d','e','f','g','h','i','j',
+'k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','_','a','b',
+'c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u',
+'v','w','x','y','z','_','a','b','c','d','e','f','g','h','i','j','k','l',0,
+'u','s','t','a','r',' ',' ',0,'t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,'t','i','m'};
+
+static void verifyK(struct archive_entry *ae)
+{
+ assert(S_ISLNK(archive_entry_mode(ae)));
+ assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
+ assertEqualInt(archive_entry_uid(ae), 1000);
+ assertEqualInt(archive_entry_gid(ae), 1000);
+ assertEqualString(archive_entry_uname(ae), "tim");
+ assertEqualString(archive_entry_gname(ae), "tim");
+ assertEqualString(archive_entry_pathname(ae), "symlink");
+ assertEqualString(archive_entry_symlink(ae),
+ "this_is_a_very_long_symlink_body_abcdefghijklmnopqrstuvwxyz_"
+ "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_"
+ "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_"
+ "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_"
+ "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_"
+ "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_"
+ "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_"
+ "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz");
+ assert(archive_entry_hardlink(ae) == NULL);
+ assertEqualInt(archive_entry_mtime(ae), 1184390648);
+}
+
+/* TODO: GNU long name */
+
+/* TODO: Solaris ACL */
+
+/* Pax extended long link name */
+static unsigned char archivexL[] = {
+'.','/','P','a','x','H','e','a','d','e','r','s','.','8','6','9','7','5','/',
+'s','y','m','l','i','n','k',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0','0','6','4','4',0,'0','0','0','1',
+'7','5','0',0,'0','0','0','1','7','5','0',0,'0','0','0','0','0','0','0','0',
+'7','5','3',0,'1','0','6','4','6','0','5','7','6','1','1',0,'0','1','3','7',
+'1','4',0,' ','x',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u',
+'s','t','a','r',0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,'0','0','0','0','0','0','0',0,'0','0','0','0','0','0','0',0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'4','5','1',' ','l','i','n','k','p','a','t',
+'h','=','t','h','i','s','_','i','s','_','a','_','v','e','r','y','_','l','o',
+'n','g','_','s','y','m','l','i','n','k','_','b','o','d','y','_','a','b','c',
+'d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
+'w','x','y','z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n',
+'o','p','q','r','s','t','u','v','w','x','y','z','_','a','b','c','d','e','f',
+'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y',
+'z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
+'r','s','t','u','v','w','x','y','z','_','a','b','c','d','e','f','g','h','i',
+'j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','_','a',
+'b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t',
+'u','v','w','x','y','z','_','a','b','c','d','e','f','g','h','i','j','k','l',
+'m','n','o','p','q','r','s','t','u','v','w','x','y','z','_','a','b','c','d',
+'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w',
+'x','y','z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',
+'p','q','r','s','t','u','v','w','x','y','z','_','a','b','c','d','e','f','g',
+'h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
+'_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r',
+'s','t','u','v','w','x','y','z','_','a','b','c','d','e','f','g','h','i','j',
+'k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','_','a','b',
+'c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u',
+'v','w','x','y','z','_','a','b','c','d','e','f','g','h','i','j','k','l','m',
+'n','o','p','q','r','s','t','u','v','w','x','y','z','_','a','b','c','d','e',
+'f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x',
+'y','z',10,'2','0',' ','a','t','i','m','e','=','1','1','8','4','3','9','1',
+'0','2','5',10,'2','0',' ','c','t','i','m','e','=','1','1','8','4','3','9',
+'0','6','4','8',10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'s','y','m',
+'l','i','n','k',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0','0','7',
+'5','5',0,'0','0','0','1','7','5','0',0,'0','0','0','1','7','5','0',0,'0',
+'0','0','0','0','0','0','0','0','0','0',0,'1','0','6','4','6','0','5','6',
+'7','7','0',0,'0','3','7','1','2','1',0,' ','2','t','h','i','s','_','i','s',
+'_','a','_','v','e','r','y','_','l','o','n','g','_','s','y','m','l','i','n',
+'k','_','b','o','d','y','_','a','b','c','d','e','f','g','h','i','j','k','l',
+'m','n','o','p','q','r','s','t','u','v','w','x','y','z','_','a','b','c','d',
+'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w',
+'x','y','z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','u','s',
+'t','a','r',0,'0','0','t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,'t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,'0','0','0','0','0','0','0',0,'0','0','0','0','0','0','0'};
+
+static void verifyxL(struct archive_entry *ae)
+{
+ assert(S_ISLNK(archive_entry_mode(ae)));
+ assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
+ assertEqualInt(archive_entry_uid(ae), 1000);
+ assertEqualInt(archive_entry_gid(ae), 1000);
+ assertEqualString(archive_entry_uname(ae), "tim");
+ assertEqualString(archive_entry_gname(ae), "tim");
+ assertEqualString(archive_entry_pathname(ae), "symlink");
+ assertEqualString(archive_entry_symlink(ae),
+ "this_is_a_very_long_symlink_body_abcdefghijklmnopqrstuvwxyz_"
+ "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_"
+ "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_"
+ "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_"
+ "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_"
+ "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_"
+ "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_"
+ "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz");
+ assert(archive_entry_hardlink(ae) == NULL);
+ assertEqualInt(archive_entry_mtime(ae), 1184390648);
+}
+
+
+/* TODO: Any other types of headers? */
+
+static void verify(unsigned char *d, size_t s,
+ void (*f)(struct archive_entry *),
+ int compression, int format)
{
struct archive_entry *ae;
struct archive *a;
+ unsigned char *buff = malloc(100000);
+
+ memcpy(buff, d, s);
+ memset(buff + s, 0, 2048);
+
assert((a = archive_read_new()) != NULL);
assertA(0 == archive_read_support_compression_all(a));
assertA(0 == archive_read_support_format_all(a));
- assertA(0 == archive_read_open_memory(a, archive, sizeof(archive)));
+ assertA(0 == archive_read_open_memory(a, buff, s + 1024));
assertA(0 == archive_read_next_header(a, &ae));
- assertA(archive_compression(a) == ARCHIVE_COMPRESSION_NONE);
- assertA(archive_format(a) == ARCHIVE_FORMAT_TAR_USTAR);
+ assertEqualInt(archive_compression(a), compression);
+ assertEqualInt(archive_format(a), format);
+
+ /* Verify the only entry. */
+ f(ae);
+
assert(0 == archive_read_close(a));
#if ARCHIVE_API_VERSION > 1
assert(0 == archive_read_finish(a));
#else
archive_read_finish(a);
#endif
+ free(buff);
+}
+
+DEFINE_TEST(test_read_format_tar)
+{
+ verify(archive1, sizeof(archive1), verify1,
+ ARCHIVE_COMPRESSION_NONE, ARCHIVE_FORMAT_TAR_USTAR);
+ verify(archive2, sizeof(archive2), verify2,
+ ARCHIVE_COMPRESSION_NONE, ARCHIVE_FORMAT_TAR_USTAR);
+ verify(archive3, sizeof(archive3), verify3,
+ ARCHIVE_COMPRESSION_NONE, ARCHIVE_FORMAT_TAR_USTAR);
+ verify(archive4, sizeof(archive4), verify4,
+ ARCHIVE_COMPRESSION_NONE, ARCHIVE_FORMAT_TAR_USTAR);
+ verify(archive5, sizeof(archive5), verify5,
+ ARCHIVE_COMPRESSION_NONE, ARCHIVE_FORMAT_TAR_USTAR);
+ verify(archive6, sizeof(archive6), verify6,
+ ARCHIVE_COMPRESSION_NONE, ARCHIVE_FORMAT_TAR_USTAR);
+ verify(archiveK, sizeof(archiveK), verifyK,
+ ARCHIVE_COMPRESSION_NONE, ARCHIVE_FORMAT_TAR_GNUTAR);
+ verify(archivexL, sizeof(archivexL), verifyxL,
+ ARCHIVE_COMPRESSION_NONE, ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE);
}
diff --git a/archivers/libarchive/files/libarchive/test/test_tar_filenames.c b/archivers/libarchive/files/libarchive/test/test_tar_filenames.c
index 27c8db4e33d..b75ac7f0cae 100644
--- a/archivers/libarchive/files/libarchive/test/test_tar_filenames.c
+++ b/archivers/libarchive/files/libarchive/test/test_tar_filenames.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_tar_filenames.c,v 1.6 2007/07/06 15:43:11 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_tar_filenames.c,v 1.7 2007/07/14 17:52:01 kientzle Exp $");
/*
* Exercise various lengths of filenames in tar archives,
@@ -42,9 +42,6 @@ test_filename(const char *prefix, int dlen, int flen)
size_t used;
size_t prefix_length = 0;
int i = 0;
-#if ARCHIVE_VERSION_STAMP < 1009000
- static int bug_reported_1 = 0, bug_reported_2 = 0, bug_reported_3 = 0;
-#endif
if (prefix) {
strcpy(filename, prefix);
@@ -118,10 +115,7 @@ test_filename(const char *prefix, int dlen, int flen)
/* Read the file and check the filename. */
assertA(0 == archive_read_next_header(a, &ae));
#if ARCHIVE_VERSION_STAMP < 1009000
- if (!bug_reported_3) {
- skipping("Leading '/' preserved on long filenames");
- ++bug_reported_3;
- }
+ skipping("Leading '/' preserved on long filenames");
#else
assertEqualString(filename, archive_entry_pathname(ae));
#endif
@@ -137,10 +131,7 @@ test_filename(const char *prefix, int dlen, int flen)
*/
assertA(0 == archive_read_next_header(a, &ae));
#if ARCHIVE_VERSION_STAMP < 1009000
- if (!bug_reported_2) {
- skipping("Trailing '/' preserved on dirnames");
- ++bug_reported_2;
- }
+ skipping("Trailing '/' preserved on dirnames");
#else
assertEqualString(dirname, archive_entry_pathname(ae));
#endif
@@ -148,10 +139,7 @@ test_filename(const char *prefix, int dlen, int flen)
assertA(0 == archive_read_next_header(a, &ae));
#if ARCHIVE_VERSION_STAMP < 1009000
- if (!bug_reported_1) {
- skipping("Trailing '/' added to dir names");
- ++bug_reported_1;
- }
+ skipping("Trailing '/' added to dir names");
#else
assertEqualString(dirname, archive_entry_pathname(ae));
#endif
diff --git a/archivers/libarchive/files/libarchive/test/test_write_disk_perms.c b/archivers/libarchive/files/libarchive/test/test_write_disk_perms.c
index 36cd34581a4..cffe39fe868 100644
--- a/archivers/libarchive/files/libarchive/test/test_write_disk_perms.c
+++ b/archivers/libarchive/files/libarchive/test/test_write_disk_perms.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_disk_perms.c,v 1.5 2007/07/06 15:43:11 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_disk_perms.c,v 1.6 2007/07/15 17:16:42 kientzle Exp $");
#if ARCHIVE_VERSION_STAMP >= 1009000
@@ -235,7 +235,7 @@ DEFINE_TEST(test_write_disk_perms)
archive_entry_set_uid(ae, getuid() + 1);
archive_write_disk_set_options(a, ARCHIVE_EXTRACT_PERM);
assertA(0 == archive_write_header(a, ae));
- assertA(ARCHIVE_WARN == archive_write_finish_entry(a));
+ assertEqualInt(ARCHIVE_WARN, archive_write_finish_entry(a));
/* Write a regular file with ARCHIVE_EXTRACT_PERM & SGID bit */
assert(archive_entry_clear(ae) != NULL);