9 from fnmatch import fnmatchcase as matches
10 from cStringIO import StringIO
12 logg = logging.getLogger("test")
15 testdatadir = "testdata.d"
21 def shell_string(command):
22 return " ".join(["'%s'" % arg.replace("'","\\'") for arg in command])
24 def shell(command, shell=True, calls=False, cwd=None, env=None, lang=None, returncodes=None):
25 returncodes = returncodes or [ None, 0 ]
26 Shell = collections.namedtuple("Shell",["returncode", "output", "errors", "shell"])
27 if isinstance(command, basestring):
31 sh_command = shell_string(command)
33 if not env: env = os.environ.copy()
34 for name, value in env.items():
35 if name.startswith("LC_"):
37 env["LANG"] = lang # defines message format
38 env["LC_ALL"] = lang # other locale formats
40 output, errors = "", ""
42 logg.debug("result from %s: %s", cwd and cwd+"/" or "shell", sh_command)
43 run = subprocess.Popen(command, shell=shell, cwd=cwd, env=env)
45 logg.warning("EXIT %s: %s", run.returncode, command)
48 logg.debug("output from %s: %s", cwd and cwd+"/" or "shell", sh_command)
49 run = subprocess.Popen(command, shell=shell, cwd=cwd,
50 stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=None, env=env)
52 logg.warning("EXIT %s: %s", run.returncode, command)
53 output, errors = run.communicate() # run.wait()
55 logg.error("*E*: %s", sh_command)
56 for line in output.split("\n"):
58 logg.error("OUT: %s", line)
59 for line in errors.split("\n"):
61 logg.error("ERR: %s", line)
63 if run.returncode not in returncodes:
64 logg.warning("*%02i: %s", run.returncode, sh_command)
65 for line in output.split("\n"):
67 logg.warning("OUT: %s", line)
68 for line in errors.split("\n"):
70 logg.warning("ERR: %s", line)
71 raise subprocess.CalledProcessError(run.returncode, sh_command, output)
73 for line in output.split("\n"):
75 logg.debug("OUT: %s", line)
76 for line in errors.split("\n"):
78 logg.debug("ERR: %s", line)
79 return Shell(run.returncode, output, errors, sh_command)
81 def testdir(testname):
82 newdir = "tests/tmp."+testname
83 if os.path.isdir(newdir):
88 def download(base_url, filename, into):
89 if not os.path.isdir(into):
91 if not os.path.exists(os.path.join(into, filename)):
92 shell("cd {into} && wget {base_url}/{filename}".format(**locals()))
93 def trycopy(srcdir, filename, into):
94 if not os.path.isdir(into):
96 src_file = os.path.join(srcdir, filename)
97 dst_file = os.path.join(into, filename)
98 if os.path.isfile(src_file):
99 shutil.copy(src_file, dst_file)
101 def output(cmd, shell=True):
102 run = subprocess.Popen(cmd, shell=shell, stdout=subprocess.PIPE)
103 out, err = run.communicate()
105 def grep(pattern, lines):
106 if isinstance(lines, basestring):
107 lines = lines.split("\n")
109 if re.search(pattern, line.rstrip()):
111 def greps(lines, pattern):
112 return list(grep(pattern, lines))
115 class ZZipTest(unittest.TestCase):
118 if not os.path.isdir(testdatadir):
119 os.makedirs(testdatadir)
125 return os.path.join(self.s, name)
127 f = open(self.src(readme))
131 def mkfile(self, name, content):
132 b = os.path.dirname(name)
133 if not os.path.isdir(b):
138 def bins(self, name):
139 if name == "unzip": return unzip
140 if name == "mkzip": return mkzip
141 exe = os.path.join("..", "bins", name)
142 if exeext: exe += exeext
144 def gentext(self, size):
145 random.seed(1234567891234567890)
149 for i in xrange(size):
151 x = random.choice(" abcdefghijklmnopqrstuvwxyz\n")
152 if x == old1 or x == old2: continue
157 return result.getvalue()
158 ################################################################
159 def test_100_make_test0_zip(self):
160 """ create a test.zip for later tests using standard 'zip'
161 It will fall back to a variant in the source code if 'zip'
162 is not installed on the build host. The content is just
163 the README file that we can check for equality later on. """
166 exe=self.bins("mkzip")
167 filename = os.path.join(tmpdir,"README")
168 filetext = self.readme()
169 self.mkfile(filename, filetext)
170 shell("{exe} ../{zipfile} README".format(**locals()), cwd=tmpdir)
171 self.assertGreater(os.path.getsize(zipfile), 10)
172 def test_101_make_test1_zip(self):
173 """ create a test1.zip for later tests using standard 'zip'
174 It will fall back to a variant in the source code if 'zip'
175 is not installed on the build host. The archive has 10
176 generic files that we can check for their content later. """
179 exe=self.bins("mkzip")
180 for i in [1,2,3,4,5,6,7,8,9]:
181 filename = os.path.join(tmpdir,"file.%i" % i)
182 filetext = "file-%i\n" % i
183 self.mkfile(filename, filetext)
184 filename = os.path.join(tmpdir,"README")
185 filetext = self.readme()
186 self.mkfile(filename, filetext)
187 shell("{exe} ../{zipfile} ??*.* README".format(**locals()), cwd=tmpdir)
188 self.assertGreater(os.path.getsize(zipfile), 10)
189 def test_102_make_test2_zip(self):
190 """ create a test2.zip for later tests using standard 'zip'
191 It will NOT fall back to a variant in the source code.
192 The archive has 100 generic files with known content. """
195 exe=self.bins("mkzip")
196 for i in xrange(100):
197 filename = os.path.join(tmpdir,"file.%02i" % i)
198 filetext = "file-%02i\n" % i
199 self.mkfile(filename, filetext)
200 filename = os.path.join(tmpdir,"README")
201 filetext = self.readme()
202 self.mkfile(filename, filetext)
203 shell("{exe} ../{zipfile} ??*.* README".format(**locals()), cwd=tmpdir)
204 self.assertGreater(os.path.getsize(zipfile), 10)
205 def test_103_make_test3_zip(self):
206 """ create a test3.zip for later tests using standard 'zip'
207 It will NOT fall back to a variant in the source code.
208 The archive has 1000 generic files with known content. """
211 exe=self.bins("mkzip")
212 for i in xrange(1000):
213 filename = os.path.join(tmpdir,"file.%03i" % i)
214 filetext = "file-%03i\n" % i
215 self.mkfile(filename, filetext)
216 filename = os.path.join(tmpdir,"README")
217 filetext = self.readme()
218 self.mkfile(filename, filetext)
219 shell("{exe} ../{zipfile} ??*.* README".format(**locals()), cwd=tmpdir)
220 self.assertGreater(os.path.getsize(zipfile), 10)
221 def test_104_make_test4_zip(self):
222 """ create a test4.zip for later tests using standard 'zip'
223 It will NOT fall back to a variant in the source code.
224 The archive has 10000 generic files with known content
225 and they are stored (NOT compressed) in the archive. """
228 exe=self.bins("mkzip")
229 for i in xrange(10000):
230 filename = os.path.join(tmpdir,"file%04i.txt" % i)
231 filetext = "file-%04i\n" % i
232 self.mkfile(filename, filetext)
233 filename = os.path.join(tmpdir,"README")
234 filetext = self.readme()
235 self.mkfile(filename, filetext)
236 shell("{exe} -n README ../{zipfile} ??*.* README".format(**locals()), cwd=tmpdir)
237 self.assertGreater(os.path.getsize(zipfile), 1000000)
238 def test_105_make_test5_zip(self):
239 """ create a test5.zip for later tests using standard 'zip'
240 It will NOT fall back to a variant in the source code.
241 The archive has files at multiple subdirectories depth
242 and of varying sizes each. """
245 exe=self.bins("mkzip")
246 for depth in xrange(20):
248 for i in xrange(depth):
250 dirpath += "subdir%i/" % i
251 for size in xrange(18):
253 filetext = self.gentext(size)
254 filepart = "file%i-%i.txt" % (depth, size)
255 filename = os.path.join(tmpdir, dirpath + filepart )
256 self.mkfile(filename, filetext)
257 filename = os.path.join(tmpdir,"README")
258 filetext = self.readme()
259 self.mkfile(filename, filetext)
260 shell("{exe} ../{zipfile} -r file* subdir* README".format(**locals()), cwd=tmpdir)
261 self.assertGreater(os.path.getsize(zipfile), 1000000)
262 def test_110_make_test0_dat(self):
263 """ create test.dat from test.zip with xorcopy """
264 zipfile = "test0.zip"
265 datfile = "test0x.dat"
266 exe = self.bins("zzxorcopy")
267 shell("{exe} {zipfile} {datfile}".format(**locals()))
268 self.assertGreater(os.path.getsize(datfile), 10)
269 self.assertEqual(os.path.getsize(datfile), os.path.getsize(zipfile))
270 def test_111_make_test1_dat(self):
271 """ create test.dat from test.zip with xorcopy """
272 zipfile = "test1.zip"
273 datfile = "test1x.dat"
274 exe = self.bins("zzxorcopy")
275 shell("{exe} {zipfile} {datfile}".format(**locals()))
276 self.assertGreater(os.path.getsize(datfile), 10)
277 self.assertEqual(os.path.getsize(datfile), os.path.getsize(zipfile))
278 def test_112_make_test2_dat(self):
279 """ create test.dat from test.zip with xorcopy """
280 zipfile = "test2.zip"
281 datfile = "test2x.dat"
282 exe = self.bins("zzxorcopy")
283 shell("{exe} {zipfile} {datfile}".format(**locals()))
284 self.assertGreater(os.path.getsize(datfile), 10)
285 self.assertEqual(os.path.getsize(datfile), os.path.getsize(zipfile))
286 def test_113_make_test3_dat(self):
287 """ create test.dat from test.zip with xorcopy """
288 zipfile = "test3.zip"
289 datfile = "test3x.dat"
290 exe = self.bins("zzxorcopy")
291 shell("{exe} {zipfile} {datfile}".format(**locals()))
292 self.assertGreater(os.path.getsize(datfile), 10)
293 self.assertEqual(os.path.getsize(datfile), os.path.getsize(zipfile))
294 def test_114_make_test4_dat(self):
295 """ create test.dat from test.zip with xorcopy """
296 zipfile = "test4.zip"
297 datfile = "test4x.dat"
298 exe = self.bins("zzxorcopy")
299 shell("{exe} {zipfile} {datfile}".format(**locals()))
300 self.assertGreater(os.path.getsize(datfile), 10)
301 self.assertEqual(os.path.getsize(datfile), os.path.getsize(zipfile))
302 def test_200_zziptest_test0_zip(self):
303 """ run zziptest on test.zip """
304 zipfile = "test0.zip"
305 logfile = "test0.log"
306 exe = self.bins("zziptest")
307 shell("{exe} --quick {zipfile} | tee {logfile}".format(**locals()))
308 self.assertGreater(os.path.getsize(logfile), 10)
309 def test_201_zziptest_test1_zip(self):
310 """ run zziptest on test.zip """
311 zipfile = "test1.zip"
312 logfile = "test1.log"
313 exe = self.bins("zziptest")
314 shell("{exe} --quick {zipfile} | tee {logfile}".format(**locals()))
315 self.assertGreater(os.path.getsize(logfile), 10)
316 def test_202_zziptest_test2_zip(self):
317 """ run zziptest on test.zip """
318 zipfile = "test2.zip"
319 logfile = "test2.log"
320 exe = self.bins("zziptest")
321 shell("{exe} --quick {zipfile} | tee {logfile}".format(**locals()))
322 self.assertGreater(os.path.getsize(logfile), 10)
323 def test_203_zziptest_test3_zip(self):
324 """ run zziptest on test.zip """
325 zipfile = "test3.zip"
326 logfile = "test3.log"
327 exe = self.bins("zziptest")
328 shell("{exe} --quick {zipfile} | tee {logfile}".format(**locals()))
329 self.assertGreater(os.path.getsize(logfile), 10)
330 def test_204_zziptest_test4_zip(self):
331 """ run zziptest on test.zip """
332 zipfile = "test4.zip"
333 logfile = "test4.log"
334 exe = self.bins("zziptest")
335 shell("{exe} --quick {zipfile} | tee {logfile}".format(**locals()))
336 self.assertGreater(os.path.getsize(logfile), 10)
337 def test_210_zzcat_test0_zip(self):
338 """ run zzcat on test.zip using just test/README """
339 zipfile = "test0.zip"
340 getfile = "test0/README"
341 logfile = "test0.readme.txt"
342 exe = self.bins("zzcat")
343 run = shell("{exe} {getfile} | tee {logfile}".format(**locals()))
344 self.assertGreater(os.path.getsize(logfile), 10)
345 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
346 def test_211_zzcat_test1_zip(self):
347 """ run zzcat on test.zip using just test/README """
348 zipfile = "test1.zip"
349 getfile = "test1/README"
350 logfile = "test1.readme.txt"
351 exe = self.bins("zzcat")
352 run = shell("{exe} {getfile} | tee {logfile}".format(**locals()))
353 self.assertGreater(os.path.getsize(logfile), 10)
354 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
355 getfile = "test1/file.1"
356 run = shell("{exe} {getfile}".format(**locals()))
357 self.assertEqual("file-1\n", run.output)
358 def test_212_zzcat_test2_zip(self):
359 """ run zzcat on test.zip using just test/README """
360 zipfile = "test2.zip"
361 getfile = "test2/README"
362 logfile = "test2.readme.txt"
363 exe = self.bins("zzcat")
364 run = shell("{exe} {getfile} | tee {logfile}".format(**locals()))
365 self.assertGreater(os.path.getsize(logfile), 10)
366 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
367 getfile = "test2/file.22"
368 run = shell("{exe} {getfile}".format(**locals()))
369 self.assertEqual("file-22\n", run.output)
370 def test_213_zzcat_test3_zip(self):
371 """ run zzcat on test.zip using just test/README """
372 zipfile = "test3.zip"
373 getfile = "test3/README"
374 logfile = "test3.readme.txt"
375 exe = self.bins("zzcat")
376 run = shell("{exe} {getfile} | tee {logfile}".format(**locals()))
377 self.assertGreater(os.path.getsize(logfile), 10)
378 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
379 getfile = "test3/file.999"
380 run = shell("{exe} {getfile}".format(**locals()))
381 self.assertEqual("file-999\n", run.output)
382 def test_214_zzcat_test4_zip(self):
383 """ run zzcat on test.zip using just test/README """
384 zipfile = "test4.zip"
385 getfile = "test4/README"
386 logfile = "test4.readme.txt"
387 exe = self.bins("zzcat")
388 run = shell("{exe} {getfile} | tee {logfile}".format(**locals()))
389 self.assertGreater(os.path.getsize(logfile), 10)
390 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
391 getfile = "test4/file9999.txt"
392 run = shell("{exe} {getfile}".format(**locals()))
393 self.assertEqual("file-9999\n", run.output)
394 def test_220_zzdir_test0_zip(self):
395 """ run zzdir on test0.zip using just 'test0' """
396 zipfile = "test0.zip"
398 exe = self.bins("zzdir")
399 run = shell("{exe} {getfile} ".format(**locals()))
400 self.assertIn(' README\n', run.output)
401 self.assertIn(' defl:N ', run.output)
402 self.assertLess(len(run.output), 30)
403 def test_221_zzdir_test1_zip(self):
404 """ run zzdir on test1.zip using just 'test1' """
405 zipfile = "test1.zip"
407 exe = self.bins("zzdir")
408 run = shell("{exe} {getfile} ".format(**locals()))
409 self.assertIn(' file.1\n', run.output)
410 self.assertIn(' file.2\n', run.output)
411 self.assertIn(' file.9\n', run.output)
412 self.assertIn(' README\n', run.output)
413 self.assertIn(' defl:N ', run.output)
414 self.assertIn(' stored ', run.output)
415 def test_222_zzdir_test2_zip(self):
416 """ run zzdir on test2.zip using just 'test2' """
417 zipfile = "test2.zip"
419 exe = self.bins("zzdir")
420 run = shell("{exe} {getfile} ".format(**locals()))
421 self.assertIn(' file.01\n', run.output)
422 self.assertIn(' file.22\n', run.output)
423 self.assertIn(' file.99\n', run.output)
424 self.assertIn(' defl:N ', run.output)
425 self.assertIn(' stored ', run.output)
426 def test_223_zzdir_test3_zip(self):
427 """ run zzdir on test3.zip using just 'test3' """
428 zipfile = "test3.zip"
430 exe = self.bins("zzdir")
431 run = shell("{exe} {getfile} ".format(**locals()))
432 self.assertIn(' file.001\n', run.output)
433 self.assertIn(' file.222\n', run.output)
434 self.assertIn(' file.999\n', run.output)
435 self.assertIn(' defl:N ', run.output)
436 self.assertIn(' stored ', run.output)
437 def test_224_zzdir_test4_zip(self):
438 """ run zzdir on test4.zip using just 'test4' """
439 zipfile = "test4.zip"
441 exe = self.bins("zzdir")
442 run = shell("{exe} {getfile} ".format(**locals()))
443 self.assertIn(' file0001.txt\n', run.output)
444 self.assertIn(' file2222.txt\n', run.output)
445 self.assertIn(' file9999.txt\n', run.output)
446 self.assertNotIn(' defl:N ', run.output)
447 self.assertIn(' stored ', run.output)
448 def test_320_zzxordir_test0_dat(self):
449 """ run zzxordir on test0x.dat """
450 zipfile = "test0x.dat"
451 getfile = "test0x.dat"
452 exe = self.bins("zzdir")
453 run = shell("{exe} {getfile} ".format(**locals()), returncodes = [0,1])
454 self.assertEqual(run.returncode, 1)
455 self.assertEqual("", run.output)
456 self.assertIn("did not open test", run.errors)
457 exe = self.bins("zzxordir")
458 run = shell("{exe} {getfile} ".format(**locals()))
459 self.assertIn(' README\n', run.output)
460 self.assertIn(' defl:N ', run.output)
461 self.assertLess(len(run.output), 30)
462 def test_321_zzxordir_test1_dat(self):
463 """ run zzxordir on test1x.dat using just 'test1x' """
464 zipfile = "test1x.dat"
465 getfile = "test1x.dat"
466 exe = self.bins("zzdir")
467 run = shell("{exe} {getfile} ".format(**locals()), returncodes = [0,1])
468 self.assertEqual(run.returncode, 1)
469 self.assertEqual("", run.output)
470 self.assertIn("did not open test", run.errors)
471 exe = self.bins("zzxordir")
472 run = shell("{exe} {getfile} ".format(**locals()))
473 self.assertIn(' file.1\n', run.output)
474 self.assertIn(' file.2\n', run.output)
475 self.assertIn(' file.9\n', run.output)
476 self.assertIn(' README\n', run.output)
477 self.assertIn(' defl:N ', run.output)
478 self.assertIn(' stored ', run.output)
479 def test_322_zzxordir_test2_dat(self):
480 """ run zzxordir on test2x.dat using just 'test2x' """
481 zipfile = "test2x.dat"
483 exe = self.bins("zzdir")
484 run = shell("{exe} {getfile} ".format(**locals()), returncodes = [0,1])
485 self.assertEqual(run.returncode, 1)
486 self.assertEqual("", run.output)
487 self.assertIn("did not open test", run.errors)
488 exe = self.bins("zzxordir")
489 run = shell("{exe} {getfile} ".format(**locals()))
490 self.assertIn(' file.01\n', run.output)
491 self.assertIn(' file.22\n', run.output)
492 self.assertIn(' file.99\n', run.output)
493 self.assertIn(' defl:N ', run.output)
494 self.assertIn(' stored ', run.output)
495 def test_323_zzxordir_test3_dat(self):
496 """ run zzxordir on test3x.dat using just 'test3x' """
497 zipfile = "test3x.dat"
499 exe = self.bins("zzdir")
500 run = shell("{exe} {getfile} ".format(**locals()), returncodes = [0,1])
501 self.assertEqual(run.returncode, 1)
502 self.assertEqual("", run.output)
503 self.assertIn("did not open test", run.errors)
504 exe = self.bins("zzxordir")
505 run = shell("{exe} {getfile} ".format(**locals()))
506 self.assertIn(' file.001\n', run.output)
507 self.assertIn(' file.222\n', run.output)
508 self.assertIn(' file.999\n', run.output)
509 self.assertIn(' defl:N ', run.output)
510 self.assertIn(' stored ', run.output)
511 def test_324_zzxordir_test4_zip(self):
512 """ run zzxordir on test4x.dat using just 'test4x' """
513 zipfile = "test4x.dat"
515 exe = self.bins("zzdir")
516 run = shell("{exe} {getfile} ".format(**locals()), returncodes = [0,1])
517 self.assertEqual(run.returncode, 1)
518 self.assertEqual("", run.output)
519 self.assertIn("did not open test", run.errors)
520 exe = self.bins("zzxordir")
521 run = shell("{exe} {getfile} ".format(**locals()))
522 self.assertIn(' file0001.txt\n', run.output)
523 self.assertIn(' file2222.txt\n', run.output)
524 self.assertIn(' file9999.txt\n', run.output)
525 self.assertNotIn(' defl:N ', run.output)
526 self.assertIn(' stored ', run.output)
527 def test_340_zzxorcat_test0_zip(self):
528 """ run zzxorcat on testx.zip using just testx/README """
529 getfile = "test0x/README"
530 logfile = "test0x.readme.txt"
531 exe = self.bins("zzcat")
532 run = shell("{exe} {getfile} ".format(**locals()), lang="C")
533 self.assertEqual("", run.output)
534 self.assertIn("No such file or directory", run.errors)
535 exe = self.bins("zzxorcat")
536 run = shell("{exe} {getfile} | tee {logfile}".format(**locals()))
537 self.assertGreater(os.path.getsize(logfile), 10)
538 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
539 def test_341_zzxorcat_test1_zip(self):
540 """ run zzxorcat on testx.zip using just testx/README """
541 getfile = "test1x/README"
542 logfile = "test1x.readme.txt"
543 exe = self.bins("zzcat")
544 run = shell("{exe} {getfile} ".format(**locals()), lang="C")
545 self.assertEqual("", run.output)
546 self.assertIn("No such file or directory", run.errors)
547 exe = self.bins("zzxorcat")
548 run = shell("{exe} {getfile} | tee {logfile}".format(**locals()))
549 self.assertGreater(os.path.getsize(logfile), 10)
550 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
551 getfile = "test1x/file.1"
552 run = shell("{exe} {getfile}".format(**locals()))
553 self.assertEqual("file-1\n", run.output)
554 def test_342_zzxorcat_test2_zip(self):
555 """ run zzxorcat on testx.zip using just testx/README """
556 getfile = "test2x/README"
557 logfile = "test2x.readme.txt"
558 exe = self.bins("zzcat")
559 run = shell("{exe} {getfile} ".format(**locals()), lang="C")
560 self.assertEqual("", run.output)
561 self.assertIn("No such file or directory", run.errors)
562 exe = self.bins("zzxorcat")
563 run = shell("{exe} {getfile} | tee {logfile}".format(**locals()))
564 self.assertGreater(os.path.getsize(logfile), 10)
565 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
566 getfile = "test2x/file.22"
567 run = shell("{exe} {getfile}".format(**locals()))
568 self.assertEqual("file-22\n", run.output)
569 def test_343_zzxorcat_test3_zip(self):
570 """ run zzxorcat on testx.zip using just testx/README """
571 getfile = "test3x/README"
572 logfile = "test3x.readme.txt"
573 exe = self.bins("zzcat")
574 run = shell("{exe} {getfile} ".format(**locals()), lang="C")
575 self.assertEqual("", run.output)
576 self.assertIn("No such file or directory", run.errors)
577 exe = self.bins("zzxorcat")
578 run = shell("{exe} {getfile} | tee {logfile}".format(**locals()))
579 self.assertGreater(os.path.getsize(logfile), 10)
580 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
581 getfile = "test3x/file.999"
582 run = shell("{exe} {getfile}".format(**locals()))
583 self.assertEqual("file-999\n", run.output)
584 def test_344_zzxorcat_test4_zip(self):
585 """ run zzxorcat on testx.zip using just testx/README """
586 getfile = "test4x/README"
587 logfile = "test4x.readme.txt"
588 exe = self.bins("zzxorcat")
589 run = shell("{exe} {getfile} | tee {logfile}".format(**locals()))
590 self.assertGreater(os.path.getsize(logfile), 10)
591 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
592 getfile = "test4x/file9999.txt"
593 run = shell("{exe} {getfile}".format(**locals()))
594 self.assertEqual("file-9999\n", run.output)
595 #####################################################################
597 #####################################################################
598 def test_400_infozip_cat_test0_zip(self):
599 """ run inzo-zip cat test.zip using just archive README """
600 zipfile = "test0.zip"
602 logfile = "test0.readme.pk.txt"
603 exe = self.bins("unzip")
604 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
605 self.assertGreater(os.path.getsize(logfile), 10)
606 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
607 def test_401_infozip_cat_test1_zip(self):
608 """ run info-zip cat test.zip using just archive README """
609 zipfile = "test1.zip"
611 logfile = "test1.readme.pk.txt"
612 exe = self.bins("unzip")
613 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
614 self.assertGreater(os.path.getsize(logfile), 10)
615 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
617 run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
618 self.assertEqual("file-1\n", run.output)
619 def test_402_infozip_cat_test2_zip(self):
620 """ run info-zip cat test.zip using just archive README """
621 zipfile = "test2.zip"
623 logfile = "test2.readme.pk.txt"
624 exe = self.bins("unzip")
625 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
626 self.assertGreater(os.path.getsize(logfile), 10)
627 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
629 run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
630 self.assertEqual("file-22\n", run.output)
631 def test_405_zzcat_big_test5_zip(self):
632 """ run info-zip cat test.zip using archive README """
633 zipfile = "test5.zip"
635 logfile = "test5.readme.pk.txt"
636 exe = self.bins("unzip")
637 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
638 self.assertGreater(os.path.getsize(logfile), 10)
639 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
640 getfile = "subdir1/subdir2/subdir3/subdir4/subdir5/subdir6/file7-1024.txt"
641 compare = self.gentext(1024)
642 run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
643 self.assertEqual(compare, run.output)
644 def test_410_zzcat_big_test0_zip(self):
645 """ run zzcat-big on test.zip using just archive README """
646 zipfile = "test0.zip"
648 logfile = "test0.readme.big.txt"
649 exe = self.bins("unzzip-big")
650 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
651 self.assertGreater(os.path.getsize(logfile), 10)
652 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
653 def test_411_zzcat_big_test1_zip(self):
654 """ run zzcat-big on test.zip using just archive README """
655 zipfile = "test1.zip"
657 logfile = "test1.readme.big.txt"
658 exe = self.bins("unzzip-big")
659 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
660 self.assertGreater(os.path.getsize(logfile), 10)
661 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
663 run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
664 self.assertEqual("file-1\n", run.output)
665 def test_412_zzcat_big_test2_zip(self):
666 """ run zzcat-seeke on test.zip using just archive README """
667 zipfile = "test2.zip"
669 logfile = "test2.readme.big.txt"
670 exe = self.bins("unzzip-big")
671 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
672 self.assertGreater(os.path.getsize(logfile), 10)
673 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
675 run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
676 self.assertEqual("file-22\n", run.output)
677 def test_415_zzcat_big_test5_zip(self):
678 """ run zzcat-big on test.zip using archive README """
679 zipfile = "test5.zip"
681 logfile = "test5.readme.zap.txt"
682 exe = self.bins("unzzip-big")
683 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
684 self.assertGreater(os.path.getsize(logfile), 10)
685 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
686 getfile = "subdir1/subdir2/subdir3/subdir4/subdir5/subdir6/file7-1024.txt"
687 compare = self.gentext(1024)
688 run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
689 self.assertEqual(compare, run.output)
690 def test_420_zzcat_mem_test0_zip(self):
691 """ run zzcat-mem on test.zip using just archive README """
692 zipfile = "test0.zip"
694 logfile = "test0.readme.mem.txt"
695 exe = self.bins("unzzip-mem")
696 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
697 self.assertGreater(os.path.getsize(logfile), 10)
698 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
699 def test_421_zzcat_mem_test1_zip(self):
700 """ run zzcat-mem on test.zip using archive README """
701 zipfile = "test1.zip"
703 logfile = "test1.readme.mem.txt"
704 exe = self.bins("unzzip-mem")
705 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
706 self.assertGreater(os.path.getsize(logfile), 10)
707 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
709 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
710 self.assertEqual("file-1\n", run.output)
711 def test_422_zzcat_mem_test2_zip(self):
712 """ run zzcat-mem on test.zip using archive README """
713 zipfile = "test2.zip"
715 logfile = "test2.readme.mem.txt"
716 exe = self.bins("unzzip-mem")
717 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
718 self.assertGreater(os.path.getsize(logfile), 10)
719 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
721 run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
722 self.assertEqual("file-22\n", run.output)
723 def test_423_zzcat_mem_test3_zip(self):
724 """ run zzcat-mem on test.zip using archive README """
725 zipfile = "test3.zip"
727 logfile = "test3.readme.mem.txt"
728 exe = self.bins("unzzip-mem")
729 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
730 self.assertGreater(os.path.getsize(logfile), 10)
731 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
733 run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
734 self.assertEqual("file-999\n", run.output)
735 def test_424_zzcat_mem_test4_zip(self):
736 """ run zzcat-mem on test.zip using archive README """
737 zipfile = "test4.zip"
739 logfile = "test4.readme.mem.txt"
740 exe = self.bins("unzzip-mem")
741 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
742 self.assertGreater(os.path.getsize(logfile), 10)
743 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
744 getfile = "file9999.txt"
745 run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
746 self.assertEqual("file-9999\n", run.output)
747 def test_425_zzcat_mem_test5_zip(self):
748 """ run zzcat-mem on test.zip using archive README """
749 zipfile = "test5.zip"
751 logfile = "test5.readme.zap.txt"
752 exe = self.bins("unzzip-mem")
753 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
754 self.assertGreater(os.path.getsize(logfile), 10)
755 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
756 getfile = "subdir1/subdir2/subdir3/subdir4/subdir5/subdir6/file7-1024.txt"
757 compare = self.gentext(1024)
758 run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
759 self.assertEqual(compare, run.output)
760 def test_430_zzcat_mix_test0_zip(self):
761 """ run zzcat-mix on test.zip using just archive README """
762 zipfile = "test0.zip"
764 logfile = "test0.readme.mix.txt"
765 exe = self.bins("unzzip-mix")
766 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
767 self.assertGreater(os.path.getsize(logfile), 10)
768 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
769 def test_431_zzcat_mix_test1_zip(self):
770 """ run zzcat-mix on test.zip using archive README """
771 zipfile = "test1.zip"
773 logfile = "test1.readme.mix.txt"
774 exe = self.bins("unzzip-mix")
775 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
776 self.assertGreater(os.path.getsize(logfile), 10)
777 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
779 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
780 self.assertEqual("file-1\n", run.output)
781 def test_432_zzcat_mix_test2_zip(self):
782 """ run zzcat-mix on test.zip using archive README """
783 zipfile = "test2.zip"
785 logfile = "test2.readme.mix.txt"
786 exe = self.bins("unzzip-mix")
787 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
788 self.assertGreater(os.path.getsize(logfile), 10)
789 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
791 run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
792 self.assertEqual("file-22\n", run.output)
793 def test_433_zzcat_mix_test3_zip(self):
794 """ run zzcat-mix on test.zip using archive README """
795 zipfile = "test3.zip"
797 logfile = "test3.readme.mix.txt"
798 exe = self.bins("unzzip-mix")
799 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
800 self.assertGreater(os.path.getsize(logfile), 10)
801 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
803 run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
804 self.assertEqual("file-999\n", run.output)
805 def test_434_zzcat_mix_test4_zip(self):
806 """ run zzcat-mix on test.zip using archive README """
807 zipfile = "test4.zip"
809 logfile = "test4.readme.mix.txt"
810 exe = self.bins("unzzip-mix")
811 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
812 self.assertGreater(os.path.getsize(logfile), 10)
813 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
814 getfile = "file9999.txt"
815 run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
816 self.assertEqual("file-9999\n", run.output)
817 def test_435_zzcat_mix_test5_zip(self):
818 """ run zzcat-mix on test.zip using archive README """
819 zipfile = "test5.zip"
821 logfile = "test5.readme.zap.txt"
822 exe = self.bins("unzzip-mix")
823 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
824 self.assertGreater(os.path.getsize(logfile), 10)
825 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
826 getfile = "subdir1/subdir2/subdir3/subdir4/subdir5/subdir6/file7-1024.txt"
827 compare = self.gentext(1024)
828 run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
829 self.assertEqual(compare, run.output)
830 def test_440_zzcat_zap_test0_zip(self):
831 """ run zzcat-zap on test.zip using just archive README """
832 zipfile = "test0.zip"
834 logfile = "test0.readme.txt"
835 exe = self.bins("unzzip")
836 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
837 self.assertGreater(os.path.getsize(logfile), 10)
838 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
839 def test_441_zzcat_zap_test1_zip(self):
840 """ run zzcat-zap on test.zip using archive README """
841 zipfile = "test1.zip"
843 logfile = "test1.readme.zap.txt"
844 exe = self.bins("unzzip")
845 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
846 self.assertGreater(os.path.getsize(logfile), 10)
847 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
849 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
850 self.assertEqual("file-1\n", run.output)
851 def test_442_zzcat_zap_test2_zip(self):
852 """ run zzcat-zap on test.zip using archive README """
853 zipfile = "test2.zip"
855 logfile = "test2.readme.zap.txt"
856 exe = self.bins("unzzip")
857 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
858 self.assertGreater(os.path.getsize(logfile), 10)
859 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
861 run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
862 self.assertEqual("file-22\n", run.output)
863 def test_443_zzcat_zap_test3_zip(self):
864 """ run zzcat-zap on test.zip using archive README """
865 zipfile = "test3.zip"
867 logfile = "test3.readme.zap.txt"
868 exe = self.bins("unzzip")
869 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
870 self.assertGreater(os.path.getsize(logfile), 10)
871 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
873 run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
874 self.assertEqual("file-999\n", run.output)
875 def test_444_zzcat_zap_test4_zip(self):
876 """ run zzcat-zap on test.zip using archive README """
877 zipfile = "test4.zip"
879 logfile = "test4.readme.zap.txt"
880 exe = self.bins("unzzip")
881 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
882 self.assertGreater(os.path.getsize(logfile), 10)
883 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
884 getfile = "file9999.txt"
885 run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
886 self.assertEqual("file-9999\n", run.output)
887 def test_445_zzcat_zap_test5_zip(self):
888 """ run zzcat-zap on test.zip using archive README """
889 zipfile = "test5.zip"
891 logfile = "test5.readme.zap.txt"
892 exe = self.bins("unzzip")
893 run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
894 self.assertGreater(os.path.getsize(logfile), 10)
895 self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
896 getfile = "subdir1/subdir2/subdir3/subdir4/subdir5/subdir6/file7-1024.txt"
897 compare = self.gentext(1024)
898 run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
899 self.assertEqual(compare, run.output)
901 def test_500_infozipdir_test0_zip(self):
902 """ run info-zip dir test0.zip """
903 zipfile = "test0.zip"
904 getfile = "test0.zip"
905 exe = self.bins("unzip")
906 run = shell("{exe} -l {getfile} ".format(**locals()))
907 self.assertIn(' README\n', run.output)
908 self.assertLess(len(run.output), 230)
909 def test_501_infozipdir_test1_zip(self):
910 """ run info-zip dir test1.zip """
911 zipfile = "test1.zip"
912 getfile = "test1.zip"
913 exe = self.bins("unzip")
914 run = shell("{exe} -l {getfile} ".format(**locals()))
915 self.assertIn(' file.1\n', run.output)
916 self.assertIn(' file.2\n', run.output)
917 self.assertIn(' file.9\n', run.output)
918 self.assertIn(' README\n', run.output)
919 def test_502_infozipdir_big_test2_zip(self):
920 """ run info-zip dir test2.zip """
921 zipfile = "test2.zip"
922 getfile = "test2.zip"
923 exe = self.bins("unzip")
924 run = shell("{exe} -l {getfile} ".format(**locals()))
925 self.assertIn(' file.01\n', run.output)
926 self.assertIn(' file.22\n', run.output)
927 self.assertIn(' file.99\n', run.output)
928 def test_503_infozipdir_big_test3_zip(self):
929 """ run info-zip dir test3.zip """
930 zipfile = "test3.zip"
931 getfile = "test3.zip"
932 exe = self.bins("unzip")
933 run = shell("{exe} -l {getfile} ".format(**locals()))
934 self.assertIn(' file.001\n', run.output)
935 self.assertIn(' file.222\n', run.output)
936 self.assertIn(' file.999\n', run.output)
937 def test_504_infozipdir_big_test4_zip(self):
938 """ run info-zip dir test4.zip """
939 zipfile = "test4.zip"
940 getfile = "test4.zip"
941 exe = self.bins("unzip")
942 run = shell("{exe} -l {getfile} ".format(**locals()))
943 self.assertIn(' file0001.txt\n', run.output)
944 self.assertIn(' file2222.txt\n', run.output)
945 self.assertIn(' file9999.txt\n', run.output)
946 def test_505_infozipdir_big_test5_zip(self):
947 """ run info-zip dir on test5.zip """
948 zipfile = "test5.zip"
949 getfile = "test5.zip"
950 exe = self.bins("unzzip-mix")
951 run = shell("{exe} -v {getfile} ".format(**locals()))
952 self.assertIn('/subdir14/file15-128.txt\n', run.output)
953 self.assertIn('/subdir5/subdir6/', run.output)
954 self.assertIn(' defl:N ', run.output)
955 self.assertIn(' stored ', run.output)
956 def test_510_zzdir_big_test0_zip(self):
957 """ run zzdir-big on test0.zip """
958 zipfile = "test0.zip"
959 getfile = "test0.zip"
960 exe = self.bins("unzzip-big")
961 run = shell("{exe} -l {getfile} ".format(**locals()))
962 self.assertIn(' README\n', run.output)
963 self.assertLess(len(run.output), 30)
964 def test_511_zzdir_big_test1_zip(self):
965 """ run zzdir-big on test1.zip """
966 zipfile = "test1.zip"
967 getfile = "test1.zip"
968 exe = self.bins("unzzip-big")
969 run = shell("{exe} -l {getfile} ".format(**locals()))
970 self.assertIn(' file.1\n', run.output)
971 self.assertIn(' file.2\n', run.output)
972 self.assertIn(' file.9\n', run.output)
973 self.assertIn(' README\n', run.output)
974 def test_512_zzdir_big_test2_zip(self):
975 """ run zzdir-big on test2.zip """
976 zipfile = "test2.zip"
977 getfile = "test2.zip"
978 exe = self.bins("unzzip-big")
979 run = shell("{exe} -l {getfile} ".format(**locals()))
980 self.assertIn(' file.01\n', run.output)
981 self.assertIn(' file.22\n', run.output)
982 self.assertIn(' file.99\n', run.output)
983 def test_513_zzdir_big_test3_zip(self):
984 """ run zzdir-big on test3.zip """
985 zipfile = "test3.zip"
986 getfile = "test3.zip"
987 exe = self.bins("unzzip-big")
988 run = shell("{exe} -l {getfile} ".format(**locals()))
989 self.assertIn(' file.001\n', run.output)
990 self.assertIn(' file.222\n', run.output)
991 self.assertIn(' file.999\n', run.output)
992 def test_514_zzdir_big_test4_zip(self):
993 """ run zzdir-big on test4.zip """
994 zipfile = "test4.zip"
995 getfile = "test4.zip"
996 exe = self.bins("unzzip-big")
997 run = shell("{exe} -l {getfile} ".format(**locals()))
998 self.assertIn(' file0001.txt\n', run.output)
999 self.assertIn(' file2222.txt\n', run.output)
1000 self.assertIn(' file9999.txt\n', run.output)
1001 def test_515_zzdir_big_test5_zip(self):
1002 """ run zzdir-big on test5.zip """
1003 zipfile = "test5.zip"
1004 getfile = "test5.zip"
1005 exe = self.bins("unzzip-mix")
1006 run = shell("{exe} -v {getfile} ".format(**locals()))
1007 self.assertIn('/subdir14/file15-128.txt\n', run.output)
1008 self.assertIn('/subdir5/subdir6/', run.output)
1009 self.assertIn(' defl:N ', run.output)
1010 self.assertIn(' stored ', run.output)
1011 def test_520_zzdir_mem_test0_zip(self):
1012 """ run zzdir-mem on test0.zip """
1013 zipfile = "test0.zip"
1014 getfile = "test0.zip"
1015 exe = self.bins("unzzip-mem")
1016 run = shell("{exe} -v {getfile} ".format(**locals()))
1017 self.assertIn(' README\n', run.output)
1018 self.assertIn(' defl:N ', run.output)
1019 self.assertLess(len(run.output), 30)
1020 def test_521_zzdir_mem_test1_zip(self):
1021 """ run zzdir-mem on test1.zip """
1022 zipfile = "test1.zip"
1023 getfile = "test1.zip"
1024 exe = self.bins("unzzip-mem")
1025 run = shell("{exe} -v {getfile} ".format(**locals()))
1026 self.assertIn(' file.1\n', run.output)
1027 self.assertIn(' file.2\n', run.output)
1028 self.assertIn(' file.9\n', run.output)
1029 self.assertIn(' README\n', run.output)
1030 self.assertIn(' defl:N ', run.output)
1031 self.assertIn(' stored ', run.output)
1032 def test_522_zzdir_mem_test2_zip(self):
1033 """ run zzdir-mem on test2.zip """
1034 zipfile = "test2.zip"
1035 getfile = "test2.zip"
1036 exe = self.bins("unzzip-mem")
1037 run = shell("{exe} -v {getfile} ".format(**locals()))
1038 self.assertIn(' file.01\n', run.output)
1039 self.assertIn(' file.22\n', run.output)
1040 self.assertIn(' file.99\n', run.output)
1041 self.assertIn(' defl:N ', run.output)
1042 self.assertIn(' stored ', run.output)
1043 def test_523_zzdir_mem_test3_zip(self):
1044 """ run zzdir-mem on test3.zip """
1045 zipfile = "test3.zip"
1046 getfile = "test3.zip"
1047 exe = self.bins("unzzip-mem")
1048 run = shell("{exe} -v {getfile} ".format(**locals()))
1049 self.assertIn(' file.001\n', run.output)
1050 self.assertIn(' file.222\n', run.output)
1051 self.assertIn(' file.999\n', run.output)
1052 self.assertIn(' defl:N ', run.output)
1053 self.assertIn(' stored ', run.output)
1054 def test_524_zzdir_mem_test4_zip(self):
1055 """ run zzdir-mem on test4.zip """
1056 zipfile = "test4.zip"
1057 getfile = "test4.zip"
1058 exe = self.bins("unzzip-mem")
1059 run = shell("{exe} -v {getfile} ".format(**locals()))
1060 self.assertIn(' file0001.txt\n', run.output)
1061 self.assertIn(' file2222.txt\n', run.output)
1062 self.assertIn(' file9999.txt\n', run.output)
1063 self.assertNotIn(' defl:N ', run.output)
1064 self.assertIn(' stored ', run.output)
1065 def test_525_zzdir_mem_test5_zip(self):
1066 """ run zzdir-mem on test5.zip """
1067 zipfile = "test5.zip"
1068 getfile = "test5.zip"
1069 exe = self.bins("unzzip-mix")
1070 run = shell("{exe} -v {getfile} ".format(**locals()))
1071 self.assertIn('/subdir14/file15-128.txt\n', run.output)
1072 self.assertIn('/subdir5/subdir6/', run.output)
1073 self.assertIn(' defl:N ', run.output)
1074 self.assertIn(' stored ', run.output)
1075 def test_530_zzdir_mix_test0_zip(self):
1076 """ run zzdir-mix on test0.zip """
1077 # self.skipTest("todo")
1078 zipfile = "test0.zip"
1079 getfile = "test0.zip"
1080 exe = self.bins("unzzip-mix")
1081 run = shell("{exe} -v {getfile} ".format(**locals()))
1082 self.assertIn(' README\n', run.output)
1083 self.assertIn(' defl:N ', run.output)
1084 self.assertLess(len(run.output), 30)
1085 def test_531_zzdir_mix_test1_zip(self):
1086 """ run zzdir-mix on test1.zip """
1087 zipfile = "test1.zip"
1088 getfile = "test1.zip"
1089 exe = self.bins("unzzip-mix")
1090 run = shell("{exe} -v {getfile} ".format(**locals()))
1091 self.assertIn(' file.1\n', run.output)
1092 self.assertIn(' file.2\n', run.output)
1093 self.assertIn(' file.9\n', run.output)
1094 self.assertIn(' README\n', run.output)
1095 self.assertIn(' defl:N ', run.output)
1096 self.assertIn(' stored ', run.output)
1097 def test_532_zzdir_mix_test2_zip(self):
1098 """ run zzdir-mix on test2.zip """
1099 zipfile = "test2.zip"
1100 getfile = "test2.zip"
1101 exe = self.bins("unzzip-mix")
1102 run = shell("{exe} -v {getfile} ".format(**locals()))
1103 self.assertIn(' file.01\n', run.output)
1104 self.assertIn(' file.22\n', run.output)
1105 self.assertIn(' file.99\n', run.output)
1106 self.assertIn(' defl:N ', run.output)
1107 self.assertIn(' stored ', run.output)
1108 def test_533_zzdir_mix_test3_zip(self):
1109 """ run zzdir-mix on test3.zip """
1110 zipfile = "test3.zip"
1111 getfile = "test3.zip"
1112 exe = self.bins("unzzip-mix")
1113 run = shell("{exe} -v {getfile} ".format(**locals()))
1114 self.assertIn(' file.001\n', run.output)
1115 self.assertIn(' file.222\n', run.output)
1116 self.assertIn(' file.999\n', run.output)
1117 self.assertIn(' defl:N ', run.output)
1118 self.assertIn(' stored ', run.output)
1119 def test_534_zzdir_mix_test4_zip(self):
1120 """ run zzdir-mix on test4.zip """
1121 zipfile = "test4.zip"
1122 getfile = "test4.zip"
1123 exe = self.bins("unzzip-mix")
1124 run = shell("{exe} -v {getfile} ".format(**locals()))
1125 self.assertIn(' file0001.txt\n', run.output)
1126 self.assertIn(' file2222.txt\n', run.output)
1127 self.assertIn(' file9999.txt\n', run.output)
1128 self.assertNotIn(' defl:N ', run.output)
1129 self.assertIn(' stored ', run.output)
1130 def test_535_zzdir_mix_test5_zip(self):
1131 """ run zzdir-mix on test5.zip """
1132 zipfile = "test5.zip"
1133 getfile = "test5.zip"
1134 exe = self.bins("unzzip-mix")
1135 run = shell("{exe} -v {getfile} ".format(**locals()))
1136 self.assertIn('/subdir14/file15-128.txt\n', run.output)
1137 self.assertIn('/subdir5/subdir6/', run.output)
1138 self.assertIn(' defl:N ', run.output)
1139 self.assertIn(' stored ', run.output)
1140 def test_540_zzdir_zap_test0_zip(self):
1141 """ run zzdir-zap on test0.zip """
1142 zipfile = "test0.zip"
1143 getfile = "test0.zip"
1144 exe = self.bins("unzzip")
1145 run = shell("{exe} -v {getfile} ".format(**locals()))
1146 self.assertIn(' README\n', run.output)
1147 self.assertIn(' defl:N ', run.output)
1148 self.assertLess(len(run.output), 30)
1149 def test_541_zzdir_zap_test1_zip(self):
1150 """ run zzdir-zap on test1.zip """
1151 zipfile = "test1.zip"
1152 getfile = "test1.zip"
1153 exe = self.bins("unzzip")
1154 run = shell("{exe} -v {getfile} ".format(**locals()))
1155 self.assertIn(' file.1\n', run.output)
1156 self.assertIn(' file.2\n', run.output)
1157 self.assertIn(' file.9\n', run.output)
1158 self.assertIn(' README\n', run.output)
1159 self.assertIn(' defl:N ', run.output)
1160 self.assertIn(' stored ', run.output)
1161 def test_542_zzdir_zap_test2_zip(self):
1162 """ run zzdir-zap on test2.zip """
1163 zipfile = "test2.zip"
1164 getfile = "test2.zip"
1165 exe = self.bins("unzzip")
1166 run = shell("{exe} -v {getfile} ".format(**locals()))
1167 self.assertIn(' file.01\n', run.output)
1168 self.assertIn(' file.22\n', run.output)
1169 self.assertIn(' file.99\n', run.output)
1170 self.assertIn(' defl:N ', run.output)
1171 self.assertIn(' stored ', run.output)
1172 def test_543_zzdir_zap_test3_zip(self):
1173 """ run zzdir-zap on test3.zip """
1174 zipfile = "test3.zip"
1175 getfile = "test3.zip"
1176 exe = self.bins("unzzip")
1177 run = shell("{exe} -v {getfile} ".format(**locals()))
1178 self.assertIn(' file.001\n', run.output)
1179 self.assertIn(' file.222\n', run.output)
1180 self.assertIn(' file.999\n', run.output)
1181 self.assertIn(' defl:N ', run.output)
1182 self.assertIn(' stored ', run.output)
1183 def test_544_zzdir_zap_test4_zip(self):
1184 """ run zzdir-zap on test4.zip """
1185 zipfile = "test4.zip"
1186 getfile = "test4.zip"
1187 exe = self.bins("unzzip")
1188 run = shell("{exe} -v {getfile} ".format(**locals()))
1189 self.assertIn(' file0001.txt\n', run.output)
1190 self.assertIn(' file2222.txt\n', run.output)
1191 self.assertIn(' file9999.txt\n', run.output)
1192 self.assertNotIn(' defl:N ', run.output)
1193 self.assertIn(' stored ', run.output)
1194 def test_545_zzdir_zap_test5_zip(self):
1195 """ run zzdir-zap on test5.zip """
1196 zipfile = "test5.zip"
1197 getfile = "test5.zip"
1198 exe = self.bins("unzzip")
1199 run = shell("{exe} -v {getfile} ".format(**locals()))
1200 self.assertIn('/subdir14/file15-128.txt\n', run.output)
1201 self.assertIn('/subdir5/subdir6/', run.output)
1202 self.assertIn(' defl:N ', run.output)
1203 self.assertIn(' stored ', run.output)
1204 def test_595_zzextract_zap_test5_zip(self):
1205 """ run zzextract-zap on test5.zip
1206 => coughs up a SEGFAULT in zzip_dir_close() ?!?"""
1207 zipfile = "test5.zip"
1208 getfile = "test5.zip"
1209 tmpdir = "tmp.test_595"
1211 exe = self.bins("unzzip")
1212 run = shell("cd {tmpdir} && ../{exe} ../{getfile} ".format(**locals()))
1213 self.assertTrue(tmpdir+'/subdir1/subdir2/file3-1024.txt')
1215 url_CVE_2017_5977 = "https://raw.githubusercontent.com/asarubbo/poc/master/"
1216 zip_CVE_2017_5977 = "00153-zziplib-invalidread-zzip_mem_entry_extra_block"
1217 def test_600_infozipdir_CVE_2017_5977(self):
1218 """ run info-zip dir test0.zip """
1219 tmpdir = "tmp.test_600"
1220 filename = self.zip_CVE_2017_5977
1221 file_url = self.url_CVE_2017_5977
1222 trycopy("tmp.test_601", filename, tmpdir)
1224 download(file_url, filename, tmpdir)
1225 exe = self.bins("unzip")
1226 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1227 returncodes = [0, 2])
1228 self.assertIn(" didn't find end-of-central-dir signature at end of central dir", run.errors)
1229 self.assertIn(" 2 extra bytes at beginning or within zipfile", run.errors)
1230 self.assertLess(len(run.output), 280)
1231 def test_601_zzipdir_big_CVE_2017_5977(self):
1232 """ run info-zip -l $(CVE_2017_5977).zip """
1233 tmpdir = "tmp.test_601"
1234 filename = self.zip_CVE_2017_5977
1235 file_url = self.url_CVE_2017_5977
1237 trycopy("tmp.test_600", filename, tmpdir)
1238 trycopy("tmp.test_602", filename, tmpdir)
1239 download(file_url, filename, tmpdir)
1240 exe = self.bins("unzzip-big")
1241 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1243 self.assertLess(len(run.output), 30)
1244 self.assertLess(len(run.errors), 1)
1245 self.assertIn(" stored test", run.output)
1246 def test_602_zzipdir_mem_CVE_2017_5977(self):
1247 """ run unzzip-mem -l $(CVE_2017_5977).zip """
1248 tmpdir = "tmp.test_602"
1249 filename = self.zip_CVE_2017_5977
1250 file_url = self.url_CVE_2017_5977
1252 trycopy("tmp.test_601", filename, tmpdir)
1253 trycopy("tmp.test_603", filename, tmpdir)
1254 download(file_url, filename, tmpdir)
1255 exe = self.bins("unzzip-mem")
1256 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1258 self.assertLess(len(run.output), 30)
1259 self.assertLess(len(run.errors), 1)
1260 self.assertIn(" 3 test", run.output)
1261 def test_603_zzipdir_mem_CVE_2017_5977(self):
1262 """ run unzzip-mem -l $(CVE_2017_5977).zip """
1263 tmpdir = "tmp.test_603"
1264 filename = self.zip_CVE_2017_5977
1265 file_url = self.url_CVE_2017_5977
1267 trycopy("tmp.test_602", filename, tmpdir)
1268 trycopy("tmp.test_604", filename, tmpdir)
1269 download(file_url, filename, tmpdir)
1270 exe = self.bins("unzzip-mem")
1271 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1273 self.assertLess(len(run.output), 30)
1274 self.assertLess(len(run.errors), 1)
1275 self.assertIn(" 3 test", run.output)
1276 def test_604_zzipdir_zap_CVE_2017_5977(self):
1277 """ run unzzip-mix -l $(CVE_2017_5977).zip """
1278 tmpdir = "tmp.test_604"
1279 filename = self.zip_CVE_2017_5977
1280 file_url = self.url_CVE_2017_5977
1282 trycopy("tmp.test_603", filename, tmpdir)
1283 download(file_url, filename, tmpdir)
1284 exe = self.bins("unzzip")
1285 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1286 returncodes = [0, 255])
1287 self.assertLess(len(run.output), 30)
1288 self.assertLess(len(run.errors), 1)
1289 self.assertIn(" 3 test", run.output)
1291 url_CVE_2017_5978 = "https://raw.githubusercontent.com/asarubbo/poc/master/"
1292 zip_CVE_2017_5978 = "00156-zziplib-oobread-zzip_mem_entry_new"
1293 def test_610_infozipdir_CVE_2017_5978(self):
1294 """ run info-zip dir test0.zip """
1295 tmpdir = "tmp.test_610"
1296 filename = self.zip_CVE_2017_5978
1297 file_url = self.url_CVE_2017_5978
1298 trycopy("tmp.test_611", filename, tmpdir)
1300 download(file_url, filename, tmpdir)
1301 exe = self.bins("unzip")
1302 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1303 returncodes = [0, 3])
1304 self.assertIn(' missing 4608 bytes in zipfile', run.errors)
1305 self.assertIn(' attempt to seek before beginning of zipfile', run.errors)
1306 self.assertLess(len(run.output), 80)
1307 self.assertLess(len(run.errors), 430)
1308 def test_611_zzipdir_big_CVE_2017_5978(self):
1309 """ run info-zip -l $(CVE_2017_5978).zip """
1310 tmpdir = "tmp.test_611"
1311 filename = self.zip_CVE_2017_5978
1312 file_url = self.url_CVE_2017_5978
1314 trycopy("tmp.test_610", filename, tmpdir)
1315 trycopy("tmp.test_612", filename, tmpdir)
1316 download(file_url, filename, tmpdir)
1317 exe = self.bins("unzzip-big")
1318 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1320 self.assertLess(len(run.output), 30)
1321 self.assertLess(len(run.errors), 1)
1322 self.assertIn(" stored (null)", run.output)
1323 def test_612_zzipdir_mem_CVE_2017_5978(self):
1324 """ run unzzip-mem -l $(CVE_2017_5978).zip """
1325 tmpdir = "tmp.test_612"
1326 filename = self.zip_CVE_2017_5978
1327 file_url = self.url_CVE_2017_5978
1329 trycopy("tmp.test_611", filename, tmpdir)
1330 trycopy("tmp.test_613", filename, tmpdir)
1331 download(file_url, filename, tmpdir)
1332 exe = self.bins("unzzip-mem")
1333 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1335 self.assertLess(len(run.output), 1)
1336 self.assertLess(len(run.errors), 180)
1337 self.assertIn("zzip_mem_disk_load : unable to load entry", run.errors)
1338 self.assertIn("zzip_mem_disk_open : unable to load disk", run.errors)
1339 def test_613_zzipdir_mem_CVE_2017_5978(self):
1340 """ run unzzip-mem -l $(CVE_2017_5978).zip """
1341 tmpdir = "tmp.test_613"
1342 filename = self.zip_CVE_2017_5978
1343 file_url = self.url_CVE_2017_5978
1345 trycopy("tmp.test_612", filename, tmpdir)
1346 trycopy("tmp.test_614", filename, tmpdir)
1347 download(file_url, filename, tmpdir)
1348 exe = self.bins("unzzip-mem")
1349 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1351 self.assertLess(len(run.output), 1)
1352 self.assertLess(len(run.errors), 180)
1353 self.assertIn("zzip_mem_disk_load : unable to load entry", run.errors)
1354 self.assertIn("zzip_mem_disk_open : unable to load disk", run.errors)
1355 @unittest.expectedFailure
1356 def test_614_zzipdir_zap_CVE_2017_5978(self):
1357 """ run unzzip-mix -l $(CVE_2017_5978).zip """
1358 tmpdir = "tmp.test_614"
1359 filename = self.zip_CVE_2017_5978
1360 file_url = self.url_CVE_2017_5978
1362 trycopy("tmp.test_613", filename, tmpdir)
1363 download(file_url, filename, tmpdir)
1364 exe = self.bins("unzzip")
1365 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1366 returncodes = [0, 255])
1367 self.assertLess(len(run.output), 1)
1368 self.assertLess(len(run.errors), 180)
1369 self.assertIn("zzip_mem_disk_load : unable to load entry", run.errors)
1370 self.assertIn("zzip_mem_disk_open : unable to load disk", run.errors)
1372 url_CVE_2017_5979 = "https://raw.githubusercontent.com/asarubbo/poc/master/"
1373 zip_CVE_2017_5979 = "00157-zziplib-nullptr-prescan_entry"
1374 def test_620_infozipdir_CVE_2017_5979(self):
1375 """ run info-zip dir test0.zip """
1376 tmpdir = "tmp.test_620"
1377 filename = self.zip_CVE_2017_5979
1378 file_url = self.url_CVE_2017_5979
1379 trycopy("tmp.test_621", filename, tmpdir)
1381 download(file_url, filename, tmpdir)
1382 exe = self.bins("unzip")
1383 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1385 self.assertIn(' 1 file', run.output)
1386 self.assertLess(len(run.output), 330)
1387 self.assertLess(len(run.errors), 1)
1388 def test_621_zzipdir_big_CVE_2017_5979(self):
1389 """ run info-zip -l $(CVE_2017_5979).zip """
1390 tmpdir = "tmp.test_621"
1391 filename = self.zip_CVE_2017_5979
1392 file_url = self.url_CVE_2017_5979
1394 trycopy("tmp.test_620", filename, tmpdir)
1395 trycopy("tmp.test_622", filename, tmpdir)
1396 download(file_url, filename, tmpdir)
1397 exe = self.bins("unzzip-big")
1398 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1400 self.assertLess(len(run.output), 30)
1401 self.assertLess(len(run.errors), 1)
1402 self.assertIn(" stored a", run.output)
1403 def test_622_zzipdir_mem_CVE_2017_5979(self):
1404 """ run unzzip-mem -l $(CVE_2017_5979).zip """
1405 tmpdir = "tmp.test_622"
1406 filename = self.zip_CVE_2017_5979
1407 file_url = self.url_CVE_2017_5979
1409 trycopy("tmp.test_621", filename, tmpdir)
1410 trycopy("tmp.test_623", filename, tmpdir)
1411 download(file_url, filename, tmpdir)
1412 exe = self.bins("unzzip-mem")
1413 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1415 self.assertLess(len(run.output), 30)
1416 self.assertLess(len(run.errors), 1)
1417 self.assertIn(" 3 a", run.output)
1418 def test_623_zzipdir_mem_CVE_2017_5979(self):
1419 """ run unzzip-mem -l $(CVE_2017_5979).zip """
1420 tmpdir = "tmp.test_623"
1421 filename = self.zip_CVE_2017_5979
1422 file_url = self.url_CVE_2017_5979
1424 trycopy("tmp.test_622", filename, tmpdir)
1425 trycopy("tmp.test_624", filename, tmpdir)
1426 download(file_url, filename, tmpdir)
1427 exe = self.bins("unzzip-mem")
1428 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1430 self.assertLess(len(run.output), 30)
1431 self.assertLess(len(run.errors), 1)
1432 self.assertIn(" 3 a", run.output)
1433 def test_624_zzipdir_zap_CVE_2017_5979(self):
1434 """ run unzzip-mix -l $(CVE_2017_5979).zip """
1435 tmpdir = "tmp.test_624"
1436 filename = self.zip_CVE_2017_5979
1437 file_url = self.url_CVE_2017_5979
1439 trycopy("tmp.test_623", filename, tmpdir)
1440 download(file_url, filename, tmpdir)
1441 exe = self.bins("unzzip")
1442 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1443 returncodes = [0, 255])
1444 self.assertLess(len(run.output), 30)
1445 self.assertLess(len(run.errors), 1)
1446 self.assertIn(" 3 a", run.output)
1448 url_CVE_2017_5974 = "https://raw.githubusercontent.com/asarubbo/poc/master/"
1449 zip_CVE_2017_5974 = "00150-zziplib-heapoverflow-__zzip_get32"
1450 def test_630_infozipdir_CVE_2017_5974(self):
1451 """ run info-zip dir test0.zip """
1452 tmpdir = "tmp.test_630"
1453 filename = self.zip_CVE_2017_5974
1454 file_url = self.url_CVE_2017_5974
1455 trycopy("tmp.test_631", filename, tmpdir)
1457 download(file_url, filename, tmpdir)
1458 exe = self.bins("unzip")
1459 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1460 returncodes = [0, 9])
1461 self.assertIn(' 1 file', run.output)
1462 self.assertLess(len(run.output), 330)
1463 self.assertLess(len(run.errors), 1)
1464 def test_631_zzipdir_big_CVE_2017_5974(self):
1465 """ run info-zip -l $(CVE_2017_5974).zip """
1466 tmpdir = "tmp.test_631"
1467 filename = self.zip_CVE_2017_5974
1468 file_url = self.url_CVE_2017_5974
1470 trycopy("tmp.test_630", filename, tmpdir)
1471 trycopy("tmp.test_632", filename, tmpdir)
1472 download(file_url, filename, tmpdir)
1473 exe = self.bins("unzzip-big")
1474 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1476 self.assertLess(len(run.output), 30)
1477 self.assertLess(len(run.errors), 1)
1478 self.assertIn(" stored test", run.output)
1479 def test_632_zzipdir_mem_CVE_2017_5974(self):
1480 """ run unzzip-mem -l $(CVE_2017_5974).zip """
1481 tmpdir = "tmp.test_632"
1482 filename = self.zip_CVE_2017_5974
1483 file_url = self.url_CVE_2017_5974
1485 trycopy("tmp.test_631", filename, tmpdir)
1486 trycopy("tmp.test_633", filename, tmpdir)
1487 download(file_url, filename, tmpdir)
1488 exe = self.bins("unzzip-mem")
1489 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1491 self.assertLess(len(run.output), 30)
1492 self.assertLess(len(run.errors), 1)
1493 self.assertIn(" 3 test", run.output)
1494 def test_633_zzipdir_mem_CVE_2017_5974(self):
1495 """ run unzzip-mem -l $(CVE_2017_5974).zip """
1496 tmpdir = "tmp.test_633"
1497 filename = self.zip_CVE_2017_5974
1498 file_url = self.url_CVE_2017_5974
1500 trycopy("tmp.test_632", filename, tmpdir)
1501 trycopy("tmp.test_634", filename, tmpdir)
1502 download(file_url, filename, tmpdir)
1503 exe = self.bins("unzzip-mem")
1504 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1506 self.assertLess(len(run.output), 30)
1507 self.assertLess(len(run.errors), 1)
1508 self.assertIn(" 3 test", run.output)
1509 def test_634_zzipdir_zap_CVE_2017_5974(self):
1510 """ run unzzip-mix -l $(CVE_2017_5974).zip """
1511 tmpdir = "tmp.test_634"
1512 filename = self.zip_CVE_2017_5974
1513 file_url = self.url_CVE_2017_5974
1515 trycopy("tmp.test_633", filename, tmpdir)
1516 download(file_url, filename, tmpdir)
1517 exe = self.bins("unzzip")
1518 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1519 returncodes = [0, 255])
1520 self.assertLess(len(run.output), 30)
1521 self.assertLess(len(run.errors), 1)
1522 self.assertIn(" 3 test", run.output)
1524 url_CVE_2017_5975 = "https://raw.githubusercontent.com/asarubbo/poc/master/"
1525 zip_CVE_2017_5975 = "00151-zziplib-heapoverflow-__zzip_get64"
1526 def test_640_infozipdir_CVE_2017_5975(self):
1527 """ run info-zip dir test0.zip """
1528 tmpdir = "tmp.test_640"
1529 filename = self.zip_CVE_2017_5975
1530 file_url = self.url_CVE_2017_5975
1531 trycopy("tmp.test_641", filename, tmpdir)
1533 download(file_url, filename, tmpdir)
1534 exe = self.bins("unzip")
1535 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1536 returncodes = [0, 2])
1537 self.assertIn(' missing 10 bytes in zipfile', run.errors)
1538 self.assertIn("didn't find end-of-central-dir signature at end of central dir", run.errors)
1539 self.assertIn(' 1 file', run.output)
1540 self.assertLess(len(run.output), 330)
1541 self.assertLess(len(run.errors), 430)
1542 def test_641_zzipdir_big_CVE_2017_5975(self):
1543 """ run info-zip -l $(CVE_2017_5975).zip """
1544 tmpdir = "tmp.test_641"
1545 filename = self.zip_CVE_2017_5975
1546 file_url = self.url_CVE_2017_5975
1548 trycopy("tmp.test_640", filename, tmpdir)
1549 trycopy("tmp.test_642", filename, tmpdir)
1550 download(file_url, filename, tmpdir)
1551 exe = self.bins("unzzip-big")
1552 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1554 self.assertLess(len(run.output), 30)
1555 self.assertLess(len(run.errors), 1)
1556 self.assertIn(" stored test", run.output)
1557 def test_642_zzipdir_mem_CVE_2017_5975(self):
1558 """ run unzzip-mem -l $(CVE_2017_5975).zip """
1559 tmpdir = "tmp.test_642"
1560 filename = self.zip_CVE_2017_5975
1561 file_url = self.url_CVE_2017_5975
1563 trycopy("tmp.test_641", filename, tmpdir)
1564 trycopy("tmp.test_643", filename, tmpdir)
1565 download(file_url, filename, tmpdir)
1566 exe = self.bins("unzzip-mem")
1567 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1569 self.assertLess(len(run.output), 1)
1570 self.assertLess(len(run.errors), 180)
1571 self.assertIn("zzip_mem_disk_load : unable to load entry", run.errors)
1572 self.assertIn("zzip_mem_disk_open : unable to load disk", run.errors)
1573 def test_643_zzipdir_mem_CVE_2017_5975(self):
1574 """ run unzzip-mem -l $(CVE_2017_5975).zip """
1575 tmpdir = "tmp.test_643"
1576 filename = self.zip_CVE_2017_5975
1577 file_url = self.url_CVE_2017_5975
1579 trycopy("tmp.test_642", filename, tmpdir)
1580 trycopy("tmp.test_644", filename, tmpdir)
1581 download(file_url, filename, tmpdir)
1582 exe = self.bins("unzzip-mem")
1583 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1585 self.assertLess(len(run.output), 1)
1586 self.assertLess(len(run.errors), 180)
1587 self.assertIn("zzip_mem_disk_load : unable to load entry", run.errors)
1588 self.assertIn("zzip_mem_disk_open : unable to load disk", run.errors)
1589 def test_644_zzipdir_zap_CVE_2017_5975(self):
1590 """ run unzzip-mix -l $(CVE_2017_5975).zip """
1591 tmpdir = "tmp.test_644"
1592 filename = self.zip_CVE_2017_5975
1593 file_url = self.url_CVE_2017_5975
1595 trycopy("tmp.test_643", filename, tmpdir)
1596 download(file_url, filename, tmpdir)
1597 exe = self.bins("unzzip")
1598 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1599 returncodes = [0, 255])
1600 self.assertLess(len(run.output), 1)
1601 self.assertLess(len(run.errors), 180)
1602 self.assertIn(": Success", run.errors)
1604 url_CVE_2017_5976 = "https://raw.githubusercontent.com/asarubbo/poc/master/"
1605 zip_CVE_2017_5976 = "00152-zziplib-heapoverflow-zzip_mem_entry_extra_block"
1606 def test_650_infozipdir_CVE_2017_5976(self):
1607 """ run info-zip dir test0.zip """
1608 tmpdir = "tmp.test_650"
1609 filename = self.zip_CVE_2017_5976
1610 file_url = self.url_CVE_2017_5976
1611 trycopy("tmp.test_651", filename, tmpdir)
1613 download(file_url, filename, tmpdir)
1614 exe = self.bins("unzip")
1615 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1616 returncodes = [0, 2])
1617 self.assertIn(' 27 extra bytes at beginning or within zipfile', run.errors)
1618 self.assertIn("didn't find end-of-central-dir signature at end of central dir", run.errors)
1619 self.assertIn(' 1 file', run.output)
1620 self.assertLess(len(run.output), 330)
1621 self.assertLess(len(run.errors), 500)
1622 def test_651_zzipdir_big_CVE_2017_5976(self):
1623 """ run info-zip -l $(CVE_2017_5976).zip """
1624 tmpdir = "tmp.test_651"
1625 filename = self.zip_CVE_2017_5976
1626 file_url = self.url_CVE_2017_5976
1628 trycopy("tmp.test_650", filename, tmpdir)
1629 trycopy("tmp.test_652", filename, tmpdir)
1630 download(file_url, filename, tmpdir)
1631 exe = self.bins("unzzip-big")
1632 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1634 self.assertLess(len(run.output), 30)
1635 self.assertLess(len(run.errors), 1)
1636 self.assertIn(" stored test", run.output)
1637 def test_652_zzipdir_mem_CVE_2017_5976(self):
1638 """ run unzzip-mem -l $(CVE_2017_5976).zip """
1639 tmpdir = "tmp.test_652"
1640 filename = self.zip_CVE_2017_5976
1641 file_url = self.url_CVE_2017_5976
1643 trycopy("tmp.test_651", filename, tmpdir)
1644 trycopy("tmp.test_653", filename, tmpdir)
1645 download(file_url, filename, tmpdir)
1646 exe = self.bins("unzzip-mem")
1647 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1649 self.assertLess(len(run.output), 30)
1650 self.assertLess(len(run.errors), 1)
1651 self.assertIn("3 test", run.output)
1652 def test_653_zzipdir_mem_CVE_2017_5976(self):
1653 """ run unzzip-mem -l $(CVE_2017_5976).zip """
1654 tmpdir = "tmp.test_653"
1655 filename = self.zip_CVE_2017_5976
1656 file_url = self.url_CVE_2017_5976
1658 trycopy("tmp.test_652", filename, tmpdir)
1659 trycopy("tmp.test_654", filename, tmpdir)
1660 download(file_url, filename, tmpdir)
1661 exe = self.bins("unzzip-mem")
1662 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1664 self.assertLess(len(run.output), 30)
1665 self.assertLess(len(run.errors), 1)
1666 self.assertIn("3 test", run.output)
1667 def test_654_zzipdir_zap_CVE_2017_5976(self):
1668 """ run unzzip-mix -l $(CVE_2017_5976).zip """
1669 tmpdir = "tmp.test_654"
1670 filename = self.zip_CVE_2017_5976
1671 file_url = self.url_CVE_2017_5976
1673 trycopy("tmp.test_653", filename, tmpdir)
1674 download(file_url, filename, tmpdir)
1675 exe = self.bins("unzzip")
1676 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1677 returncodes = [0, 255])
1678 self.assertLess(len(run.output), 30)
1679 self.assertLess(len(run.errors), 1)
1680 self.assertIn("3 test", run.output)
1682 url_CVE_2017_5980 = "https://raw.githubusercontent.com/asarubbo/poc/master/"
1683 zip_CVE_2017_5980 = "00154-zziplib-nullptr-zzip_mem_entry_new"
1684 def test_660_infozipdir_CVE_2017_5980(self):
1685 """ run info-zip dir test0.zip """
1686 tmpdir = "tmp.test_660"
1687 filename = self.zip_CVE_2017_5980
1688 file_url = self.url_CVE_2017_5980
1689 trycopy("tmp.test_661", filename, tmpdir)
1691 download(file_url, filename, tmpdir)
1692 exe = self.bins("unzip")
1693 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1694 returncodes = [0, 2])
1695 self.assertIn(' missing 6 bytes in zipfile', run.errors)
1696 self.assertIn("didn't find end-of-central-dir signature at end of central dir", run.errors)
1697 self.assertIn(' 1 file', run.output)
1698 self.assertLess(len(run.output), 330)
1699 self.assertLess(len(run.errors), 500)
1700 def test_661_zzipdir_big_CVE_2017_5980(self):
1701 """ run info-zip -l $(CVE_2017_5980).zip """
1702 tmpdir = "tmp.test_661"
1703 filename = self.zip_CVE_2017_5980
1704 file_url = self.url_CVE_2017_5980
1706 trycopy("tmp.test_660", filename, tmpdir)
1707 trycopy("tmp.test_662", filename, tmpdir)
1708 download(file_url, filename, tmpdir)
1709 exe = self.bins("unzzip-big")
1710 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1712 self.assertLess(len(run.output), 30)
1713 self.assertLess(len(run.errors), 1)
1714 self.assertIn(" stored (null)", run.output)
1715 def test_662_zzipdir_mem_CVE_2017_5980(self):
1716 """ run unzzip-mem -l $(CVE_2017_5980).zip """
1717 tmpdir = "tmp.test_662"
1718 filename = self.zip_CVE_2017_5980
1719 file_url = self.url_CVE_2017_5980
1721 trycopy("tmp.test_661", filename, tmpdir)
1722 trycopy("tmp.test_663", filename, tmpdir)
1723 download(file_url, filename, tmpdir)
1724 exe = self.bins("unzzip-mem")
1725 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1727 self.assertLess(len(run.output), 1)
1728 self.assertLess(len(run.errors), 180)
1729 self.assertIn("zzip_mem_disk_load : unable to load entry", run.errors)
1730 self.assertIn("zzip_mem_disk_open : unable to load disk", run.errors)
1731 def test_663_zzipdir_mem_CVE_2017_5980(self):
1732 """ run unzzip-mem -l $(CVE_2017_5980).zip """
1733 tmpdir = "tmp.test_663"
1734 filename = self.zip_CVE_2017_5980
1735 file_url = self.url_CVE_2017_5980
1737 trycopy("tmp.test_662", filename, tmpdir)
1738 trycopy("tmp.test_664", filename, tmpdir)
1739 download(file_url, filename, tmpdir)
1740 exe = self.bins("unzzip-mem")
1741 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1743 self.assertLess(len(run.output), 1)
1744 self.assertLess(len(run.errors), 180)
1745 self.assertIn("zzip_mem_disk_load : unable to load entry", run.errors)
1746 self.assertIn("zzip_mem_disk_open : unable to load disk", run.errors)
1747 def test_664_zzipdir_zap_CVE_2017_5980(self):
1748 """ run unzzip-mix -l $(CVE_2017_5980).zip """
1749 tmpdir = "tmp.test_664"
1750 filename = self.zip_CVE_2017_5980
1751 file_url = self.url_CVE_2017_5980
1753 trycopy("tmp.test_663", filename, tmpdir)
1754 download(file_url, filename, tmpdir)
1755 exe = self.bins("unzzip")
1756 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1757 returncodes = [0, 255])
1758 self.assertLess(len(run.output), 1)
1759 self.assertLess(len(run.errors), 180)
1760 self.assertIn(": Success", run.errors)
1762 url_CVE_2017_5981 = "https://raw.githubusercontent.com/asarubbo/poc/master/"
1763 zip_CVE_2017_5981 = "00161-zziplib-assertionfailure-seeko_C"
1764 def test_670_infozipdir_CVE_2017_5981(self):
1765 """ run info-zip dir test0.zip """
1766 tmpdir = "tmp.test_670"
1767 filename = self.zip_CVE_2017_5981
1768 file_url = self.url_CVE_2017_5981
1769 trycopy("tmp.test_671", filename, tmpdir)
1771 download(file_url, filename, tmpdir)
1772 exe = self.bins("unzip")
1773 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1774 returncodes = [0, 3])
1775 self.assertIn(' missing 4 bytes in zipfile', run.errors)
1776 self.assertIn("zipfile corrupt", run.errors)
1777 self.assertLess(len(run.output), 80)
1778 self.assertLess(len(run.errors), 500)
1779 def test_671_zzipdir_big_CVE_2017_5981(self):
1780 """ run info-zip -l $(CVE_2017_5981).zip """
1781 tmpdir = "tmp.test_671"
1782 filename = self.zip_CVE_2017_5981
1783 file_url = self.url_CVE_2017_5981
1785 trycopy("tmp.test_670", filename, tmpdir)
1786 trycopy("tmp.test_672", filename, tmpdir)
1787 download(file_url, filename, tmpdir)
1788 exe = self.bins("unzzip-big")
1789 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1791 self.assertLess(len(run.output), 1)
1792 self.assertLess(len(run.errors), 1)
1793 def test_672_zzipdir_mem_CVE_2017_5981(self):
1794 """ run unzzip-mem -l $(CVE_2017_5981).zip """
1795 tmpdir = "tmp.test_672"
1796 filename = self.zip_CVE_2017_5981
1797 file_url = self.url_CVE_2017_5981
1799 trycopy("tmp.test_671", filename, tmpdir)
1800 trycopy("tmp.test_673", filename, tmpdir)
1801 download(file_url, filename, tmpdir)
1802 exe = self.bins("unzzip-mem")
1803 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1805 self.assertLess(len(run.output), 1)
1806 self.assertLess(len(run.errors), 1)
1807 def test_673_zzipdir_mem_CVE_2017_5981(self):
1808 """ run unzzip-mem -l $(CVE_2017_5981).zip """
1809 tmpdir = "tmp.test_673"
1810 filename = self.zip_CVE_2017_5981
1811 file_url = self.url_CVE_2017_5981
1813 trycopy("tmp.test_672", filename, tmpdir)
1814 trycopy("tmp.test_674", filename, tmpdir)
1815 download(file_url, filename, tmpdir)
1816 exe = self.bins("unzzip-mem")
1817 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1819 self.assertLess(len(run.output), 1)
1820 self.assertLess(len(run.errors), 1)
1821 def test_674_zzipdir_zap_CVE_2017_5981(self):
1822 """ run unzzip-mix -l $(CVE_2017_5981).zip """
1823 tmpdir = "tmp.test_674"
1824 filename = self.zip_CVE_2017_5981
1825 file_url = self.url_CVE_2017_5981
1827 trycopy("tmp.test_673", filename, tmpdir)
1828 download(file_url, filename, tmpdir)
1829 exe = self.bins("unzzip")
1830 run = shell("{exe} -l {tmpdir}/{filename} ".format(**locals()),
1831 returncodes = [0, 255])
1832 self.assertLess(len(run.output), 1)
1833 self.assertLess(len(run.errors), 80)
1834 self.assertIn(": Success", run.errors)
1836 def test_800_zzshowme_check_sfx(self):
1837 """ create an *.exe that can extract its own zip content """
1838 exe=self.bins("mkzip")
1839 exefile = "tmp.zzshowme" + exeext
1840 libstub = ".libs/zzipself" + exeext
1841 txtfile_name = readme
1842 txtfile = self.src(readme)
1843 # add the extract-stub so we have reserved the size
1844 run = shell("{exe} -0 -j {exefile}.zip {libstub}".format(**locals()))
1845 self.assertFalse(run.returncode)
1846 # add the actual content which may now be compressed
1847 run = shell("{exe} -9 -j {exefile}.zip {txtfile}".format(**locals()))
1848 self.assertFalse(run.returncode)
1849 # rename .zip to .exe and put the extract-stub at the start
1850 shutil.copy(exefile+".zip", exefile)
1851 setstub="./zzipsetstub" + exeext
1852 run = shell("{setstub} {exefile} {libstub}".format(**locals()))
1853 self.assertFalse(run.returncode)
1854 os.chmod(exefile, 0755)
1855 # now ask the new .exe to show some of its own content
1856 run = shell("./{exefile} {txtfile_name}".format(**locals()))
1857 self.assertFalse(run.returncode)
1858 txt = open(txtfile).read()
1859 self.assertEqual(txt.split("\n"), run.output.split("\n"))
1861 def test_900_make_test1w_zip(self):
1862 """ create a test1w.zip using zzip/write functions. """
1863 exe=self.bins("zzip")
1864 run = shell("{exe} --version".format(**locals()))
1865 if "- NO -" in run.output:
1866 self.skipTest("- NO -D_ZZIP_ENABLE_WRITE")
1868 zipfile="test1w.zip"
1870 exe=self.bins("zzip")
1871 for i in [1,2,3,4,5,6,7,8,9]:
1872 filename = os.path.join(tmpdir,"file.%i" % i)
1873 filetext = "file-%i\n" % i
1874 self.mkfile(filename, filetext)
1875 filename = os.path.join(tmpdir,"README")
1876 filetext = self.readme()
1877 self.mkfile(filename, filetext)
1878 try: os.remove(zipfile)
1880 shell("../{exe} ../{zipfile} ??*.* README".format(**locals()), cwd=tmpdir)
1881 self.assertGreater(os.path.getsize(zipfile), 10)
1886 if __name__ == "__main__":
1888 _o = optparse.OptionParser("%prog [options] test_xxx")
1889 _o.add_option("-b", "--topsrcdir", metavar="DIR", default=topsrcdir,
1890 help="path to the top srcdir / unpack directory [%default]")
1891 _o.add_option("-t", "--testdatadir", metavar="DIR", default=testdatadir,
1892 help="path where temporary testdata is created [%default]")
1893 _o.add_option("-Z", "--mkzip", metavar="EXE", default=mkzip,
1894 help="name or path to zip.exe for *.zip creation [%default]")
1895 _o.add_option("-U", "--unzip", metavar="EXE", default=unzip,
1896 help="name or path to unzip.exe to unpack *.zip [%default]")
1897 _o.add_option("-E", "--exeext", metavar="EXT", default=exeext,
1898 help="the executable extension (automake $(EXEEXT)) [%default]")
1899 _o.add_option("--xmlresults", action="store_true", default=False,
1900 help="print output in junit xml testresult format [%default]")
1901 _o.add_option("-v", "--verbose", action="count", default=0,
1902 help="increase logging output [%default]")
1903 opt, args = _o.parse_args()
1904 logging.basicConfig(level = logging.WARNING - 10 * opt.verbose)
1905 topsrcdir = opt.topsrcdir
1906 testdatdir = opt.testdatadir
1910 if not args: args += [ "test_" ]
1911 suite = unittest.TestSuite()
1913 for classname in sorted(list(globals())):
1914 if not classname.endswith("Test"):
1916 testclass = globals()[classname]
1917 for method in sorted(dir(testclass)):
1918 if "*" not in arg: arg += "*"
1919 if arg.startswith("_"): arg = arg[1:]
1920 if matches(method, arg):
1921 suite.addTest(testclass(method))
1922 # TextTestRunner(verbosity=opt.verbose).run(suite)
1925 Runner = xmlrunner.XMLTestRunner
1926 Runner(xmlresults).run(suite)
1928 Runner = unittest.TextTestRunner
1929 Runner(verbosity=opt.verbose).run(suite)