test_write_format_zip_compression_store.c revision 299425
1299425Smm/*- 2299425Smm * Copyright (c) 2008 Anselm Strauss 3299425Smm * All rights reserved. 4299425Smm * 5299425Smm * Redistribution and use in source and binary forms, with or without 6299425Smm * modification, are permitted provided that the following conditions 7299425Smm * are met: 8299425Smm * 1. Redistributions of source code must retain the above copyright 9299425Smm * notice, this list of conditions and the following disclaimer. 10299425Smm * 2. Redistributions in binary form must reproduce the above copyright 11299425Smm * notice, this list of conditions and the following disclaimer in the 12299425Smm * documentation and/or other materials provided with the distribution. 13299425Smm * 14299425Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15299425Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16299425Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17299425Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18299425Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19299425Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20299425Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21299425Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22299425Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23299425Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24299425Smm */ 25299425Smm 26299425Smm/* 27299425Smm * Development supported by Google Summer of Code 2008. 28299425Smm */ 29299425Smm 30299425Smm#include "test.h" 31299425Smm__FBSDID("$FreeBSD: vendor/libarchive/dist/libarchive/test/test_write_format_zip_compression_store.c 299425 2016-05-11 10:19:44Z mm $"); 32299425Smm 33299425Smm/* File data */ 34299425Smmstatic const char file_name[] = "file"; 35299425Smmstatic const char file_data1[] = {'1', '2', '3', '4', '5'}; 36299425Smmstatic const char file_data2[] = {'6', '7', '8', '9', '0'}; 37299425Smmstatic const int file_perm = 00644; 38299425Smmstatic const short file_uid = 10; 39299425Smmstatic const short file_gid = 20; 40299425Smm 41299425Smm/* Folder data */ 42299425Smmstatic const char folder_name[] = "folder/"; 43299425Smmstatic const int folder_perm = 00755; 44299425Smmstatic const short folder_uid = 30; 45299425Smmstatic const short folder_gid = 40; 46299425Smm 47299425Smmstatic time_t now; 48299425Smm 49299425Smmstatic unsigned long 50299425Smmbitcrc32(unsigned long c, const void *_p, size_t s) 51299425Smm{ 52299425Smm /* This is a drop-in replacement for crc32() from zlib. 53299425Smm * Libarchive should be able to correctly generate 54299425Smm * uncompressed zip archives (including correct CRCs) even 55299425Smm * when zlib is unavailable, and this function helps us verify 56299425Smm * that. Yes, this is very, very slow and unsuitable for 57299425Smm * production use, but it's correct, compact, and works well 58299425Smm * enough for this particular usage. Libarchive internally 59299425Smm * uses a much more efficient implementation. */ 60299425Smm const unsigned char *p = _p; 61299425Smm int bitctr; 62299425Smm 63299425Smm if (p == NULL) 64299425Smm return (0); 65299425Smm 66299425Smm for (; s > 0; --s) { 67299425Smm c ^= *p++; 68299425Smm for (bitctr = 8; bitctr > 0; --bitctr) { 69299425Smm if (c & 1) c = (c >> 1); 70299425Smm else c = (c >> 1) ^ 0xedb88320; 71299425Smm c ^= 0x80000000; 72299425Smm } 73299425Smm } 74299425Smm return (c); 75299425Smm} 76299425Smm 77299425Smmstatic void verify_write_uncompressed(struct archive *a) 78299425Smm{ 79299425Smm struct archive_entry *entry; 80299425Smm 81299425Smm /* Write entries. */ 82299425Smm 83299425Smm /* Regular file */ 84299425Smm assert((entry = archive_entry_new()) != NULL); 85299425Smm archive_entry_set_pathname(entry, file_name); 86299425Smm archive_entry_set_mode(entry, S_IFREG | 0644); 87299425Smm archive_entry_set_size(entry, sizeof(file_data1) + sizeof(file_data2)); 88299425Smm archive_entry_set_uid(entry, file_uid); 89299425Smm archive_entry_set_gid(entry, file_gid); 90299425Smm archive_entry_set_mtime(entry, now, 0); 91299425Smm archive_entry_set_atime(entry, now + 3, 0); 92299425Smm assertEqualIntA(a, 0, archive_write_header(a, entry)); 93299425Smm assertEqualIntA(a, sizeof(file_data1), archive_write_data(a, file_data1, sizeof(file_data1))); 94299425Smm assertEqualIntA(a, sizeof(file_data2), archive_write_data(a, file_data2, sizeof(file_data2))); 95299425Smm archive_entry_free(entry); 96299425Smm 97299425Smm /* Folder */ 98299425Smm assert((entry = archive_entry_new()) != NULL); 99299425Smm archive_entry_set_pathname(entry, folder_name); 100299425Smm archive_entry_set_mode(entry, S_IFDIR | folder_perm); 101299425Smm archive_entry_set_size(entry, 0); 102299425Smm archive_entry_set_uid(entry, folder_uid); 103299425Smm archive_entry_set_gid(entry, folder_gid); 104299425Smm archive_entry_set_mtime(entry, now, 0); 105299425Smm archive_entry_set_ctime(entry, now + 5, 0); 106299425Smm assertEqualIntA(a, 0, archive_write_header(a, entry)); 107299425Smm archive_entry_free(entry); 108299425Smm} 109299425Smm 110299425Smm/* Quick and dirty: Read 2-byte and 4-byte integers from Zip file. */ 111299425Smmstatic int i2(const char *p) { return ((p[0] & 0xff) | ((p[1] & 0xff) << 8)); } 112299425Smmstatic int i4(const char *p) { return (i2(p) | (i2(p + 2) << 16)); } 113299425Smm 114299425Smmstatic void verify_uncompressed_contents(const char *buff, size_t used) 115299425Smm{ 116299425Smm const char *buffend; 117299425Smm 118299425Smm /* Misc variables */ 119299425Smm unsigned long crc; 120299425Smm struct tm *tm = localtime(&now); 121299425Smm 122299425Smm /* p is the pointer to walk over the central directory, 123299425Smm * q walks over the local headers, the data and the data descriptors. */ 124299425Smm const char *p, *q, *local_header, *extra_start; 125299425Smm 126299425Smm /* Remember the end of the archive in memory. */ 127299425Smm buffend = buff + used; 128299425Smm 129299425Smm /* Verify "End of Central Directory" record. */ 130299425Smm /* Get address of end-of-central-directory record. */ 131299425Smm p = buffend - 22; /* Assumes there is no zip comment field. */ 132299425Smm failure("End-of-central-directory begins with PK\\005\\006 signature"); 133299425Smm assertEqualMem(p, "PK\005\006", 4); 134299425Smm failure("This must be disk 0"); 135299425Smm assertEqualInt(i2(p + 4), 0); 136299425Smm failure("Central dir must start on disk 0"); 137299425Smm assertEqualInt(i2(p + 6), 0); 138299425Smm failure("All central dir entries are on this disk"); 139299425Smm assertEqualInt(i2(p + 8), i2(p + 10)); 140299425Smm failure("CD start (%d) + CD length (%d) should == archive size - 22", 141299425Smm i4(p + 12), i4(p + 16)); 142299425Smm assertEqualInt(i4(p + 12) + i4(p + 16), used - 22); 143299425Smm failure("no zip comment"); 144299425Smm assertEqualInt(i2(p + 20), 0); 145299425Smm 146299425Smm /* Get address of first entry in central directory. */ 147299425Smm p = buff + i4(buffend - 6); 148299425Smm failure("Central file record at offset %d should begin with" 149299425Smm " PK\\001\\002 signature", 150299425Smm i4(buffend - 10)); 151299425Smm 152299425Smm /* Verify file entry in central directory. */ 153299425Smm assertEqualMem(p, "PK\001\002", 4); /* Signature */ 154299425Smm assertEqualInt(i2(p + 4), 3 * 256 + 10); /* Version made by */ 155299425Smm assertEqualInt(i2(p + 6), 10); /* Version needed to extract */ 156299425Smm assertEqualInt(i2(p + 8), 8); /* Flags */ 157299425Smm assertEqualInt(i2(p + 10), 0); /* Compression method */ 158299425Smm assertEqualInt(i2(p + 12), (tm->tm_hour * 2048) + (tm->tm_min * 32) + (tm->tm_sec / 2)); /* File time */ 159299425Smm assertEqualInt(i2(p + 14), ((tm->tm_year - 80) * 512) + ((tm->tm_mon + 1) * 32) + tm->tm_mday); /* File date */ 160299425Smm crc = bitcrc32(0, file_data1, sizeof(file_data1)); 161299425Smm crc = bitcrc32(crc, file_data2, sizeof(file_data2)); 162299425Smm assertEqualInt(i4(p + 16), crc); /* CRC-32 */ 163299425Smm assertEqualInt(i4(p + 20), sizeof(file_data1) + sizeof(file_data2)); /* Compressed size */ 164299425Smm assertEqualInt(i4(p + 24), sizeof(file_data1) + sizeof(file_data2)); /* Uncompressed size */ 165299425Smm assertEqualInt(i2(p + 28), strlen(file_name)); /* Pathname length */ 166299425Smm assertEqualInt(i2(p + 30), 28); /* Extra field length */ 167299425Smm assertEqualInt(i2(p + 32), 0); /* File comment length */ 168299425Smm assertEqualInt(i2(p + 34), 0); /* Disk number start */ 169299425Smm assertEqualInt(i2(p + 36), 0); /* Internal file attrs */ 170299425Smm assertEqualInt(i4(p + 38) >> 16 & 01777, file_perm); /* External file attrs */ 171299425Smm assertEqualInt(i4(p + 42), 0); /* Offset of local header */ 172299425Smm assertEqualMem(p + 46, file_name, strlen(file_name)); /* Pathname */ 173299425Smm p = p + 46 + strlen(file_name); 174299425Smm assertEqualInt(i2(p), 0x5455); /* 'UT' extension header */ 175299425Smm assertEqualInt(i2(p + 2), 9); /* 'UT' size */ 176299425Smm assertEqualInt(p[4], 3); /* 'UT' flags */ 177299425Smm assertEqualInt(i4(p + 5), now); /* 'UT' mtime */ 178299425Smm assertEqualInt(i4(p + 9), now + 3); /* 'UT' atime */ 179299425Smm p = p + 4 + i2(p + 2); 180299425Smm assertEqualInt(i2(p), 0x7875); /* 'ux' extension header */ 181299425Smm assertEqualInt(i2(p + 2), 11); /* 'ux' size */ 182299425Smm/* TODO */ 183299425Smm p = p + 4 + i2(p + 2); 184299425Smm 185299425Smm /* Verify local header of file entry. */ 186299425Smm local_header = q = buff; 187299425Smm assertEqualMem(q, "PK\003\004", 4); /* Signature */ 188299425Smm assertEqualInt(i2(q + 4), 10); /* Version needed to extract */ 189299425Smm assertEqualInt(i2(q + 6), 8); /* Flags */ 190299425Smm assertEqualInt(i2(q + 8), 0); /* Compression method */ 191299425Smm assertEqualInt(i2(q + 10), (tm->tm_hour * 2048) + (tm->tm_min * 32) + (tm->tm_sec / 2)); /* File time */ 192299425Smm assertEqualInt(i2(q + 12), ((tm->tm_year - 80) * 512) + ((tm->tm_mon + 1) * 32) + tm->tm_mday); /* File date */ 193299425Smm assertEqualInt(i4(q + 14), 0); /* CRC-32 */ 194299425Smm assertEqualInt(i4(q + 18), sizeof(file_data1) + sizeof(file_data2)); /* Compressed size */ 195299425Smm assertEqualInt(i4(q + 22), sizeof(file_data1) + sizeof(file_data2)); /* Uncompressed size */ 196299425Smm assertEqualInt(i2(q + 26), strlen(file_name)); /* Pathname length */ 197299425Smm assertEqualInt(i2(q + 28), 41); /* Extra field length */ 198299425Smm assertEqualMem(q + 30, file_name, strlen(file_name)); /* Pathname */ 199299425Smm extra_start = q = q + 30 + strlen(file_name); 200299425Smm assertEqualInt(i2(q), 0x5455); /* 'UT' extension header */ 201299425Smm assertEqualInt(i2(q + 2), 9); /* 'UT' size */ 202299425Smm assertEqualInt(q[4], 3); /* 'UT' flags */ 203299425Smm assertEqualInt(i4(q + 5), now); /* 'UT' mtime */ 204299425Smm assertEqualInt(i4(q + 9), now + 3); /* 'UT' atime */ 205299425Smm q = q + 4 + i2(q + 2); 206299425Smm 207299425Smm assertEqualInt(i2(q), 0x7875); /* 'ux' extension header */ 208299425Smm assertEqualInt(i2(q + 2), 11); /* 'ux' size */ 209299425Smm assertEqualInt(q[4], 1); /* 'ux' version */ 210299425Smm assertEqualInt(q[5], 4); /* 'ux' uid size */ 211299425Smm assertEqualInt(i4(q + 6), file_uid); /* 'Ux' UID */ 212299425Smm assertEqualInt(q[10], 4); /* 'ux' gid size */ 213299425Smm assertEqualInt(i4(q + 11), file_gid); /* 'Ux' GID */ 214299425Smm q = q + 4 + i2(q + 2); 215299425Smm 216299425Smm assertEqualInt(i2(q), 0x6c78); /* 'xl' experimental extension header */ 217299425Smm assertEqualInt(i2(q + 2), 9); /* size */ 218299425Smm assertEqualInt(q[4], 7); /* Bitmap of fields included. */ 219299425Smm assertEqualInt(i2(q + 5) >> 8, 3); /* system & version made by */ 220299425Smm assertEqualInt(i2(q + 7), 0); /* internal file attributes */ 221299425Smm assertEqualInt(i4(q + 9) >> 16 & 01777, file_perm); /* external file attributes */ 222299425Smm q = q + 4 + i2(q + 2); 223299425Smm 224299425Smm assert(q == extra_start + i2(local_header + 28)); 225299425Smm q = extra_start + i2(local_header + 28); 226299425Smm 227299425Smm /* Verify data of file entry. */ 228299425Smm assertEqualMem(q, file_data1, sizeof(file_data1)); 229299425Smm assertEqualMem(q + sizeof(file_data1), file_data2, sizeof(file_data2)); 230299425Smm q = q + sizeof(file_data1) + sizeof(file_data2); 231299425Smm 232299425Smm /* Verify data descriptor of file entry. */ 233299425Smm assertEqualMem(q, "PK\007\010", 4); /* Signature */ 234299425Smm assertEqualInt(i4(q + 4), crc); /* CRC-32 */ 235299425Smm assertEqualInt(i4(q + 8), sizeof(file_data1) + sizeof(file_data2)); /* Compressed size */ 236299425Smm assertEqualInt(i4(q + 12), sizeof(file_data1) + sizeof(file_data2)); /* Uncompressed size */ 237299425Smm q = q + 16; 238299425Smm 239299425Smm /* Verify folder entry in central directory. */ 240299425Smm assertEqualMem(p, "PK\001\002", 4); /* Signature */ 241299425Smm assertEqualInt(i2(p + 4), 3 * 256 + 20); /* Version made by */ 242299425Smm assertEqualInt(i2(p + 6), 20); /* Version needed to extract */ 243299425Smm assertEqualInt(i2(p + 8), 0); /* Flags */ 244299425Smm assertEqualInt(i2(p + 10), 0); /* Compression method */ 245299425Smm assertEqualInt(i2(p + 12), (tm->tm_hour * 2048) + (tm->tm_min * 32) + (tm->tm_sec / 2)); /* File time */ 246299425Smm assertEqualInt(i2(p + 14), ((tm->tm_year - 80) * 512) + ((tm->tm_mon + 1) * 32) + tm->tm_mday); /* File date */ 247299425Smm crc = 0; 248299425Smm assertEqualInt(i4(p + 16), crc); /* CRC-32 */ 249299425Smm assertEqualInt(i4(p + 20), 0); /* Compressed size */ 250299425Smm assertEqualInt(i4(p + 24), 0); /* Uncompressed size */ 251299425Smm assertEqualInt(i2(p + 28), strlen(folder_name)); /* Pathname length */ 252299425Smm assertEqualInt(i2(p + 30), 28); /* Extra field length */ 253299425Smm assertEqualInt(i2(p + 32), 0); /* File comment length */ 254299425Smm assertEqualInt(i2(p + 34), 0); /* Disk number start */ 255299425Smm assertEqualInt(i2(p + 36), 0); /* Internal file attrs */ 256299425Smm assertEqualInt(i4(p + 38) >> 16 & 01777, folder_perm); /* External file attrs */ 257299425Smm assertEqualInt(i4(p + 42), q - buff); /* Offset of local header */ 258299425Smm assertEqualMem(p + 46, folder_name, strlen(folder_name)); /* Pathname */ 259299425Smm p = p + 46 + strlen(folder_name); 260299425Smm assertEqualInt(i2(p), 0x5455); /* 'UT' extension header */ 261299425Smm assertEqualInt(i2(p + 2), 9); /* 'UT' size */ 262299425Smm assertEqualInt(p[4], 5); /* 'UT' flags */ 263299425Smm assertEqualInt(i4(p + 5), now); /* 'UT' mtime */ 264299425Smm assertEqualInt(i4(p + 9), now + 5); /* 'UT' atime */ 265299425Smm p = p + 4 + i2(p + 2); 266299425Smm assertEqualInt(i2(p), 0x7875); /* 'ux' extension header */ 267299425Smm assertEqualInt(i2(p + 2), 11); /* 'ux' size */ 268299425Smm assertEqualInt(p[4], 1); /* 'ux' version */ 269299425Smm assertEqualInt(p[5], 4); /* 'ux' uid size */ 270299425Smm assertEqualInt(i4(p + 6), folder_uid); /* 'ux' UID */ 271299425Smm assertEqualInt(p[10], 4); /* 'ux' gid size */ 272299425Smm assertEqualInt(i4(p + 11), folder_gid); /* 'ux' GID */ 273299425Smm /*p = p + 4 + i2(p + 2);*/ 274299425Smm 275299425Smm /* Verify local header of folder entry. */ 276299425Smm local_header = q; 277299425Smm assertEqualMem(q, "PK\003\004", 4); /* Signature */ 278299425Smm assertEqualInt(i2(q + 4), 20); /* Version needed to extract */ 279299425Smm assertEqualInt(i2(q + 6), 0); /* Flags */ 280299425Smm assertEqualInt(i2(q + 8), 0); /* Compression method */ 281299425Smm assertEqualInt(i2(q + 10), (tm->tm_hour * 2048) + (tm->tm_min * 32) + (tm->tm_sec / 2)); /* File time */ 282299425Smm assertEqualInt(i2(q + 12), ((tm->tm_year - 80) * 512) + ((tm->tm_mon + 1) * 32) + tm->tm_mday); /* File date */ 283299425Smm assertEqualInt(i4(q + 14), 0); /* CRC-32 */ 284299425Smm assertEqualInt(i4(q + 18), 0); /* Compressed size */ 285299425Smm assertEqualInt(i4(q + 22), 0); /* Uncompressed size */ 286299425Smm assertEqualInt(i2(q + 26), strlen(folder_name)); /* Pathname length */ 287299425Smm assertEqualInt(i2(q + 28), 41); /* Extra field length */ 288299425Smm assertEqualMem(q + 30, folder_name, strlen(folder_name)); /* Pathname */ 289299425Smm extra_start = q = q + 30 + strlen(folder_name); 290299425Smm assertEqualInt(i2(q), 0x5455); /* 'UT' extension header */ 291299425Smm assertEqualInt(i2(q + 2), 9); /* 'UT' size */ 292299425Smm assertEqualInt(q[4], 5); /* 'UT' flags */ 293299425Smm assertEqualInt(i4(q + 5), now); /* 'UT' mtime */ 294299425Smm assertEqualInt(i4(q + 9), now + 5); /* 'UT' atime */ 295299425Smm q = q + 4 + i2(q + 2); 296299425Smm assertEqualInt(i2(q), 0x7875); /* 'ux' extension header */ 297299425Smm assertEqualInt(i2(q + 2), 11); /* 'ux' size */ 298299425Smm assertEqualInt(q[4], 1); /* 'ux' version */ 299299425Smm assertEqualInt(q[5], 4); /* 'ux' uid size */ 300299425Smm assertEqualInt(i4(q + 6), folder_uid); /* 'ux' UID */ 301299425Smm assertEqualInt(q[10], 4); /* 'ux' gid size */ 302299425Smm assertEqualInt(i4(q + 11), folder_gid); /* 'ux' GID */ 303299425Smm q = q + 4 + i2(q + 2); 304299425Smm 305299425Smm assertEqualInt(i2(q), 0x6c78); /* 'xl' experimental extension header */ 306299425Smm assertEqualInt(i2(q + 2), 9); /* size */ 307299425Smm assertEqualInt(q[4], 7); /* bitmap of fields */ 308299425Smm assertEqualInt(i2(q + 5) >> 8, 3); /* system & version made by */ 309299425Smm assertEqualInt(i2(q + 7), 0); /* internal file attributes */ 310299425Smm assertEqualInt(i4(q + 9) >> 16 & 01777, folder_perm); /* external file attributes */ 311299425Smm q = q + 4 + i2(q + 2); 312299425Smm 313299425Smm assert(q == extra_start + i2(local_header + 28)); 314299425Smm q = extra_start + i2(local_header + 28); 315299425Smm 316299425Smm /* There should not be any data in the folder entry, 317299425Smm * so the first central directory entry should be next: */ 318299425Smm assertEqualMem(q, "PK\001\002", 4); /* Signature */ 319299425Smm} 320299425Smm 321299425SmmDEFINE_TEST(test_write_format_zip_compression_store) 322299425Smm{ 323299425Smm /* Buffer data */ 324299425Smm struct archive *a; 325299425Smm char buff[100000]; 326299425Smm size_t used; 327299425Smm 328299425Smm /* Time data */ 329299425Smm now = time(NULL); 330299425Smm 331299425Smm /* Create new ZIP archive in memory without padding. */ 332299425Smm /* Use compression=store to disable compression. */ 333299425Smm assert((a = archive_write_new()) != NULL); 334299425Smm assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_zip(a)); 335299425Smm assertEqualIntA(a, ARCHIVE_OK, 336299425Smm archive_write_set_options(a, "zip:compression=store")); 337299425Smm assertEqualIntA(a, ARCHIVE_OK, 338299425Smm archive_write_set_options(a, "zip:experimental")); 339299425Smm assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_none(a)); 340299425Smm assertEqualIntA(a, ARCHIVE_OK, archive_write_set_bytes_per_block(a, 1)); 341299425Smm assertEqualIntA(a, ARCHIVE_OK, archive_write_set_bytes_in_last_block(a, 1)); 342299425Smm assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, sizeof(buff), &used)); 343299425Smm 344299425Smm verify_write_uncompressed(a); 345299425Smm 346299425Smm /* Close the archive . */ 347299425Smm assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a)); 348299425Smm assertEqualInt(ARCHIVE_OK, archive_write_free(a)); 349299425Smm dumpfile("constructed.zip", buff, used); 350299425Smm 351299425Smm verify_uncompressed_contents(buff, used); 352299425Smm 353299425Smm /* Create new ZIP archive in memory without padding. */ 354299425Smm /* Use compression-level=0 to disable compression. */ 355299425Smm assert((a = archive_write_new()) != NULL); 356299425Smm assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_zip(a)); 357299425Smm assertEqualIntA(a, ARCHIVE_OK, 358299425Smm archive_write_set_options(a, "zip:compression-level=0")); 359299425Smm assertEqualIntA(a, ARCHIVE_OK, 360299425Smm archive_write_set_options(a, "zip:experimental")); 361299425Smm assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_none(a)); 362299425Smm assertEqualIntA(a, ARCHIVE_OK, archive_write_set_bytes_per_block(a, 1)); 363299425Smm assertEqualIntA(a, ARCHIVE_OK, archive_write_set_bytes_in_last_block(a, 1)); 364299425Smm assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, sizeof(buff), &used)); 365299425Smm 366299425Smm verify_write_uncompressed(a); 367299425Smm 368299425Smm /* Close the archive . */ 369299425Smm assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a)); 370299425Smm assertEqualInt(ARCHIVE_OK, archive_write_free(a)); 371299425Smm dumpfile("constructed.zip", buff, used); 372299425Smm 373299425Smm verify_uncompressed_contents(buff, used); 374299425Smm 375299425Smm} 376