summaryrefslogtreecommitdiff
path: root/libarchive/test
diff options
context:
space:
mode:
authorMartin Matuska <mm@FreeBSD.org>2018-11-24 01:15:08 +0000
committerMartin Matuska <mm@FreeBSD.org>2018-11-24 01:15:08 +0000
commitfd2a102f7ba73f37fbac1c994086b23f438cbf13 (patch)
tree839a0814bd5fe79181ad1d0544f840fee2b9968b /libarchive/test
parenta26007e8d35293595dadaee72d00911741d111ed (diff)
downloadsrc-test2-fd2a102f7ba73f37fbac1c994086b23f438cbf13.tar.gz
src-test2-fd2a102f7ba73f37fbac1c994086b23f438cbf13.zip
Notes
Diffstat (limited to 'libarchive/test')
-rw-r--r--libarchive/test/test_fuzz.c2
-rw-r--r--libarchive/test/test_read_format_rar5.c41
-rw-r--r--libarchive/test/test_write_disk_perms.c2
3 files changed, 43 insertions, 2 deletions
diff --git a/libarchive/test/test_fuzz.c b/libarchive/test/test_fuzz.c
index 42351450b265..2025834ca424 100644
--- a/libarchive/test/test_fuzz.c
+++ b/libarchive/test/test_fuzz.c
@@ -433,7 +433,7 @@ DEFINE_TEST(test_fuzz_tar)
{0, fileset9}, /* Exercise lzo decompressor. */
#endif
#if HAVE_ZSTD_H && HAVE_LIBZSTD
- {0, fileset10}, /* Excercise zstd decompressor. */
+ {0, fileset10}, /* Exercise zstd decompressor. */
#endif
{1, NULL}
};
diff --git a/libarchive/test/test_read_format_rar5.c b/libarchive/test/test_read_format_rar5.c
index 2196123ddbc5..6c570f1c6643 100644
--- a/libarchive/test/test_read_format_rar5.c
+++ b/libarchive/test/test_read_format_rar5.c
@@ -726,3 +726,44 @@ DEFINE_TEST(test_read_format_rar5_extract_win32)
assertA(0 == extract_one(a, ae, 0x36A448FF));
EPILOGUE();
}
+
+DEFINE_TEST(test_read_format_rar5_block_by_block)
+{
+ /* This test uses strange buffer sizes intentionally. */
+
+ struct archive_entry *ae;
+ struct archive *a;
+ uint8_t buf[173];
+ int bytes_read;
+ uint32_t computed_crc = 0;
+
+ extract_reference_file("test_read_format_rar5_compressed.rar");
+ assert((a = archive_read_new()) != NULL);
+ assertA(0 == archive_read_support_filter_all(a));
+ assertA(0 == archive_read_support_format_all(a));
+ assertA(0 == archive_read_open_filename(a, "test_read_format_rar5_compressed.rar", 130));
+ assertA(0 == archive_read_next_header(a, &ae));
+ assertEqualString("test.bin", archive_entry_pathname(ae));
+ assertEqualInt(1200, archive_entry_size(ae));
+
+ /* File size is 1200 bytes, we're reading it using a buffer of 173 bytes.
+ * Libarchive is configured to use a buffer of 130 bytes. */
+
+ while(1) {
+ /* archive_read_data should return one of:
+ * a) 0, if there is no more data to be read,
+ * b) negative value, if there was an error,
+ * c) positive value, meaning how many bytes were read.
+ */
+
+ bytes_read = archive_read_data(a, buf, sizeof(buf));
+ assertA(bytes_read >= 0);
+ if(bytes_read <= 0)
+ break;
+
+ computed_crc = crc32(computed_crc, buf, bytes_read);
+ }
+
+ assertEqualInt(computed_crc, 0x7CCA70CD);
+ EPILOGUE();
+}
diff --git a/libarchive/test/test_write_disk_perms.c b/libarchive/test/test_write_disk_perms.c
index 8205d6abc59a..81f8b1209ce1 100644
--- a/libarchive/test/test_write_disk_perms.c
+++ b/libarchive/test/test_write_disk_perms.c
@@ -203,7 +203,7 @@ DEFINE_TEST(test_write_disk_perms)
failure("dir_overwrite_0744: st.st_mode=%o", st.st_mode);
assertEqualInt(st.st_mode & 0777, 0744);
- /* For dir, the owner should get left when not overwritting. */
+ /* For dir, the owner should get left when not overwriting. */
assertMakeDir("dir_owner", 0744);
if (getuid() == 0) {