xref: /freebsd/contrib/libarchive/libarchive/test/test_write_format_zip_compression_lzmaxz.c (revision 2e113ef82465598b8c26e0ca415fbe90677fbd47)
1 /*-SPDX-License-Identifier: BSD-2-Clause
2  * Copyright (c) 2024 ARJANEN Loïc Jean David
3  * All rights reserved.
4  */
5 
6 #include "test.h"
7 #ifdef HAVE_LZMA_H
8 #include <lzma.h>
9 
10 /* File data */
11 static const char file_name[] = "file";
12 static const char file_data1[] = {'.', ';', ':', '!', '?', ',', '"', '\'', ')', '(', '*'};
13 static const char file_data2[] = {'-', '/', '>', '$', '\\', '#', '@', '+', '=', '{', ']', '[', '}', '&', '<', '%'};
14 static const int file_perm = 00644;
15 static const short file_uid = 10;
16 static const short file_gid = 20;
17 
18 /* Folder data */
19 static const char folder_name[] = "folder/";
20 static const int folder_perm = 00755;
21 static const short folder_uid = 30;
22 static const short folder_gid = 40;
23 
24 static time_t now;
25 
verify_write_lzma(struct archive * a)26 static void verify_write_lzma(struct archive *a)
27 {
28 	struct archive_entry *entry;
29 
30 	/* Write entries. */
31 
32 	/* Regular file */
33 	assert((entry = archive_entry_new()) != NULL);
34 	archive_entry_set_pathname(entry, file_name);
35 	archive_entry_set_mode(entry, S_IFREG | 0644);
36 	archive_entry_set_size(entry, sizeof(file_data1) + sizeof(file_data2));
37 	archive_entry_set_uid(entry, file_uid);
38 	archive_entry_set_gid(entry, file_gid);
39 	archive_entry_set_mtime(entry, now, 0);
40 	archive_entry_set_atime(entry, now + 3, 0);
41 	assertEqualIntA(a, 0, archive_write_header(a, entry));
42 	assertEqualIntA(a, sizeof(file_data1), archive_write_data(a, file_data1, sizeof(file_data1)));
43 	assertEqualIntA(a, sizeof(file_data2), archive_write_data(a, file_data2, sizeof(file_data2)));
44 	archive_entry_free(entry);
45 
46 	/* Folder */
47 	assert((entry = archive_entry_new()) != NULL);
48 	archive_entry_set_pathname(entry, folder_name);
49 	archive_entry_set_mode(entry, S_IFDIR | folder_perm);
50 	archive_entry_set_size(entry, 0);
51 	archive_entry_set_uid(entry, folder_uid);
52 	archive_entry_set_gid(entry, folder_gid);
53 	archive_entry_set_mtime(entry, now, 0);
54 	archive_entry_set_ctime(entry, now + 5, 0);
55 	assertEqualIntA(a, 0, archive_write_header(a, entry));
56 	archive_entry_free(entry);
57 }
58 
verify_xz_lzma(const char * buff,size_t used,uint16_t id,uint16_t flags)59 static void verify_xz_lzma(const char *buff, size_t used, uint16_t id,
60 	uint16_t flags)
61 {
62 	const char *buffend;
63 	struct archive* zip_archive;
64 	struct archive_entry *ae;
65 	char filedata[sizeof(file_data1) + sizeof(file_data2)];
66 	/* Misc variables */
67 	unsigned long crc;
68 	struct tm *tm;
69 #if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S)
70 	struct tm tmbuf;
71 #endif
72 	/* p is the pointer to walk over the central directory,
73 	 * q walks over the local headers, the data and the data descriptors. */
74 	const char *p, *q, *local_header, *extra_start;
75 
76 #if defined(HAVE_LOCALTIME_S)
77 	tm = localtime_s(&tmbuf, &now) ? NULL : &tmbuf;
78 #elif defined(HAVE_LOCALTIME_R)
79 	tm = localtime_r(&now, &tmbuf);
80 #else
81 	tm = localtime(&now);
82 #endif
83 
84 	/* Open archive from memory, we'll need it for checking the file
85 	 * value */
86 	assert((zip_archive = archive_read_new()) != NULL);
87 	assertEqualIntA(zip_archive, ARCHIVE_OK, archive_read_support_format_all(zip_archive));
88 	assertEqualIntA(zip_archive, ARCHIVE_OK, archive_read_support_filter_all(zip_archive));
89 	assertEqualIntA(zip_archive, ARCHIVE_OK, archive_read_open_memory(zip_archive, buff, used));
90 
91 	/* Remember the end of the archive in memory. */
92 	buffend = buff + used;
93 
94 	/* Verify "End of Central Directory" record. */
95 	/* Get address of end-of-central-directory record. */
96 	p = buffend - 22; /* Assumes there is no zip comment field. */
97 	failure("End-of-central-directory begins with PK\\005\\006 signature");
98 	assertEqualMem(p, "PK\005\006", 4);
99 	failure("This must be disk 0");
100 	assertEqualInt(i2le(p + 4), 0);
101 	failure("Central dir must start on disk 0");
102 	assertEqualInt(i2le(p + 6), 0);
103 	failure("All central dir entries are on this disk");
104 	assertEqualInt(i2le(p + 8), i2le(p + 10));
105 	failure("CD start (%u) + CD length (%u) should == archive size - 22",
106 	    i4le(p + 12), i4le(p + 16));
107 	assertEqualInt(i4le(p + 12) + i4le(p + 16), used - 22);
108 	failure("no zip comment");
109 	assertEqualInt(i2le(p + 20), 0);
110 
111 	/* Get address of first entry in central directory. */
112 	p = buff + i4le(buffend - 6);
113 	failure("Central file record at offset %u should begin with"
114 	    " PK\\001\\002 signature",
115 	    i4le(buffend - 10));
116 
117 	/* Verify file entry in central directory, except compressed size (offset 20). */
118 	assertEqualMem(p, "PK\001\002", 4); /* Signature */
119 	assertEqualInt(i2le(p + 4), 3 * 256 + 63); /* Version made by */
120 	assertEqualInt(i2le(p + 6), 63); /* Version needed to extract */
121 	assertEqualInt(i2le(p + 8), flags); /* Flags */
122 	assertEqualInt(i2le(p + 10), id); /* Compression method */
123 	assertEqualInt(i2le(p + 12), (tm->tm_hour * 2048) + (tm->tm_min * 32) + (tm->tm_sec / 2)); /* File time */
124 	assertEqualInt(i2le(p + 14), ((tm->tm_year - 80) * 512) + ((tm->tm_mon + 1) * 32) + tm->tm_mday); /* File date */
125 	crc = bitcrc32(0, file_data1, sizeof(file_data1));
126 	crc = bitcrc32(crc, file_data2, sizeof(file_data2));
127 	assertEqualInt(i4le(p + 16), crc); /* CRC-32 */
128 	assertEqualInt(i4le(p + 24), sizeof(file_data1) + sizeof(file_data2)); /* Uncompressed size */
129 	assertEqualInt(i2le(p + 28), strlen(file_name)); /* Pathname length */
130 	assertEqualInt(i2le(p + 30), 24); /* Extra field length */
131 	assertEqualInt(i2le(p + 32), 0); /* File comment length */
132 	assertEqualInt(i2le(p + 34), 0); /* Disk number start */
133 	assertEqualInt(i2le(p + 36), 0); /* Internal file attrs */
134 	assertEqualInt(i4le(p + 38) >> 16 & 01777, file_perm); /* External file attrs */
135 	assertEqualInt(i4le(p + 42), 0); /* Offset of local header */
136 	assertEqualMem(p + 46, file_name, strlen(file_name)); /* Pathname */
137 	p = p + 46 + strlen(file_name);
138 
139 	assertEqualInt(i2le(p), 0x7875); /* 'ux' extension header */
140 	assertEqualInt(i2le(p + 2), 11); /* 'ux' size */
141 /* TODO */
142 	p = p + 4 + i2le(p + 2);
143 
144 	assertEqualInt(i2le(p), 0x5455); /* 'UT' extension header */
145 	assertEqualInt(i2le(p + 2), 5); /* 'UT' size */
146 	assertEqualInt(p[4], 1); /* 'UT' flags */
147 	assertEqualInt(i4le(p + 5), now); /* 'UT' mtime */
148 	p = p + 4 + i2le(p + 2);
149 
150 	/* Verify local header of file entry. */
151 	local_header = q = buff;
152 	assertEqualMem(q, "PK\003\004", 4); /* Signature */
153 	assertEqualInt(i2le(q + 4), 63); /* Version needed to extract */
154 	assertEqualInt(i2le(q + 6), flags); /* Flags: bit 3 = length-at-end (required because CRC32 is unknown) and bit 1 = EOPM (because we always write it) */
155 	assertEqualInt(i2le(q + 8), id); /* Compression method */
156 	assertEqualInt(i2le(q + 10), (tm->tm_hour * 2048) + (tm->tm_min * 32) + (tm->tm_sec / 2)); /* File time */
157 	assertEqualInt(i2le(q + 12), ((tm->tm_year - 80) * 512) + ((tm->tm_mon + 1) * 32) + tm->tm_mday); /* File date */
158 	assertEqualInt(i4le(q + 14), 0); /* CRC-32 */
159 	assertEqualInt(i4le(q + 18), 0); /* Compressed size, must be zero because of length-at-end */
160 	assertEqualInt(i4le(q + 22), 0); /* Uncompressed size, must be zero because of length-at-end */
161 	assertEqualInt(i2le(q + 26), strlen(file_name)); /* Pathname length */
162 	assertEqualInt(i2le(q + 28), 41); /* Extra field length */
163 	assertEqualMem(q + 30, file_name, strlen(file_name)); /* Pathname */
164 	extra_start = q = q + 30 + strlen(file_name);
165 
166 	assertEqualInt(i2le(q), 0x7875); /* 'ux' extension header */
167 	assertEqualInt(i2le(q + 2), 11); /* 'ux' size */
168 	assertEqualInt(q[4], 1); /* 'ux' version */
169 	assertEqualInt(q[5], 4); /* 'ux' uid size */
170 	assertEqualInt(i4le(q + 6), file_uid); /* 'Ux' UID */
171 	assertEqualInt(q[10], 4); /* 'ux' gid size */
172 	assertEqualInt(i4le(q + 11), file_gid); /* 'Ux' GID */
173 	q = q + 4 + i2le(q + 2);
174 
175 	assertEqualInt(i2le(q), 0x5455); /* 'UT' extension header */
176 	assertEqualInt(i2le(q + 2), 9); /* 'UT' size */
177 	assertEqualInt(q[4], 3); /* 'UT' flags */
178 	assertEqualInt(i4le(q + 5), now); /* 'UT' mtime */
179 	assertEqualInt(i4le(q + 9), now + 3); /* 'UT' atime */
180 	q = q + 4 + i2le(q + 2);
181 
182 	assertEqualInt(i2le(q), 0x6c78); /* 'xl' experimental extension header */
183 	assertEqualInt(i2le(q + 2), 9); /* size */
184 	assertEqualInt(q[4], 7); /* Bitmap of fields included. */
185 	assertEqualInt(i2le(q + 5) >> 8, 3); /* system & version made by */
186 	assertEqualInt(i2le(q + 7), 0); /* internal file attributes */
187 	assertEqualInt(i4le(q + 9) >> 16 & 01777, file_perm); /* external file attributes */
188 	q = q + 4 + i2le(q + 2);
189 
190 	assert(q == extra_start + i2le(local_header + 28));
191 	q = extra_start + i2le(local_header + 28);
192 
193 	/* Verify data of file entry, using our own zip reader to test. */
194 	assertEqualIntA(zip_archive, ARCHIVE_OK, archive_read_next_header(zip_archive, &ae));
195 	assertEqualString("file", archive_entry_pathname(ae));
196 	assertEqualIntA(zip_archive, sizeof(filedata), archive_read_data(zip_archive, filedata, sizeof(filedata)));
197 	assertEqualMem(filedata, file_data1, sizeof(file_data1));
198 	assertEqualMem(filedata + sizeof(file_data1), file_data2,
199 		sizeof(file_data2));
200 
201 	/* Skip data of file entry in q */
202 	while (q < buffend - 3) {
203 		if (memcmp(q, "PK\007\010", 4) == 0) {
204 			break;
205 		}
206 		q++;
207 	}
208 
209 	/* Verify data descriptor of file entry, except compressed size (offset 8). */
210 	assertEqualMem(q, "PK\007\010", 4); /* Signature */
211 	assertEqualInt(i4le(q + 4), crc); /* CRC-32 */
212 	assertEqualInt(i4le(q + 12), sizeof(file_data1) + sizeof(file_data2)); /* Uncompressed size */
213 	q = q + 16;
214 
215 	/* Verify folder entry in central directory. */
216 	assertEqualMem(p, "PK\001\002", 4); /* Signature */
217 	assertEqualInt(i2le(p + 4), 3 * 256 + 20); /* Version made by */
218 	assertEqualInt(i2le(p + 6), 20); /* Version needed to extract */
219 	assertEqualInt(i2le(p + 8), 0); /* Flags */
220 	assertEqualInt(i2le(p + 10), 0); /* Compression method */
221 	assertEqualInt(i2le(p + 12), (tm->tm_hour * 2048) + (tm->tm_min * 32) + (tm->tm_sec / 2)); /* File time */
222 	assertEqualInt(i2le(p + 14), ((tm->tm_year - 80) * 512) + ((tm->tm_mon + 1) * 32) + tm->tm_mday); /* File date */
223 	crc = 0;
224 	assertEqualInt(i4le(p + 16), crc); /* CRC-32 */
225 	assertEqualInt(i4le(p + 20), 0); /* Compressed size */
226 	assertEqualInt(i4le(p + 24), 0); /* Uncompressed size */
227 	assertEqualInt(i2le(p + 28), strlen(folder_name)); /* Pathname length */
228 	assertEqualInt(i2le(p + 30), 24); /* Extra field length */
229 	assertEqualInt(i2le(p + 32), 0); /* File comment length */
230 	assertEqualInt(i2le(p + 34), 0); /* Disk number start */
231 	assertEqualInt(i2le(p + 36), 0); /* Internal file attrs */
232 	assertEqualInt(i4le(p + 38) >> 16 & 01777, folder_perm); /* External file attrs */
233 	assertEqualInt(i4le(p + 42), q - buff); /* Offset of local header */
234 	assertEqualMem(p + 46, folder_name, strlen(folder_name)); /* Pathname */
235 	p = p + 46 + strlen(folder_name);
236 
237 	assertEqualInt(i2le(p), 0x7875); /* 'ux' extension header */
238 	assertEqualInt(i2le(p + 2), 11); /* 'ux' size */
239 	assertEqualInt(p[4], 1); /* 'ux' version */
240 	assertEqualInt(p[5], 4); /* 'ux' uid size */
241 	assertEqualInt(i4le(p + 6), folder_uid); /* 'ux' UID */
242 	assertEqualInt(p[10], 4); /* 'ux' gid size */
243 	assertEqualInt(i4le(p + 11), folder_gid); /* 'ux' GID */
244 	p = p + 4 + i2le(p + 2);
245 
246 	assertEqualInt(i2le(p), 0x5455); /* 'UT' extension header */
247 	assertEqualInt(i2le(p + 2), 5); /* 'UT' size */
248 	assertEqualInt(p[4], 1); /* 'UT' flags */
249 	assertEqualInt(i4le(p + 5), now); /* 'UT' mtime */
250 	p = p + 4 + i2le(p + 2);
251 
252 	/* Verify local header of folder entry. */
253 	local_header = q;
254 	assertEqualMem(q, "PK\003\004", 4); /* Signature */
255 	assertEqualInt(i2le(q + 4), 20); /* Version needed to extract */
256 	assertEqualInt(i2le(q + 6), 0); /* Flags */
257 	assertEqualInt(i2le(q + 8), 0); /* Compression method */
258 	assertEqualInt(i2le(q + 10), (tm->tm_hour * 2048) + (tm->tm_min * 32) + (tm->tm_sec / 2)); /* File time */
259 	assertEqualInt(i2le(q + 12), ((tm->tm_year - 80) * 512) + ((tm->tm_mon + 1) * 32) + tm->tm_mday); /* File date */
260 	assertEqualInt(i4le(q + 14), 0); /* CRC-32 */
261 	assertEqualInt(i4le(q + 18), 0); /* Compressed size */
262 	assertEqualInt(i4le(q + 22), 0); /* Uncompressed size */
263 	assertEqualInt(i2le(q + 26), strlen(folder_name)); /* Pathname length */
264 	assertEqualInt(i2le(q + 28), 41); /* Extra field length */
265 	assertEqualMem(q + 30, folder_name, strlen(folder_name)); /* Pathname */
266 	extra_start = q = q + 30 + strlen(folder_name);
267 
268 	assertEqualInt(i2le(q), 0x7875); /* 'ux' extension header */
269 	assertEqualInt(i2le(q + 2), 11); /* 'ux' size */
270 	assertEqualInt(q[4], 1); /* 'ux' version */
271 	assertEqualInt(q[5], 4); /* 'ux' uid size */
272 	assertEqualInt(i4le(q + 6), folder_uid); /* 'ux' UID */
273 	assertEqualInt(q[10], 4); /* 'ux' gid size */
274 	assertEqualInt(i4le(q + 11), folder_gid); /* 'ux' GID */
275 	q = q + 4 + i2le(q + 2);
276 
277 	assertEqualInt(i2le(q), 0x5455); /* 'UT' extension header */
278 	assertEqualInt(i2le(q + 2), 9); /* 'UT' size */
279 	assertEqualInt(q[4], 5); /* 'UT' flags */
280 	assertEqualInt(i4le(q + 5), now); /* 'UT' mtime */
281 	assertEqualInt(i4le(q + 9), now + 5); /* 'UT' atime */
282 	q = q + 4 + i2le(q + 2);
283 
284 	assertEqualInt(i2le(q), 0x6c78); /* 'xl' experimental extension header */
285 	assertEqualInt(i2le(q + 2), 9); /* size */
286 	assertEqualInt(q[4], 7); /* bitmap of fields */
287 	assertEqualInt(i2le(q + 5) >> 8, 3); /* system & version made by */
288 	assertEqualInt(i2le(q + 7), 0); /* internal file attributes */
289 	assertEqualInt(i4le(q + 9) >> 16 & 01777, folder_perm); /* external file attributes */
290 	q = q + 4 + i2le(q + 2);
291 
292 	assert(q == extra_start + i2le(local_header + 28));
293 	q = extra_start + i2le(local_header + 28);
294 
295 	/* There should not be any data in the folder entry,
296 	 * so the first central directory entry should be next: */
297 	assertEqualMem(q, "PK\001\002", 4); /* Signature */
298 
299 	/* Close archive, in case. */
300 	archive_read_free(zip_archive);
301 }
302 
verify_xz_contents(const char * buff,size_t used)303 static void verify_xz_contents(const char *buff, size_t used)
304 {
305 	verify_xz_lzma(buff, used, 95, 0x8);
306 }
307 
verify_lzma_contents(const char * buff,size_t used)308 static void verify_lzma_contents(const char *buff, size_t used)
309 {
310 	verify_xz_lzma(buff, used, 14, 0xA);
311 }
312 
313 #endif /* HAVE_LZMA_H */
DEFINE_TEST(test_write_format_zip_compression_lzmaxz)314 DEFINE_TEST(test_write_format_zip_compression_lzmaxz)
315 {
316 #ifndef HAVE_LZMA_H
317 	skipping("lzma is not fully supported on this platform");
318 #else /* HAVE_LZMA_H */
319 	/* Buffer data */
320 	struct archive *a;
321 	char buff[100000];
322 	size_t used;
323 
324 	/* Time data */
325 	now = time(NULL);
326 
327 	/* Create new ZIP archive in memory without padding. */
328 	/* Use the setter function to use LZMA Alone compression. */
329 	assert((a = archive_write_new()) != NULL);
330 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_zip(a));
331 	assertEqualIntA(a, ARCHIVE_OK, archive_write_zip_set_compression_lzma(a));
332 	assertEqualIntA(a, ARCHIVE_OK,
333 	    archive_write_set_options(a, "zip:experimental"));
334 	assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_none(a));
335 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_bytes_per_block(a, 1));
336 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_bytes_in_last_block(a, 1));
337 	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, sizeof(buff), &used));
338 
339 	verify_write_lzma(a);
340 
341 	/* Close the archive . */
342 	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
343 	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
344 	dumpfile("constructed.zip", buff, used);
345 
346 	verify_lzma_contents(buff, used);
347 
348 	/* Create new ZIP archive in memory without padding. */
349 	/* Use compression-level=9 to check that compression
350 	 * levels are somewhat supported. */
351 	assert((a = archive_write_new()) != NULL);
352 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_zip(a));
353 	assertEqualIntA(a, ARCHIVE_OK,
354 	    archive_write_set_options(a, "zip:compression=lzma"));
355 	assertEqualIntA(a, ARCHIVE_OK,
356 	    archive_write_set_options(a, "zip:compression-level=9"));
357 	assertEqualIntA(a, ARCHIVE_OK,
358 	    archive_write_set_options(a, "zip:experimental"));
359 	assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_none(a));
360 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_bytes_per_block(a, 1));
361 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_bytes_in_last_block(a, 1));
362 	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, sizeof(buff), &used));
363 
364 	verify_write_lzma(a);
365 
366 	/* Close the archive. */
367 	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
368 	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
369 	dumpfile("constructed.zip", buff, used);
370 
371 	verify_lzma_contents(buff, used);
372 
373 	/* Same song and dance, but for XZ */
374 
375 	/* Create new ZIP archive in memory without padding. */
376 	/* Use the setter function to use XZ compression. */
377 	assert((a = archive_write_new()) != NULL);
378 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_zip(a));
379 	assertEqualIntA(a, ARCHIVE_OK, archive_write_zip_set_compression_xz(a));
380 	assertEqualIntA(a, ARCHIVE_OK,
381 	    archive_write_set_options(a, "zip:experimental"));
382 	assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_none(a));
383 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_bytes_per_block(a, 1));
384 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_bytes_in_last_block(a, 1));
385 	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, sizeof(buff), &used));
386 
387 	verify_write_lzma(a);
388 
389 	/* Close the archive . */
390 	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
391 	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
392 	dumpfile("constructed.zip", buff, used);
393 
394 	verify_xz_contents(buff, used);
395 
396 	/* Create new ZIP archive in memory without padding. */
397 	/* Use compression-level=9 to check that compression levels are
398 	 * somewhat supported as well as threads=2 to check the multi-threaded
399 	 * encoder, if available. */
400 	assert((a = archive_write_new()) != NULL);
401 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_zip(a));
402 	assertEqualIntA(a, ARCHIVE_OK,
403 	    archive_write_set_options(a, "zip:compression=xz"));
404 	assertEqualIntA(a, ARCHIVE_OK,
405 	    archive_write_set_options(a, "zip:compression-level=9"));
406 	assertEqualIntA(a, ARCHIVE_OK,
407 	    archive_write_set_options(a, "zip:threads=2"));
408 	assertEqualIntA(a, ARCHIVE_OK,
409 	    archive_write_set_options(a, "zip:experimental"));
410 	assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_none(a));
411 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_bytes_per_block(a, 1));
412 	assertEqualIntA(a, ARCHIVE_OK, archive_write_set_bytes_in_last_block(a, 1));
413 	assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, sizeof(buff), &used));
414 
415 	verify_write_lzma(a);
416 
417 	/* Close the archive. */
418 	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
419 	assertEqualInt(ARCHIVE_OK, archive_write_free(a));
420 	dumpfile("constructed.zip", buff, used);
421 
422 	verify_xz_contents(buff, used);
423 #endif /* HAVE_LZMA_H */
424 }
425 
426