summaryrefslogtreecommitdiffstats
path: root/contrib/libarchive/cpio
diff options
context:
space:
mode:
authormm <mm@FreeBSD.org>2013-03-22 13:36:03 +0000
committermm <mm@FreeBSD.org>2013-03-22 13:36:03 +0000
commit5ee0a7b76c4addc27bb45864cb4e0ce790a4b80e (patch)
treee741e3532b574e7c25aa9bb07c18cdb16139824f /contrib/libarchive/cpio
parentaf89cb16bfde2fc8e93708b89daff55026d3b216 (diff)
parent366f42737cba40ceb2e83af8d17c61c0242703c5 (diff)
downloadFreeBSD-src-5ee0a7b76c4addc27bb45864cb4e0ce790a4b80e.zip
FreeBSD-src-5ee0a7b76c4addc27bb45864cb4e0ce790a4b80e.tar.gz
MFV r248590,248594:
Update libarchive to 3.1.2 Some of new features: - support for lrzip and grzip compression - support for writing tar v7 format - b64encode and uuencode filters - support for __MACOSX directory in Zip archives - support for lzop compresion (external utility)
Diffstat (limited to 'contrib/libarchive/cpio')
-rw-r--r--contrib/libarchive/cpio/bsdcpio.112
-rw-r--r--contrib/libarchive/cpio/cmdline.c5
-rw-r--r--contrib/libarchive/cpio/cpio.c79
-rw-r--r--contrib/libarchive/cpio/cpio.h8
-rw-r--r--contrib/libarchive/cpio/test/main.c245
-rw-r--r--contrib/libarchive/cpio/test/test.h22
-rw-r--r--contrib/libarchive/cpio/test/test_basic.c12
-rw-r--r--contrib/libarchive/cpio/test/test_extract.cpio.Z.uu7
-rw-r--r--contrib/libarchive/cpio/test/test_extract.cpio.bz2.uu7
-rw-r--r--contrib/libarchive/cpio/test/test_extract.cpio.grz.uu7
-rw-r--r--contrib/libarchive/cpio/test/test_extract.cpio.gz.uu7
-rw-r--r--contrib/libarchive/cpio/test/test_extract.cpio.lrz.uu8
-rw-r--r--contrib/libarchive/cpio/test/test_extract.cpio.lz.uu6
-rw-r--r--contrib/libarchive/cpio/test/test_extract.cpio.lzma.uu6
-rw-r--r--contrib/libarchive/cpio/test/test_extract.cpio.lzo.uu9
-rw-r--r--contrib/libarchive/cpio/test/test_extract.cpio.xz.uu7
-rw-r--r--contrib/libarchive/cpio/test/test_extract_cpio_Z.c42
-rw-r--r--contrib/libarchive/cpio/test/test_extract_cpio_bz2.c48
-rw-r--r--contrib/libarchive/cpio/test/test_extract_cpio_grz.c48
-rw-r--r--contrib/libarchive/cpio/test/test_extract_cpio_gz.c48
-rw-r--r--contrib/libarchive/cpio/test/test_extract_cpio_lrz.c48
-rw-r--r--contrib/libarchive/cpio/test/test_extract_cpio_lz.c48
-rw-r--r--contrib/libarchive/cpio/test/test_extract_cpio_lzma.c48
-rw-r--r--contrib/libarchive/cpio/test/test_extract_cpio_lzo.c48
-rw-r--r--contrib/libarchive/cpio/test/test_extract_cpio_xz.c48
-rw-r--r--contrib/libarchive/cpio/test/test_format_newc.c4
-rw-r--r--contrib/libarchive/cpio/test/test_option_b64encode.c54
-rw-r--r--contrib/libarchive/cpio/test/test_option_grzip.c52
-rw-r--r--contrib/libarchive/cpio/test/test_option_lrzip.c52
-rw-r--r--contrib/libarchive/cpio/test/test_option_lzop.c56
-rw-r--r--contrib/libarchive/cpio/test/test_option_uuencode.c54
-rw-r--r--contrib/libarchive/cpio/test/test_option_xz.c57
-rw-r--r--contrib/libarchive/cpio/test/test_option_y.c5
-rw-r--r--contrib/libarchive/cpio/test/test_option_z.c5
34 files changed, 1079 insertions, 133 deletions
diff --git a/contrib/libarchive/cpio/bsdcpio.1 b/contrib/libarchive/cpio/bsdcpio.1
index 5611b20..b3d0d40 100644
--- a/contrib/libarchive/cpio/bsdcpio.1
+++ b/contrib/libarchive/cpio/bsdcpio.1
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 24, 2011
+.Dd October 7, 2012
.Dt CPIO 1
.Os
.Sh NAME
@@ -176,11 +176,21 @@ With this option, the target of the link will be archived or copied instead.
(p mode only)
Create links from the target directory to the original files,
instead of copying.
+.It Fl Fl lrzip
+(o mode only)
+Compress the resulting archive with
+.Xr lrzip 1 .
+In input mode, this option is ignored.
.It Fl Fl lzma
(o mode only)
Compress the file with lzma-compatible compression before writing it.
In input mode, this option is ignored; lzma compression is recognized
automatically on input.
+.It Fl Fl lzop
+(o mode only)
+Compress the resulting archive with
+.Xr lzop 1 .
+In input mode, this option is ignored.
.It Fl m , Fl Fl preserve-modification-time
(i and p modes)
Set file modification time on created files to match
diff --git a/contrib/libarchive/cpio/cmdline.c b/contrib/libarchive/cpio/cmdline.c
index 7f12896..b05a736 100644
--- a/contrib/libarchive/cpio/cmdline.c
+++ b/contrib/libarchive/cpio/cmdline.c
@@ -61,16 +61,20 @@ static const struct option {
int required; /* 1 if this option requires an argument */
int equivalent; /* Equivalent short option. */
} cpio_longopts[] = {
+ { "b64encode", 0, OPTION_B64ENCODE },
{ "create", 0, 'o' },
{ "dot", 0, 'V' },
{ "extract", 0, 'i' },
{ "file", 1, 'F' },
{ "format", 1, 'H' },
+ { "grzip", 0, OPTION_GRZIP },
{ "help", 0, 'h' },
{ "insecure", 0, OPTION_INSECURE },
{ "link", 0, 'l' },
{ "list", 0, 't' },
+ { "lrzip", 0, OPTION_LRZIP },
{ "lzma", 0, OPTION_LZMA },
+ { "lzop", 0, OPTION_LZOP },
{ "make-directories", 0, 'd' },
{ "no-preserve-owner", 0, OPTION_NO_PRESERVE_OWNER },
{ "null", 0, '0' },
@@ -81,6 +85,7 @@ static const struct option {
{ "preserve-owner", 0, OPTION_PRESERVE_OWNER },
{ "quiet", 0, OPTION_QUIET },
{ "unconditional", 0, 'u' },
+ { "uuencode", 0, OPTION_UUENCODE },
{ "verbose", 0, 'v' },
{ "version", 0, OPTION_VERSION },
{ "xz", 0, 'J' },
diff --git a/contrib/libarchive/cpio/cpio.c b/contrib/libarchive/cpio/cpio.c
index fb814a2..4918138 100644
--- a/contrib/libarchive/cpio/cpio.c
+++ b/contrib/libarchive/cpio/cpio.c
@@ -207,6 +207,9 @@ main(int argc, char *argv[])
case 'B': /* POSIX 1997 */
cpio->bytes_per_block = 5120;
break;
+ case OPTION_B64ENCODE:
+ cpio->add_filter = opt;
+ break;
case 'C': /* NetBSD/OpenBSD */
cpio->bytes_per_block = atoi(cpio->argument);
if (cpio->bytes_per_block <= 0)
@@ -234,6 +237,9 @@ main(int argc, char *argv[])
lafe_errc(1, 0, "Error : %s",
archive_error_string(cpio->matching));
break;
+ case OPTION_GRZIP:
+ cpio->compress = opt;
+ break;
case 'H': /* GNU cpio (also --format) */
cpio->format = cpio->argument;
break;
@@ -265,7 +271,9 @@ main(int argc, char *argv[])
case 'l': /* POSIX 1997 */
cpio->option_link = 1;
break;
+ case OPTION_LRZIP:
case OPTION_LZMA: /* GNU tar, others */
+ case OPTION_LZOP: /* GNU tar, others */
cpio->compress = opt;
break;
case 'm': /* POSIX 1997 */
@@ -326,6 +334,9 @@ main(int argc, char *argv[])
cpio->extract_flags
&= ~ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER;
break;
+ case OPTION_UUENCODE:
+ cpio->add_filter = opt;
+ break;
case 'v': /* POSIX 1997 */
cpio->verbose++;
break;
@@ -417,6 +428,7 @@ main(int argc, char *argv[])
archive_match_free(cpio->matching);
free_cache(cpio->gname_cache);
free_cache(cpio->uname_cache);
+ free(cpio->destdir);
return (cpio->return_value);
}
@@ -516,27 +528,49 @@ mode_out(struct cpio *cpio)
if (cpio->archive == NULL)
lafe_errc(1, 0, "Failed to allocate archive object");
switch (cpio->compress) {
+ case OPTION_GRZIP:
+ r = archive_write_add_filter_grzip(cpio->archive);
+ break;
case 'J':
- r = archive_write_set_compression_xz(cpio->archive);
+ r = archive_write_add_filter_xz(cpio->archive);
+ break;
+ case OPTION_LRZIP:
+ r = archive_write_add_filter_lrzip(cpio->archive);
break;
case OPTION_LZMA:
- r = archive_write_set_compression_lzma(cpio->archive);
+ r = archive_write_add_filter_lzma(cpio->archive);
+ break;
+ case OPTION_LZOP:
+ r = archive_write_add_filter_lzop(cpio->archive);
break;
case 'j': case 'y':
- r = archive_write_set_compression_bzip2(cpio->archive);
+ r = archive_write_add_filter_bzip2(cpio->archive);
break;
case 'z':
- r = archive_write_set_compression_gzip(cpio->archive);
+ r = archive_write_add_filter_gzip(cpio->archive);
break;
case 'Z':
- r = archive_write_set_compression_compress(cpio->archive);
+ r = archive_write_add_filter_compress(cpio->archive);
break;
default:
- r = archive_write_set_compression_none(cpio->archive);
+ r = archive_write_add_filter_none(cpio->archive);
break;
}
if (r < ARCHIVE_WARN)
lafe_errc(1, 0, "Requested compression not available");
+ switch (cpio->add_filter) {
+ case 0:
+ r = ARCHIVE_OK;
+ break;
+ case OPTION_B64ENCODE:
+ r = archive_write_add_filter_b64encode(cpio->archive);
+ break;
+ case OPTION_UUENCODE:
+ r = archive_write_add_filter_uuencode(cpio->archive);
+ break;
+ }
+ if (r < ARCHIVE_WARN)
+ lafe_errc(1, 0, "Requested filter not available");
r = archive_write_set_format_by_name(cpio->archive, cpio->format);
if (r != ARCHIVE_OK)
lafe_errc(1, 0, "%s", archive_error_string(cpio->archive));
@@ -548,7 +582,7 @@ mode_out(struct cpio *cpio)
/*
* The main loop: Copy each file into the output archive.
*/
- r = archive_write_open_file(cpio->archive, cpio->filename);
+ r = archive_write_open_filename(cpio->archive, cpio->filename);
if (r != ARCHIVE_OK)
lafe_errc(1, 0, "%s", archive_error_string(cpio->archive));
lr = lafe_line_reader("-", cpio->option_null);
@@ -577,7 +611,7 @@ mode_out(struct cpio *cpio)
if (!cpio->quiet) {
int64_t blocks =
- (archive_position_uncompressed(cpio->archive) + 511)
+ (archive_filter_bytes(cpio->archive, 0) + 511)
/ 512;
fprintf(stderr, "%lu %s\n", (unsigned long)blocks,
blocks == 1 ? "block" : "blocks");
@@ -806,18 +840,21 @@ entry_to_archive(struct cpio *cpio, struct archive_entry *entry)
exit(1);
if (r >= ARCHIVE_WARN && archive_entry_size(entry) > 0 && fd >= 0) {
- bytes_read = read(fd, cpio->buff, cpio->buff_size);
+ bytes_read = read(fd, cpio->buff, (unsigned)cpio->buff_size);
while (bytes_read > 0) {
- r = archive_write_data(cpio->archive,
+ ssize_t bytes_write;
+ bytes_write = archive_write_data(cpio->archive,
cpio->buff, bytes_read);
- if (r < 0)
+ if (bytes_write < 0)
lafe_errc(1, archive_errno(cpio->archive),
"%s", archive_error_string(cpio->archive));
- if (r < bytes_read) {
+ if (bytes_write < bytes_read) {
lafe_warnc(0,
- "Truncated write; file may have grown while being archived.");
+ "Truncated write; file may have "
+ "grown while being archived.");
}
- bytes_read = read(fd, cpio->buff, cpio->buff_size);
+ bytes_read = read(fd, cpio->buff,
+ (unsigned)cpio->buff_size);
}
}
@@ -908,7 +945,8 @@ mode_in(struct cpio *cpio)
archive_read_support_filter_all(a);
archive_read_support_format_all(a);
- if (archive_read_open_file(a, cpio->filename, cpio->bytes_per_block))
+ if (archive_read_open_filename(a, cpio->filename,
+ cpio->bytes_per_block))
lafe_errc(1, archive_errno(a),
"%s", archive_error_string(a));
for (;;) {
@@ -957,7 +995,7 @@ mode_in(struct cpio *cpio)
if (r != ARCHIVE_OK)
lafe_errc(1, 0, "%s", archive_error_string(ext));
if (!cpio->quiet) {
- int64_t blocks = (archive_position_uncompressed(a) + 511)
+ int64_t blocks = (archive_filter_bytes(a, 0) + 511)
/ 512;
fprintf(stderr, "%lu %s\n", (unsigned long)blocks,
blocks == 1 ? "block" : "blocks");
@@ -988,7 +1026,7 @@ extract_data(struct archive *ar, struct archive *aw)
"%s", archive_error_string(ar));
exit(1);
}
- r = archive_write_data_block(aw, block, size, offset);
+ r = (int)archive_write_data_block(aw, block, size, offset);
if (r != ARCHIVE_OK) {
lafe_warnc(archive_errno(aw),
"%s", archive_error_string(aw));
@@ -1010,7 +1048,8 @@ mode_list(struct cpio *cpio)
archive_read_support_filter_all(a);
archive_read_support_format_all(a);
- if (archive_read_open_file(a, cpio->filename, cpio->bytes_per_block))
+ if (archive_read_open_filename(a, cpio->filename,
+ cpio->bytes_per_block))
lafe_errc(1, archive_errno(a),
"%s", archive_error_string(a));
for (;;) {
@@ -1032,7 +1071,7 @@ mode_list(struct cpio *cpio)
if (r != ARCHIVE_OK)
lafe_errc(1, 0, "%s", archive_error_string(a));
if (!cpio->quiet) {
- int64_t blocks = (archive_position_uncompressed(a) + 511)
+ int64_t blocks = (archive_filter_bytes(a, 0) + 511)
/ 512;
fprintf(stderr, "%lu %s\n", (unsigned long)blocks,
blocks == 1 ? "block" : "blocks");
@@ -1167,7 +1206,7 @@ mode_pass(struct cpio *cpio, const char *destdir)
if (!cpio->quiet) {
int64_t blocks =
- (archive_position_uncompressed(cpio->archive) + 511)
+ (archive_filter_bytes(cpio->archive, 0) + 511)
/ 512;
fprintf(stderr, "%lu %s\n", (unsigned long)blocks,
blocks == 1 ? "block" : "blocks");
diff --git a/contrib/libarchive/cpio/cpio.h b/contrib/libarchive/cpio/cpio.h
index 0859100..fac7b65 100644
--- a/contrib/libarchive/cpio/cpio.h
+++ b/contrib/libarchive/cpio/cpio.h
@@ -44,6 +44,7 @@ struct cpio {
const char *argument;
/* Options */
+ int add_filter; /* --uuencode */
const char *filename;
int mode; /* -i -o -p */
int compress; /* -j, -y, or -z */
@@ -96,11 +97,16 @@ const char *owner_parse(const char *, int *, int *);
/* Fake short equivalents for long options that otherwise lack them. */
enum {
- OPTION_INSECURE = 1,
+ OPTION_B64ENCODE = 1,
+ OPTION_GRZIP,
+ OPTION_INSECURE,
+ OPTION_LRZIP,
OPTION_LZMA,
+ OPTION_LZOP,
OPTION_NO_PRESERVE_OWNER,
OPTION_PRESERVE_OWNER,
OPTION_QUIET,
+ OPTION_UUENCODE,
OPTION_VERSION
};
diff --git a/contrib/libarchive/cpio/test/main.c b/contrib/libarchive/cpio/test/main.c
index 1e4997c..3189506 100644
--- a/contrib/libarchive/cpio/test/main.c
+++ b/contrib/libarchive/cpio/test/main.c
@@ -24,6 +24,7 @@
*/
#include "test.h"
+#include "test_utils.h"
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
@@ -91,6 +92,7 @@ __FBSDID("$FreeBSD$");
*/
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <io.h>
+#include <direct.h>
#include <windows.h>
#ifndef F_OK
#define F_OK (0)
@@ -389,7 +391,6 @@ failure_finish(void *extra)
fprintf(stderr,
" *** forcing core dump so failure can be debugged ***\n");
abort();
- exit(1);
}
}
@@ -622,8 +623,8 @@ assertion_equal_string(const char *file, int line,
if (v1 == v2 || (v1 != NULL && v2 != NULL && strcmp(v1, v2) == 0))
return (1);
failure_start(file, line, "%s != %s", e1, e2);
- l1 = strlen(e1);
- l2 = strlen(e2);
+ l1 = (int)strlen(e1);
+ l2 = (int)strlen(e2);
if (l1 < l2)
l1 = l2;
strdump(e1, v1, l1, utf8);
@@ -746,6 +747,8 @@ assertion_equal_mem(const char *file, int line,
assertion_count(file, line);
if (v1 == v2 || (v1 != NULL && v2 != NULL && memcmp(v1, v2, l) == 0))
return (1);
+ if (v1 == NULL || v2 == NULL)
+ return (0);
failure_start(file, line, "%s != %s", e1, e2);
logprintf(" size %s = %d\n", ld, (int)l);
@@ -839,9 +842,14 @@ assertion_equal_file(const char *filename, int line, const char *fn1, const char
f1 = fopen(fn1, "rb");
f2 = fopen(fn2, "rb");
+ if (f1 == NULL || f2 == NULL) {
+ if (f1) fclose(f1);
+ if (f2) fclose(f2);
+ return (0);
+ }
for (;;) {
- n1 = fread(buff1, 1, sizeof(buff1), f1);
- n2 = fread(buff2, 1, sizeof(buff2), f2);
+ n1 = (int)fread(buff1, 1, sizeof(buff1), f1);
+ n2 = (int)fread(buff2, 1, sizeof(buff2), f2);
if (n1 != n2)
break;
if (n1 == 0 && n2 == 0) {
@@ -915,7 +923,7 @@ assertion_file_contents(const char *filename, int line, const void *buff, int s,
return (0);
}
contents = malloc(s * 2);
- n = fread(contents, 1, s * 2, f);
+ n = (int)fread(contents, 1, s * 2, f);
fclose(f);
if (n == s && memcmp(buff, contents, s) == 0) {
free(contents);
@@ -951,9 +959,9 @@ assertion_text_file_contents(const char *filename, int line, const char *buff, c
failure_finish(NULL);
return (0);
}
- s = strlen(buff);
+ s = (int)strlen(buff);
contents = malloc(s * 2 + 128);
- n = fread(contents, 1, s * 2 + 128 - 1, f);
+ n = (int)fread(contents, 1, s * 2 + 128 - 1, f);
if (n >= 0)
contents[n] = '\0';
fclose(f);
@@ -1004,8 +1012,8 @@ assertion_file_contains_lines_any_order(const char *file, int line,
char *buff;
size_t buff_size;
size_t expected_count, actual_count, i, j;
- char **expected;
- char *p, **actual;
+ char **expected = NULL;
+ char *p, **actual = NULL;
char c;
int expected_failure = 0, actual_failure = 0;
@@ -1018,14 +1026,21 @@ assertion_file_contains_lines_any_order(const char *file, int line,
return (0);
}
- /* Make a copy of the provided lines and count up the expected file size. */
- expected_count = 0;
+ /* Make a copy of the provided lines and count up the expected
+ * file size. */
for (i = 0; lines[i] != NULL; ++i) {
}
expected_count = i;
- expected = malloc(sizeof(char *) * expected_count);
- for (i = 0; lines[i] != NULL; ++i) {
- expected[i] = strdup(lines[i]);
+ if (expected_count) {
+ expected = malloc(sizeof(char *) * expected_count);
+ if (expected == NULL) {
+ failure_start(pathname, line, "Can't allocate memory");
+ failure_finish(NULL);
+ return (0);
+ }
+ for (i = 0; lines[i] != NULL; ++i) {
+ expected[i] = strdup(lines[i]);
+ }
}
/* Break the file into lines */
@@ -1037,11 +1052,19 @@ assertion_file_contains_lines_any_order(const char *file, int line,
++actual_count;
c = *p;
}
- actual = malloc(sizeof(char *) * actual_count);
- for (j = 0, p = buff; p < buff + buff_size; p += 1 + strlen(p)) {
- if (*p != '\0') {
- actual[j] = p;
- ++j;
+ if (actual_count) {
+ actual = calloc(sizeof(char *), actual_count);
+ if (actual == NULL) {
+ failure_start(pathname, line, "Can't allocate memory");
+ failure_finish(NULL);
+ free(expected);
+ return (0);
+ }
+ for (j = 0, p = buff; p < buff + buff_size; p += 1 + strlen(p)) {
+ if (*p != '\0') {
+ actual[j] = p;
+ ++j;
+ }
}
}
@@ -1176,11 +1199,11 @@ assertion_file_time(const char *file, int line,
#if defined(_WIN32) && !defined(__CYGWIN__)
#define EPOC_TIME (116444736000000000ULL)
- FILETIME ftime, fbirthtime, fatime, fmtime;
+ FILETIME fxtime, fbirthtime, fatime, fmtime;
ULARGE_INTEGER wintm;
HANDLE h;
- ftime.dwLowDateTime = 0;
- ftime.dwHighDateTime = 0;
+ fxtime.dwLowDateTime = 0;
+ fxtime.dwHighDateTime = 0;
assertion_count(file, line);
/* Note: FILE_FLAG_BACKUP_SEMANTICS applies to open
@@ -1195,9 +1218,9 @@ assertion_file_time(const char *file, int line,
}
r = GetFileTime(h, &fbirthtime, &fatime, &fmtime);
switch (type) {
- case 'a': ftime = fatime; break;
- case 'b': ftime = fbirthtime; break;
- case 'm': ftime = fmtime; break;
+ case 'a': fxtime = fatime; break;
+ case 'b': fxtime = fbirthtime; break;
+ case 'm': fxtime = fmtime; break;
}
CloseHandle(h);
if (r == 0) {
@@ -1205,8 +1228,8 @@ assertion_file_time(const char *file, int line,
failure_finish(NULL);
return (0);
}
- wintm.LowPart = ftime.dwLowDateTime;
- wintm.HighPart = ftime.dwHighDateTime;
+ wintm.LowPart = fxtime.dwLowDateTime;
+ wintm.HighPart = fxtime.dwHighDateTime;
filet = (wintm.QuadPart - EPOC_TIME) / 10000000;
filet_nsec = ((wintm.QuadPart - EPOC_TIME) % 10000000) * 100;
nsec = (nsec / 100) * 100; /* Round the request */
@@ -1834,15 +1857,45 @@ canSymlink(void)
return (value);
}
-/*
- * Can this platform run the gzip program?
- */
/* Platform-dependent options for hiding the output of a subcommand. */
#if defined(_WIN32) && !defined(__CYGWIN__)
static const char *redirectArgs = ">NUL 2>NUL"; /* Win32 cmd.exe */
#else
static const char *redirectArgs = ">/dev/null 2>/dev/null"; /* POSIX 'sh' */
#endif
+/*
+ * Can this platform run the bzip2 program?
+ */
+int
+canBzip2(void)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("bzip2 -d -V %s", redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+/*
+ * Can this platform run the grzip program?
+ */
+int
+canGrzip(void)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("grzip -V %s", redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+/*
+ * Can this platform run the gzip program?
+ */
int
canGzip(void)
{
@@ -1856,15 +1909,75 @@ canGzip(void)
}
/*
- * Can this platform run the gunzip program?
+ * Can this platform run the lrzip program?
+ */
+int
+canLrzip(void)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("lrzip -V %s", redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+/*
+ * Can this platform run the lzip program?
+ */
+int
+canLzip(void)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("lzip -V %s", redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+/*
+ * Can this platform run the lzma program?
*/
int
-canGunzip(void)
+canLzma(void)
{
static int tested = 0, value = 0;
if (!tested) {
tested = 1;
- if (systemf("gunzip -V %s", redirectArgs) == 0)
+ if (systemf("lzma -V %s", redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+/*
+ * Can this platform run the lzop program?
+ */
+int
+canLzop(void)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("lzop -V %s", redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+/*
+ * Can this platform run the xz program?
+ */
+int
+canXz(void)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("xz -V %s", redirectArgs) == 0)
value = 1;
}
return (value);
@@ -2124,7 +2237,7 @@ is_LargeInode(const char *file)
/* Use "list.h" to create a list of all tests (functions and names). */
#undef DEFINE_TEST
#define DEFINE_TEST(n) { n, #n, 0 },
-struct { void (*func)(void); const char *name; int failures; } tests[] = {
+struct test_list_t tests[] = {
#include "list.h"
};
@@ -2377,65 +2490,6 @@ success:
return strdup(buff);
}
-static int
-get_test_set(int *test_set, int limit, const char *test)
-{
- int start, end;
- int idx = 0;
-
- if (test == NULL) {
- /* Default: Run all tests. */
- for (;idx < limit; idx++)
- test_set[idx] = idx;
- return (limit);
- }
- if (*test >= '0' && *test <= '9') {
- const char *vp = test;
- start = 0;
- while (*vp >= '0' && *vp <= '9') {
- start *= 10;
- start += *vp - '0';
- ++vp;
- }
- if (*vp == '\0') {
- end = start;
- } else if (*vp == '-') {
- ++vp;
- if (*vp == '\0') {
- end = limit - 1;
- } else {
- end = 0;
- while (*vp >= '0' && *vp <= '9') {
- end *= 10;
- end += *vp - '0';
- ++vp;
- }
- }
- } else
- return (-1);
- if (start < 0 || end >= limit || start > end)
- return (-1);
- while (start <= end)
- test_set[idx++] = start++;
- } else {
- size_t len = strlen(test);
- for (start = 0; start < limit; ++start) {
- const char *name = tests[start].name;
- const char *p;
-
- while ((p = strchr(name, test[0])) != NULL) {
- if (strncmp(p, test, len) == 0) {
- test_set[idx++] = start;
- break;
- } else
- name = p + 1;
- }
-
- }
- }
- return ((idx == 0)?-1:idx);
-}
-
int
main(int argc, char **argv)
{
@@ -2720,10 +2774,11 @@ main(int argc, char **argv)
do {
int test_num;
- test_num = get_test_set(test_set, limit, *argv);
+ test_num = get_test_set(test_set, limit, *argv, tests);
if (test_num < 0) {
printf("*** INVALID Test %s\n", *argv);
free(refdir_alloc);
+ free(testprogdir);
usage(progname);
return (1);
}
diff --git a/contrib/libarchive/cpio/test/test.h b/contrib/libarchive/cpio/test/test.h
index b9e7030..f2127ec 100644
--- a/contrib/libarchive/cpio/test/test.h
+++ b/contrib/libarchive/cpio/test/test.h
@@ -266,11 +266,29 @@ void sleepUntilAfter(time_t);
/* Return true if this platform can create symlinks. */
int canSymlink(void);
+/* Return true if this platform can run the "bzip2" program. */
+int canBzip2(void);
+
+/* Return true if this platform can run the "grzip" program. */
+int canGrzip(void);
+
/* Return true if this platform can run the "gzip" program. */
int canGzip(void);
-/* Return true if this platform can run the "gunzip" program. */
-int canGunzip(void);
+/* Return true if this platform can run the "lrzip" program. */
+int canLrzip(void);
+
+/* Return true if this platform can run the "lzip" program. */
+int canLzip(void);
+
+/* Return true if this platform can run the "lzma" program. */
+int canLzma(void);
+
+/* Return true if this platform can run the "lzop" program. */
+int canLzop(void);
+
+/* Return true if this platform can run the "xz" program. */
+int canXz(void);
/* Return true if this filesystem can handle nodump flags. */
int canNodump(void);
diff --git a/contrib/libarchive/cpio/test/test_basic.c b/contrib/libarchive/cpio/test/test_basic.c
index fa3fdb5..bd3229a 100644
--- a/contrib/libarchive/cpio/test/test_basic.c
+++ b/contrib/libarchive/cpio/test/test_basic.c
@@ -148,7 +148,7 @@ DEFINE_TEST(test_basic)
strncat(result,
"bsdcpio: file: large inode number truncated: "
"Numerical result out of range\n",
- sizeof(result) - strlen(result));
+ sizeof(result) - strlen(result) -1);
/* hardlink to above file. */
assertMakeHardlink("linkfile", "file");
@@ -157,7 +157,7 @@ DEFINE_TEST(test_basic)
strncat(result,
"bsdcpio: linkfile: large inode number truncated: "
"Numerical result out of range\n",
- sizeof(result) - strlen(result));
+ sizeof(result) - strlen(result) -1);
/* Symlink to above file. */
if (canSymlink()) {
@@ -167,7 +167,7 @@ DEFINE_TEST(test_basic)
strncat(result,
"bsdcpio: symlink: large inode number truncated: "
"Numerical result out of range\n",
- sizeof(result) - strlen(result));
+ sizeof(result) - strlen(result) -1);
}
/* Another file with different permissions. */
@@ -177,7 +177,7 @@ DEFINE_TEST(test_basic)
strncat(result,
"bsdcpio: file2: large inode number truncated: "
"Numerical result out of range\n",
- sizeof(result) - strlen(result));
+ sizeof(result) - strlen(result) -1);
/* Directory. */
assertMakeDir("dir", 0775);
@@ -186,8 +186,8 @@ DEFINE_TEST(test_basic)
strncat(result,
"bsdcpio: dir: large inode number truncated: "
"Numerical result out of range\n",
- sizeof(result) - strlen(result));
- strncat(result, "2 blocks\n", sizeof(result) - strlen(result));
+ sizeof(result) - strlen(result) -1);
+ strncat(result, "2 blocks\n", sizeof(result) - strlen(result) -1);
/* All done. */
fclose(filelist);
diff --git a/contrib/libarchive/cpio/test/test_extract.cpio.Z.uu b/contrib/libarchive/cpio/test/test_extract.cpio.Z.uu
new file mode 100644
index 0000000..e520a341
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_extract.cpio.Z.uu
@@ -0,0 +1,7 @@
+begin 664 test_extract.cpio.Z
+M'YV0,&X$'`B#!@P8,0XJC)$0A@T;!A'>J+%PHL*%%P_&D`%CAHP;!F7,B*C0
+M1L:+(LVD85,F!H`Q;]S0*2-S#H@W9D"H9!G#A8*!`@46U)A11L.'$6-8U+CT
+M8D.G'#V"A"&#!L6+)D\>3+FRC(R7,6?6O)ESIU>?0`EJ7<N6[=.V:V/,@$M%
+A2I`D3(I("<$7@-^_@`,+'DRXL.'#B!,K7LRXL>/'D!4#
+`
+end
diff --git a/contrib/libarchive/cpio/test/test_extract.cpio.bz2.uu b/contrib/libarchive/cpio/test/test_extract.cpio.bz2.uu
new file mode 100644
index 0000000..228a957
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_extract.cpio.bz2.uu
@@ -0,0 +1,7 @@
+begin 664 test_extract.cpio.bz2
+M0EIH.3%!629365?=.4@``#G_@G*0(`#@`7^`(B04``LEC```!"``E`E(>I,H
+M::'J&@_4C3:@E$AD#0&@&@%"E;V/1!XIP>#C9T[41`4PQ1A`@S*4F&BD@B0T
+MBA$$-:\/@BQGNKU1G@%#`G+N0R%$JTHG(XBRB%1$V8F4#F_IWT=S4+ERVL(?
+40V!'@1L4+AO_B[DBG"A(*^Z<I```
+`
+end
diff --git a/contrib/libarchive/cpio/test/test_extract.cpio.grz.uu b/contrib/libarchive/cpio/test/test_extract.cpio.grz.uu
new file mode 100644
index 0000000..19045a9
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_extract.cpio.grz.uu
@@ -0,0 +1,7 @@
+begin 644 test_extract.cpio.grz
+M1U)::7!)20`"!#HI``(``*P-```&`0``"````&X````B%2.02C`PK`#__..F
+MI;8=99?N!6`:IQJ:XU/T"`W`B"?N/D9-0K6VN/D\.2>0,#J&)3G"\^YE?X_'
+M_K._F':0[`DL%IQ=<,Z-JH>V$S,?.[`&42C7]J^XQ@9OY!Z$!$^JLQPKZU[:
+/!M,+.$MY:Y(HS<<]U`&`
+`
+end
diff --git a/contrib/libarchive/cpio/test/test_extract.cpio.gz.uu b/contrib/libarchive/cpio/test/test_extract.cpio.gz.uu
new file mode 100644
index 0000000..7ddccad
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_extract.cpio.gz.uu
@@ -0,0 +1,7 @@
+begin 664 test_extract.cpio.gz
+M'XL("`5X<E```W1E<W1?97AT<F%C="YC<&EO`#,P-P!!`Q,#`T,#$#`$4F9F
+M(*ZYJ0&,-(#)&A@:&1@;F9L8&!F;@/EF!C!@9)R6F9-JR)"<GU>2FE=2K)"?
+MI@`6T>,R0+?$B$A+3$RQ6F*$88D1PA*"P!"[J#$2)R3(T=/'-4A149%AF`,`
+(305ZBP`"````
+`
+end
diff --git a/contrib/libarchive/cpio/test/test_extract.cpio.lrz.uu b/contrib/libarchive/cpio/test/test_extract.cpio.lrz.uu
new file mode 100644
index 0000000..563f797
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_extract.cpio.lrz.uu
@@ -0,0 +1,8 @@
+begin 664 test_extract.cpio.lrz
+M3%):20`&``(``````````%T````!`0```@$`$`,`````#@`#`````"\``QH`
+M&@````!W``$G`&4``#,``2(``0``#0$````U<-`Y!F$`MP$````8#=\$8#<1
+MR/BL39$D4M>["H7&@4%L/4*_(*VGB*YU>?RX.9]HL86'.A)H@Y;Z\^$?M^8_
+M!/-;62G.*7*A&A!_ENZ8$7]O-M7_.FTRC%BCGC95:6'9ZH3)QSCR4RX42P!`
+/-E>/7"L[:OY"/A924S4$
+`
+end
diff --git a/contrib/libarchive/cpio/test/test_extract.cpio.lz.uu b/contrib/libarchive/cpio/test/test_extract.cpio.lz.uu
new file mode 100644
index 0000000..67e41e9
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_extract.cpio.lz.uu
@@ -0,0 +1,6 @@
+begin 664 test_extract.cpio.lz
+M3%I)4`$,`!@-WP1@-Q'(^*Q-D212U[L*A<:!06P]0K\@K:>(KG5Y_+@YGVBQ
+MA8<Z$FB#EOKSX1^WYC\$\UM9*<XI<J$:$'^B>;_>8N3MLP="$0SJ#QKYB?@8
+G]@'$$7\&W^T*+9?6B=?__M$G@$T%>HL``@```````($`````````
+`
+end
diff --git a/contrib/libarchive/cpio/test/test_extract.cpio.lzma.uu b/contrib/libarchive/cpio/test/test_extract.cpio.lzma.uu
new file mode 100644
index 0000000..449403e
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_extract.cpio.lzma.uu
@@ -0,0 +1,6 @@
+begin 664 test_extract.cpio.lzma
+M70``@`#__________P`8#=\$8#<1R/BL39$D4M>["H7&@4%L/4*_(*VGB*YU
+M>?RX.9]HL86'.A)H@Y;Z\^$?M^8_!/-;62G.*7*A&A!_HGF_WF+D[;.+!OW3
+:T_2I)V(;K[FNL#'W%T+L;ATS`A*3__[1Z```
+`
+end
diff --git a/contrib/libarchive/cpio/test/test_extract.cpio.lzo.uu b/contrib/libarchive/cpio/test/test_extract.cpio.lzo.uu
new file mode 100644
index 0000000..8ce87c7
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_extract.cpio.lzo.uu
@@ -0,0 +1,9 @@
+begin 664 test_extract.cpio.lzo
+MB4Q:3P`-"AH*$#`@8`E``04#```!``"!M%!R>-T`````$71E<W1?97AT<F%C
+M="YC<&EOOH$+9````@````"DIR,^[`HP-S`W,#<P,#0P,#$P8``#,3$P,#8V
+M>`$#-S4P,#`QE`!@`7`#"C`P,3(P,S(W-#`R,S2!`C:4`'````(R,V9I;&4Q
+M`&-O;G1E;G1S(&]F((8"+@HOD0$R(`:1`31J$#`P+I$!,B^1`3(HD`%L$3L,
+M`+P<+HH`,3,I1``(5%)!24Q%4B$A(0`@JP````$`````````````````````
+*````$0``````````
+`
+end
diff --git a/contrib/libarchive/cpio/test/test_extract.cpio.xz.uu b/contrib/libarchive/cpio/test/test_extract.cpio.xz.uu
new file mode 100644
index 0000000..5c593cf
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_extract.cpio.xz.uu
@@ -0,0 +1,7 @@
+begin 664 test_extract.cpio.xz
+M_3=Z6%H```3FUK1&`@`A`18```!T+^6CX`'_`&%=`!@-WP1@-Q'(^*Q-D212
+MU[L*A<:!06P]0K\@K:>(KG5Y_+@YGVBQA8<Z$FB#EOKSX1^WYC\$\UM9*<XI
+M<J$:$'^B>;_>8N3MLXL&_=/3]*DG8ANON:ZP,?<70NQN'3"CP@``````J9FA
+=#1$]4L<``7V`!`````?M;4JQQ&?[`@`````$65H`
+`
+end
diff --git a/contrib/libarchive/cpio/test/test_extract_cpio_Z.c b/contrib/libarchive/cpio/test/test_extract_cpio_Z.c
new file mode 100644
index 0000000..f908fc5
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_extract_cpio_Z.c
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 2012 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_extract_cpio_Z)
+{
+ const char *reffile = "test_extract.cpio.Z";
+
+ extract_reference_file(reffile);
+ assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
+ testprog, reffile));
+
+ assertFileExists("file1");
+ assertTextFileContents("contents of file1.\n", "file1");
+ assertFileExists("file2");
+ assertTextFileContents("contents of file2.\n", "file2");
+ assertEmptyFile("test.out");
+ assertTextFileContents("1 block\n", "test.err");
+}
diff --git a/contrib/libarchive/cpio/test/test_extract_cpio_bz2.c b/contrib/libarchive/cpio/test/test_extract_cpio_bz2.c
new file mode 100644
index 0000000..9525e63
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_extract_cpio_bz2.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2012 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_extract_cpio_bz2)
+{
+ const char *reffile = "test_extract.cpio.bz2";
+ int f;
+
+ extract_reference_file(reffile);
+ f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
+ if (f == 0 || canBzip2()) {
+ assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
+ testprog, reffile));
+
+ assertFileExists("file1");
+ assertTextFileContents("contents of file1.\n", "file1");
+ assertFileExists("file2");
+ assertTextFileContents("contents of file2.\n", "file2");
+ assertEmptyFile("test.out");
+ assertTextFileContents("1 block\n", "test.err");
+ } else {
+ skipping("It seems bzip2 is not supported on this platform");
+ }
+}
diff --git a/contrib/libarchive/cpio/test/test_extract_cpio_grz.c b/contrib/libarchive/cpio/test/test_extract_cpio_grz.c
new file mode 100644
index 0000000..f1a0805
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_extract_cpio_grz.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2012 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_extract_cpio_grz)
+{
+ const char *reffile = "test_extract.cpio.grz";
+ int f;
+
+ extract_reference_file(reffile);
+ f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
+ if (f == 0 || canGrzip()) {
+ assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
+ testprog, reffile));
+
+ assertFileExists("file1");
+ assertTextFileContents("contents of file1.\n", "file1");
+ assertFileExists("file2");
+ assertTextFileContents("contents of file2.\n", "file2");
+ assertEmptyFile("test.out");
+ assertTextFileContents("1 block\n", "test.err");
+ } else {
+ skipping("It seems grzip is not supported on this platform");
+ }
+}
diff --git a/contrib/libarchive/cpio/test/test_extract_cpio_gz.c b/contrib/libarchive/cpio/test/test_extract_cpio_gz.c
new file mode 100644
index 0000000..19cee51
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_extract_cpio_gz.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2012 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_extract_cpio_gz)
+{
+ const char *reffile = "test_extract.cpio.gz";
+ int f;
+
+ extract_reference_file(reffile);
+ f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
+ if (f == 0 || canGzip()) {
+ assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
+ testprog, reffile));
+
+ assertFileExists("file1");
+ assertTextFileContents("contents of file1.\n", "file1");
+ assertFileExists("file2");
+ assertTextFileContents("contents of file2.\n", "file2");
+ assertEmptyFile("test.out");
+ assertTextFileContents("1 block\n", "test.err");
+ } else {
+ skipping("It seems gzip is not supported on this platform");
+ }
+}
diff --git a/contrib/libarchive/cpio/test/test_extract_cpio_lrz.c b/contrib/libarchive/cpio/test/test_extract_cpio_lrz.c
new file mode 100644
index 0000000..6766758
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_extract_cpio_lrz.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2012 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_extract_cpio_lrz)
+{
+ const char *reffile = "test_extract.cpio.lrz";
+ int f;
+
+ extract_reference_file(reffile);
+ f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
+ if (f == 0 || canLrzip()) {
+ assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
+ testprog, reffile));
+
+ assertFileExists("file1");
+ assertTextFileContents("contents of file1.\n", "file1");
+ assertFileExists("file2");
+ assertTextFileContents("contents of file2.\n", "file2");
+ assertEmptyFile("test.out");
+ assertTextFileContents("1 block\n", "test.err");
+ } else {
+ skipping("It seems lrzip is not supported on this platform");
+ }
+}
diff --git a/contrib/libarchive/cpio/test/test_extract_cpio_lz.c b/contrib/libarchive/cpio/test/test_extract_cpio_lz.c
new file mode 100644
index 0000000..4454e7b19
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_extract_cpio_lz.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2012 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_extract_cpio_lz)
+{
+ const char *reffile = "test_extract.cpio.lz";
+ int f;
+
+ extract_reference_file(reffile);
+ f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
+ if (f == 0 || canLzip()) {
+ assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
+ testprog, reffile));
+
+ assertFileExists("file1");
+ assertTextFileContents("contents of file1.\n", "file1");
+ assertFileExists("file2");
+ assertTextFileContents("contents of file2.\n", "file2");
+ assertEmptyFile("test.out");
+ assertTextFileContents("1 block\n", "test.err");
+ } else {
+ skipping("It seems lzip is not supported on this platform");
+ }
+}
diff --git a/contrib/libarchive/cpio/test/test_extract_cpio_lzma.c b/contrib/libarchive/cpio/test/test_extract_cpio_lzma.c
new file mode 100644
index 0000000..ae630d6
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_extract_cpio_lzma.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2012 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_extract_cpio_lzma)
+{
+ const char *reffile = "test_extract.cpio.lzma";
+ int f;
+
+ extract_reference_file(reffile);
+ f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
+ if (f == 0 || canLzma()) {
+ assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
+ testprog, reffile));
+
+ assertFileExists("file1");
+ assertTextFileContents("contents of file1.\n", "file1");
+ assertFileExists("file2");
+ assertTextFileContents("contents of file2.\n", "file2");
+ assertEmptyFile("test.out");
+ assertTextFileContents("1 block\n", "test.err");
+ } else {
+ skipping("It seems lzma is not supported on this platform");
+ }
+}
diff --git a/contrib/libarchive/cpio/test/test_extract_cpio_lzo.c b/contrib/libarchive/cpio/test/test_extract_cpio_lzo.c
new file mode 100644
index 0000000..f351ba7
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_extract_cpio_lzo.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2012 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_extract_cpio_lzo)
+{
+ const char *reffile = "test_extract.cpio.lrz";
+ int f;
+
+ extract_reference_file(reffile);
+ f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
+ if (f == 0 || canLzop()) {
+ assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
+ testprog, reffile));
+
+ assertFileExists("file1");
+ assertTextFileContents("contents of file1.\n", "file1");
+ assertFileExists("file2");
+ assertTextFileContents("contents of file2.\n", "file2");
+ assertEmptyFile("test.out");
+ assertTextFileContents("1 block\n", "test.err");
+ } else {
+ skipping("It seems lzop is not supported on this platform");
+ }
+}
diff --git a/contrib/libarchive/cpio/test/test_extract_cpio_xz.c b/contrib/libarchive/cpio/test/test_extract_cpio_xz.c
new file mode 100644
index 0000000..60f1b5a
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_extract_cpio_xz.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2012 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_extract_cpio_xz)
+{
+ const char *reffile = "test_extract.cpio.xz";
+ int f;
+
+ extract_reference_file(reffile);
+ f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile);
+ if (f == 0 || canXz()) {
+ assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err",
+ testprog, reffile));
+
+ assertFileExists("file1");
+ assertTextFileContents("contents of file1.\n", "file1");
+ assertFileExists("file2");
+ assertTextFileContents("contents of file2.\n", "file2");
+ assertEmptyFile("test.out");
+ assertTextFileContents("1 block\n", "test.err");
+ } else {
+ skipping("It seems xz is not supported on this platform");
+ }
+}
diff --git a/contrib/libarchive/cpio/test/test_format_newc.c b/contrib/libarchive/cpio/test/test_format_newc.c
index 4ee901b..cb8d7cf 100644
--- a/contrib/libarchive/cpio/test/test_format_newc.c
+++ b/contrib/libarchive/cpio/test/test_format_newc.c
@@ -157,9 +157,9 @@ DEFINE_TEST(test_format_newc)
/* Verify that nothing went to stderr. */
if (canSymlink()) {
- strncat(result, "2 blocks\n", sizeof(result) - strlen(result));
+ strncat(result, "2 blocks\n", sizeof(result) - strlen(result) -1);
} else {
- strncat(result, "1 block\n", sizeof(result) - strlen(result));
+ strncat(result, "1 block\n", sizeof(result) - strlen(result) -1);
}
assertTextFileContents(result, "newc.err");
diff --git a/contrib/libarchive/cpio/test/test_option_b64encode.c b/contrib/libarchive/cpio/test/test_option_b64encode.c
new file mode 100644
index 0000000..8f6b415
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_option_b64encode.c
@@ -0,0 +1,54 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2012 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_option_b64encode)
+{
+ char *p;
+ size_t s;
+
+ /* Create a file. */
+ assertMakeFile("f", 0644, "a");
+
+ /* Archive it with compress compression and uuencode. */
+ assertEqualInt(0,
+ systemf("echo f | %s -o -Z --b64encode >archive.out 2>archive.err",
+ testprog));
+ /* Check that the archive file has an uuencode signature. */
+ p = slurpfile(&s, "archive.out");
+ assert(s > 2);
+ assertEqualMem(p, "begin-base64 644", 16);
+
+ /* Archive it with uuencode only. */
+ assertEqualInt(0,
+ systemf("echo f | %s -o --b64encode >archive.out 2>archive.err",
+ testprog));
+ /* Check that the archive file has an uuencode signature. */
+ p = slurpfile(&s, "archive.out");
+ assert(s > 2);
+ assertEqualMem(p, "begin-base64 644", 16);
+}
diff --git a/contrib/libarchive/cpio/test/test_option_grzip.c b/contrib/libarchive/cpio/test/test_option_grzip.c
new file mode 100644
index 0000000..dfce2e0
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_option_grzip.c
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2012 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_option_grzip)
+{
+ char *p;
+ size_t s;
+
+ if (!canGrzip()) {
+ skipping("grzip is not supported on this platform");
+ return;
+ }
+
+ /* Create a file. */
+ assertMakeFile("f", 0644, "a");
+
+ /* Archive it with grzip compression. */
+ assertEqualInt(0,
+ systemf("echo f | %s -o --grzip >archive.out 2>archive.err",
+ testprog));
+ p = slurpfile(&s, "archive.err");
+ p[s] = '\0';
+ /* Check that the archive file has an grzip signature. */
+ p = slurpfile(&s, "archive.out");
+ assert(s > 2);
+ assertEqualMem(p, "GRZipII\x00\x02\x04:)", 12);
+}
diff --git a/contrib/libarchive/cpio/test/test_option_lrzip.c b/contrib/libarchive/cpio/test/test_option_lrzip.c
new file mode 100644
index 0000000..a84f751
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_option_lrzip.c
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2012 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_option_lrzip)
+{
+ char *p;
+ size_t s;
+
+ if (!canLrzip()) {
+ skipping("lrzip is not supported on this platform");
+ return;
+ }
+
+ /* Create a file. */
+ assertMakeFile("f", 0644, "a");
+
+ /* Archive it with lrzip compression. */
+ assertEqualInt(0,
+ systemf("echo f | %s -o --lrzip >archive.out 2>archive.err",
+ testprog));
+ p = slurpfile(&s, "archive.err");
+ p[s] = '\0';
+ /* Check that the archive file has an lzma signature. */
+ p = slurpfile(&s, "archive.out");
+ assert(s > 2);
+ assertEqualMem(p, "LRZI\x00", 5);
+}
diff --git a/contrib/libarchive/cpio/test/test_option_lzop.c b/contrib/libarchive/cpio/test/test_option_lzop.c
new file mode 100644
index 0000000..9f1666e
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_option_lzop.c
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2012 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_option_lzop)
+{
+ char *p;
+ int r;
+ size_t s;
+
+ /* Create a file. */
+ assertMakeFile("f", 0644, "a");
+
+ /* Archive it with lzop compression. */
+ r = systemf("echo f | %s -o --lzop >archive.out 2>archive.err",
+ testprog);
+ p = slurpfile(&s, "archive.err");
+ p[s] = '\0';
+ if (r != 0) {
+ if (!canLzop()) {
+ skipping("lzop is not supported on this platform");
+ return;
+ }
+ failure("--lzop option is broken");
+ assertEqualInt(r, 0);
+ return;
+ }
+ /* Check that the archive file has an lzma signature. */
+ p = slurpfile(&s, "archive.out");
+ assert(s > 2);
+ assertEqualMem(p, "\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a", 9);
+}
diff --git a/contrib/libarchive/cpio/test/test_option_uuencode.c b/contrib/libarchive/cpio/test/test_option_uuencode.c
new file mode 100644
index 0000000..ecf354f
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_option_uuencode.c
@@ -0,0 +1,54 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2012 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_option_uuencode)
+{
+ char *p;
+ size_t s;
+
+ /* Create a file. */
+ assertMakeFile("f", 0644, "a");
+
+ /* Archive it with compress compression and uuencode. */
+ assertEqualInt(0,
+ systemf("echo f | %s -o -Z --uuencode >archive.out 2>archive.err",
+ testprog));
+ /* Check that the archive file has an uuencode signature. */
+ p = slurpfile(&s, "archive.out");
+ assert(s > 2);
+ assertEqualMem(p, "begin 644", 9);
+
+ /* Archive it with uuencode only. */
+ assertEqualInt(0,
+ systemf("echo f | %s -o --uuencode >archive.out 2>archive.err",
+ testprog));
+ /* Check that the archive file has an uuencode signature. */
+ p = slurpfile(&s, "archive.out");
+ assert(s > 2);
+ assertEqualMem(p, "begin 644", 9);
+}
diff --git a/contrib/libarchive/cpio/test/test_option_xz.c b/contrib/libarchive/cpio/test/test_option_xz.c
new file mode 100644
index 0000000..02b5dfa
--- /dev/null
+++ b/contrib/libarchive/cpio/test/test_option_xz.c
@@ -0,0 +1,57 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2012 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_option_xz)
+{
+ char *p;
+ int r;
+ size_t s;
+
+ /* Create a file. */
+ assertMakeFile("f", 0644, "a");
+
+ /* Archive it with xz compression. */
+ r = systemf("echo f | %s -o --xz >archive.out 2>archive.err",
+ testprog);
+ p = slurpfile(&s, "archive.err");
+ p[s] = '\0';
+ if (r != 0) {
+ if (strstr(p, "compression not available") != NULL) {
+ skipping("This version of bsdcpio was compiled "
+ "without xz support");
+ return;
+ }
+ failure("--xz option is broken");
+ assertEqualInt(r, 0);
+ return;
+ }
+ /* Check that the archive file has an xz signature. */
+ p = slurpfile(&s, "archive.out");
+ assert(s > 2);
+ assertEqualMem(p, "\xFD\x37\x7A\x58\x5A\x00", 6);
+}
diff --git a/contrib/libarchive/cpio/test/test_option_y.c b/contrib/libarchive/cpio/test/test_option_y.c
index 8e81ee7..b509f18 100644
--- a/contrib/libarchive/cpio/test/test_option_y.c
+++ b/contrib/libarchive/cpio/test/test_option_y.c
@@ -40,9 +40,8 @@ DEFINE_TEST(test_option_y)
p = slurpfile(&s, "archive.err");
p[s] = '\0';
if (r != 0) {
- if (strstr(p, "compression not available") != NULL) {
- skipping("This version of bsdcpio was compiled "
- "without bzip2 support");
+ if (!canBzip2()) {
+ skipping("bzip2 is not supported on this platform");
return;
}
failure("-y option is broken");
diff --git a/contrib/libarchive/cpio/test/test_option_z.c b/contrib/libarchive/cpio/test/test_option_z.c
index 91d37ac..0b68a42 100644
--- a/contrib/libarchive/cpio/test/test_option_z.c
+++ b/contrib/libarchive/cpio/test/test_option_z.c
@@ -40,9 +40,8 @@ DEFINE_TEST(test_option_z)
p = slurpfile(&s, "archive.err");
p[s] = '\0';
if (r != 0) {
- if (strstr(p, "compression not available") != NULL) {
- skipping("This version of bsdcpio was compiled "
- "without gzip support");
+ if (!canGzip()) {
+ skipping("gzip is not supported on this platform");
return;
}
failure("-z option is broken");
OpenPOWER on IntegriCloud