Skip to content

Commit

Permalink
Add tests for directory entries
Browse files Browse the repository at this point in the history
  • Loading branch information
pmqs committed Dec 28, 2023
1 parent b355bad commit f187a63
Show file tree
Hide file tree
Showing 82 changed files with 2,061 additions and 29 deletions.
107 changes: 80 additions & 27 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -398,35 +398,71 @@ t/files/0001-simple-zip/readme.md
t/files/0001-simple-zip/stdout
t/files/0001-simple-zip/stdout-v
t/files/0001-simple-zip/test.zip
t/files/0002-7z/7z-linux-aes128/7z-linux-aes128.zip
t/files/0002-7z/7z-linux-aes128/stdout
t/files/0002-7z/7z-linux-aes128/stdout-v
t/files/0002-7z/7z-linux-aes192/7z-linux-aes192.zip
t/files/0002-7z/7z-linux-aes192/stdout
t/files/0002-7z/7z-linux-aes192/stdout-v
t/files/0002-7z/7z-linux-aes256/7z-linux-aes256.zip
t/files/0002-7z/7z-linux-aes256/stdout
t/files/0002-7z/7z-linux-aes256/stdout-v
t/files/0002-7z/7z-linux-bzip2/7z-linux-bzip2.zip
t/files/0002-7z/7z-linux-bzip2/stdout
t/files/0002-7z/7z-linux-bzip2/stdout-v
t/files/0002-7z/7z-linux-copy/7z-linux-copy.zip
t/files/0002-7z/7z-linux-copy/stdout
t/files/0002-7z/7z-linux-copy/stdout-v
t/files/0002-7z/7z-linux-deflate64/7z-linux-deflate64.zip
t/files/0002-7z/7z-linux-deflate64/stdout
t/files/0002-7z/7z-linux-deflate64/stdout-v
t/files/0002-7z/7z-linux-lzma/7z-linux-lzma.zip
t/files/0002-7z/7z-linux-lzma/stdout
t/files/0002-7z/7z-linux-lzma/stdout-v
t/files/0002-7z/7z-linux-ppmd/7z-linux-ppmd.zip
t/files/0002-7z/7z-linux-ppmd/stdout
t/files/0002-7z/7z-linux-ppmd/stdout-v
t/files/0002-7z/7z-linux-zipcrypto/7z-linux-zipcrypto.zip
t/files/0002-7z/7z-linux-zipcrypto/stdout
t/files/0002-7z/7z-linux-zipcrypto/stdout-v
t/files/0002-7z/linux/7z-linux-aes128/7z-linux-aes128.zip
t/files/0002-7z/linux/7z-linux-aes128/stdout
t/files/0002-7z/linux/7z-linux-aes128/stdout-v
t/files/0002-7z/linux/7z-linux-aes192/7z-linux-aes192.zip
t/files/0002-7z/linux/7z-linux-aes192/stdout
t/files/0002-7z/linux/7z-linux-aes192/stdout-v
t/files/0002-7z/linux/7z-linux-aes256/7z-linux-aes256.zip
t/files/0002-7z/linux/7z-linux-aes256/stdout
t/files/0002-7z/linux/7z-linux-aes256/stdout-v
t/files/0002-7z/linux/7z-linux-bzip2/7z-linux-bzip2.zip
t/files/0002-7z/linux/7z-linux-bzip2/stdout
t/files/0002-7z/linux/7z-linux-bzip2/stdout-v
t/files/0002-7z/linux/7z-linux-copy/7z-linux-copy.zip
t/files/0002-7z/linux/7z-linux-copy/stdout
t/files/0002-7z/linux/7z-linux-copy/stdout-v
t/files/0002-7z/linux/7z-linux-deflate64/7z-linux-deflate64.zip
t/files/0002-7z/linux/7z-linux-deflate64/stdout
t/files/0002-7z/linux/7z-linux-deflate64/stdout-v
t/files/0002-7z/linux/7z-linux-directory/7z-linux-directory.zip
t/files/0002-7z/linux/7z-linux-directory/stdout
t/files/0002-7z/linux/7z-linux-directory/stdout-v
t/files/0002-7z/linux/7z-linux-lzma/7z-linux-lzma.zip
t/files/0002-7z/linux/7z-linux-lzma/stdout
t/files/0002-7z/linux/7z-linux-lzma/stdout-v
t/files/0002-7z/linux/7z-linux-ppmd/7z-linux-ppmd.zip
t/files/0002-7z/linux/7z-linux-ppmd/stdout
t/files/0002-7z/linux/7z-linux-ppmd/stdout-v
t/files/0002-7z/linux/7z-linux-zipcrypto/7z-linux-zipcrypto.zip
t/files/0002-7z/linux/7z-linux-zipcrypto/stdout
t/files/0002-7z/linux/7z-linux-zipcrypto/stdout-v
t/files/0002-7z/lorem.txt
t/files/0002-7z/readme.md
t/files/0002-7z/windows/7z-windows-aes128/7z-windows-aes128.zip
t/files/0002-7z/windows/7z-windows-aes128/stdout
t/files/0002-7z/windows/7z-windows-aes128/stdout-v
t/files/0002-7z/windows/7z-windows-aes192/7z-windows-aes192.zip
t/files/0002-7z/windows/7z-windows-aes192/stdout
t/files/0002-7z/windows/7z-windows-aes192/stdout-v
t/files/0002-7z/windows/7z-windows-aes256/7z-windows-aes256.zip
t/files/0002-7z/windows/7z-windows-aes256/stdout
t/files/0002-7z/windows/7z-windows-aes256/stdout-v
t/files/0002-7z/windows/7z-windows-bzip2/7z-windows-bzip2.zip
t/files/0002-7z/windows/7z-windows-bzip2/stdout
t/files/0002-7z/windows/7z-windows-bzip2/stdout-v
t/files/0002-7z/windows/7z-windows-copy/7z-windows-copy.zip
t/files/0002-7z/windows/7z-windows-copy/stdout
t/files/0002-7z/windows/7z-windows-copy/stdout-v
t/files/0002-7z/windows/7z-windows-deflate64/7z-windows-deflate64.zip
t/files/0002-7z/windows/7z-windows-deflate64/stdout
t/files/0002-7z/windows/7z-windows-deflate64/stdout-v
t/files/0002-7z/windows/7z-windows-directory/7z-windows-directory.zip
t/files/0002-7z/windows/7z-windows-directory/stdout
t/files/0002-7z/windows/7z-windows-directory/stdout-v
t/files/0002-7z/windows/7z-windows-lzma/7z-windows-lzma.zip
t/files/0002-7z/windows/7z-windows-lzma/stdout
t/files/0002-7z/windows/7z-windows-lzma/stdout-v
t/files/0002-7z/windows/7z-windows-ppmd/7z-windows-ppmd.zip
t/files/0002-7z/windows/7z-windows-ppmd/stdout
t/files/0002-7z/windows/7z-windows-ppmd/stdout-v
t/files/0002-7z/windows/7z-windows-sfx/7z-windows-sfx.zip
t/files/0002-7z/windows/7z-windows-sfx/stdout
t/files/0002-7z/windows/7z-windows-sfx/stdout-v
t/files/0002-7z/windows/7z-windows-zipcrypto/7z-windows-zipcrypto.zip
t/files/0002-7z/windows/7z-windows-zipcrypto/stdout
t/files/0002-7z/windows/7z-windows-zipcrypto/stdout-v
t/files/0003-winzip/ee-enhancedDeflate/stdout
t/files/0003-winzip/ee-enhancedDeflate/stdout-v
t/files/0003-winzip/ee-enhancedDeflate/winzip-ee-enhancedDeflate.zip
Expand Down Expand Up @@ -457,6 +493,9 @@ t/files/0003-winzip/self-extracting/exe/winzip-sfx.exe
t/files/0003-winzip/self-extracting/zip/stdout
t/files/0003-winzip/self-extracting/zip/stdout-v
t/files/0003-winzip/self-extracting/zip/winzip-sfx.zip
t/files/0003-winzip/winzip-directory/stdout
t/files/0003-winzip/winzip-directory/stdout-v
t/files/0003-winzip/winzip-directory/winzip-directory.zip
t/files/0003-winzip/winzip-duplicate/stdout
t/files/0003-winzip/winzip-duplicate/stdout-v
t/files/0003-winzip/winzip-duplicate/winzip-duplicate.zipx
Expand Down Expand Up @@ -520,6 +559,9 @@ t/files/0007-mvs/stdout--walk--scan
t/files/0008-jar/jar.zip
t/files/0008-jar/stdout
t/files/0008-jar/stdout-v
t/files/0009-infozip/iz-linux-directory/iz-linux-directory.zip
t/files/0009-infozip/iz-linux-directory/stdout
t/files/0009-infozip/iz-linux-directory/stdout-v
t/files/0009-infozip/iz-linux-encrypt/iz-linux-encrypt.zip
t/files/0009-infozip/iz-linux-encrypt/stdout
t/files/0009-infozip/iz-linux-encrypt/stdout-v
Expand Down Expand Up @@ -615,6 +657,9 @@ t/files/0016-pkzip/pkzip-204/stdout-v
t/files/0016-pkzip/pkzip-default/pkzip-default.zip
t/files/0016-pkzip/pkzip-default/stdout
t/files/0016-pkzip/pkzip-default/stdout-v
t/files/0016-pkzip/pkzip-directory/pkzip-directory.zip
t/files/0016-pkzip/pkzip-directory/stdout
t/files/0016-pkzip/pkzip-directory/stdout-v
t/files/0016-pkzip/pkzip-encrypt-passphrase-3des168-cd/control
t/files/0016-pkzip/pkzip-encrypt-passphrase-3des168-cd/pkzip-encrypt-passphrase-3des168-cd.zip
t/files/0016-pkzip/pkzip-encrypt-passphrase-3des168-cd/stdout
Expand Down Expand Up @@ -850,13 +895,21 @@ t/files/0020-zip64-eocd-extra-field/v1/stdout
t/files/0020-zip64-eocd-extra-field/v1/stdout-v
t/files/0020-zip64-eocd-extra-field/v1/zip64-eocd-extra-field-v1.zip
t/files/0020-zip64-eocd-extra-field/v2/control
t/files/0020-zip64-eocd-extra-field/v2/cover_db/digests
t/files/0020-zip64-eocd-extra-field/v2/cover_db/digests.lock
t/files/0020-zip64-eocd-extra-field/v2/cover_db/runs/1668333608.71264.35898/cover.14
t/files/0020-zip64-eocd-extra-field/v2/cover_db/runs/1668333608.71264.35898/cover.14.lock
t/files/0020-zip64-eocd-extra-field/v2/stdout
t/files/0020-zip64-eocd-extra-field/v2/stdout--scan
t/files/0020-zip64-eocd-extra-field/v2/stdout-v
t/files/0020-zip64-eocd-extra-field/v2/stdout-v--scan
t/files/0020-zip64-eocd-extra-field/v2/stdout-v--walk
t/files/0020-zip64-eocd-extra-field/v2/stdout--walk
t/files/0020-zip64-eocd-extra-field/v2/zip64-eocd-extra-field-v2.zip
t/files/0021-minizip-ng/directory/directory.zip
t/files/0021-minizip-ng/directory/stdout
t/files/0021-minizip-ng/directory/stdout-v
t/files/0021-minizip-ng/l
t/files/0021-minizip-ng/lorem.txt
t/files/0021-minizip-ng/minizip-ng-master/secure/control
t/files/0021-minizip-ng/minizip-ng-master/secure/deflate-secure.zip
Expand Down
2 changes: 1 addition & 1 deletion t/002-main.t
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use Fcntl qw(SEEK_SET);

my $tests_per_zip = 6 ;
my $tests_per_zip_full = $tests_per_zip * 2 * 3 * 2 ;
plan tests => 194 * $tests_per_zip_full ;
plan tests => 210 * $tests_per_zip_full ;

sub run;
sub compareWithGolden;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
57 changes: 57 additions & 0 deletions t/files/0002-7z/linux/7z-linux-directory/stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

0000 LOCAL HEADER #1 04034B50 (67324752)
0004 Extract Zip Spec 14 (20) '2.0'
0005 Extract OS 03 (3) 'Unix'
0006 General Purpose Flag 0000 (0)
0008 Compression Method 0000 (0) 'Stored'
000A Last Mod Date/Time 579C937A (1469879162) 'Thu Dec 28 18:27:52 2023'
000E CRC 00000000 (0)
0012 Compressed Size 00000000 (0)
0016 Uncompressed Size 00000000 (0)
001A Filename Length 0008 (8)
001C Extra Length 0000 (0)
001E Filename 'somedir/'

0026 CENTRAL HEADER #1 02014B50 (33639248)
002A Created Zip Spec 3F (63) '6.3'
002B Created OS 03 (3) 'Unix'
002C Extract Zip Spec 14 (20) '2.0'
002D Extract OS 03 (3) 'Unix'
002E General Purpose Flag 0000 (0)
0030 Compression Method 0000 (0) 'Stored'
0032 Last Mod Date/Time 579C937A (1469879162) 'Thu Dec 28 18:27:52 2023'
0036 CRC 00000000 (0)
003A Compressed Size 00000000 (0)
003E Uncompressed Size 00000000 (0)
0042 Filename Length 0008 (8)
0044 Extra Length 0024 (36)
0046 Comment Length 0000 (0)
0048 Disk Start 0000 (0)
004A Int File Attributes 0000 (0)
[Bit 0] 0 'Binary Data'
004C Ext File Attributes 41FD8010 (1107132432)
[Bit 4] Directory
[Bits 11-15] 8000 (32768) 'Unknown DOS attrib'
[Bits 16-24] 01FD (509) 'Unix attrib: rwxrwxr-x'
[Bits 28-31] 04 (4) 'Directory'
0050 Local Header Offset 00000000 (0)
0054 Filename 'somedir/'
005C Extra ID #1 000A (10) 'NTFS FileTimes'
005E Length 0020 (32)
0060 Reserved 00000000 (0)
0064 Tag1 0001 (1)
0066 Size1 0018 (24)
0068 Mtime 01DA39BB91490400 (133482616720000000) 'Thu Dec 28 18:27:52 2023 0ns'
0070 Atime 01DA39BB91490400 (133482616720000000) 'Thu Dec 28 18:27:52 2023 0ns'
0078 Ctime 01DA39BB91490400 (133482616720000000) 'Thu Dec 28 18:27:52 2023 0ns'

0080 END CENTRAL HEADER 06054B50 (101010256)
0084 Number of this disk 0000 (0)
0086 Central Dir Disk no 0000 (0)
0088 Entries in this disk 0001 (1)
008A Total Entries 0001 (1)
008C Size of Central Dir 0000005A (90)
0090 Offset to Central Dir 00000026 (38)
0094 Comment Length 0000 (0)
#
# Done
62 changes: 62 additions & 0 deletions t/files/0002-7z/linux/7z-linux-directory/stdout-v
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

0000 0003 0004 50 4B 03 04 LOCAL HEADER #1 04034B50 (67324752)
0004 0004 0001 14 Extract Zip Spec 14 (20) '2.0'
0005 0005 0001 03 Extract OS 03 (3) 'Unix'
0006 0007 0002 00 00 General Purpose Flag 0000 (0)
0008 0009 0002 00 00 Compression Method 0000 (0) 'Stored'
000A 000D 0004 7A 93 9C 57 Last Mod Date/Time 579C937A (1469879162) 'Thu Dec 28 18:27:52 2023'
000E 0011 0004 00 00 00 00 CRC 00000000 (0)
0012 0015 0004 00 00 00 00 Compressed Size 00000000 (0)
0016 0019 0004 00 00 00 00 Uncompressed Size 00000000 (0)
001A 001B 0002 08 00 Filename Length 0008 (8)
001C 001D 0002 00 00 Extra Length 0000 (0)
001E 0025 0008 73 6F 6D 65 Filename 'somedir/'
64 69 72 2F

0026 0029 0004 50 4B 01 02 CENTRAL HEADER #1 02014B50 (33639248)
002A 002A 0001 3F Created Zip Spec 3F (63) '6.3'
002B 002B 0001 03 Created OS 03 (3) 'Unix'
002C 002C 0001 14 Extract Zip Spec 14 (20) '2.0'
002D 002D 0001 03 Extract OS 03 (3) 'Unix'
002E 002F 0002 00 00 General Purpose Flag 0000 (0)
0030 0031 0002 00 00 Compression Method 0000 (0) 'Stored'
0032 0035 0004 7A 93 9C 57 Last Mod Date/Time 579C937A (1469879162) 'Thu Dec 28 18:27:52 2023'
0036 0039 0004 00 00 00 00 CRC 00000000 (0)
003A 003D 0004 00 00 00 00 Compressed Size 00000000 (0)
003E 0041 0004 00 00 00 00 Uncompressed Size 00000000 (0)
0042 0043 0002 08 00 Filename Length 0008 (8)
0044 0045 0002 24 00 Extra Length 0024 (36)
0046 0047 0002 00 00 Comment Length 0000 (0)
0048 0049 0002 00 00 Disk Start 0000 (0)
004A 004B 0002 00 00 Int File Attributes 0000 (0)
[Bit 0] 0 'Binary Data'
004C 004F 0004 10 80 FD 41 Ext File Attributes 41FD8010 (1107132432)
[Bit 4] Directory
[Bits 11-15] 8000 (32768) 'Unknown DOS attrib'
[Bits 16-24] 01FD (509) 'Unix attrib: rwxrwxr-x'
[Bits 28-31] 04 (4) 'Directory'
0050 0053 0004 00 00 00 00 Local Header Offset 00000000 (0)
0054 005B 0008 73 6F 6D 65 Filename 'somedir/'
64 69 72 2F
005C 005D 0002 0A 00 Extra ID #1 000A (10) 'NTFS FileTimes'
005E 005F 0002 20 00 Length 0020 (32)
0060 0063 0004 00 00 00 00 Reserved 00000000 (0)
0064 0065 0002 01 00 Tag1 0001 (1)
0066 0067 0002 18 00 Size1 0018 (24)
0068 006F 0008 00 04 49 91 Mtime 01DA39BB91490400 (133482616720000000) 'Thu Dec 28 18:27:52 2023 0ns'
BB 39 DA 01
0070 0077 0008 00 04 49 91 Atime 01DA39BB91490400 (133482616720000000) 'Thu Dec 28 18:27:52 2023 0ns'
BB 39 DA 01
0078 007F 0008 00 04 49 91 Ctime 01DA39BB91490400 (133482616720000000) 'Thu Dec 28 18:27:52 2023 0ns'
BB 39 DA 01

0080 0083 0004 50 4B 05 06 END CENTRAL HEADER 06054B50 (101010256)
0084 0085 0002 00 00 Number of this disk 0000 (0)
0086 0087 0002 00 00 Central Dir Disk no 0000 (0)
0088 0089 0002 01 00 Entries in this disk 0001 (1)
008A 008B 0002 01 00 Total Entries 0001 (1)
008C 008F 0004 5A 00 00 00 Size of Central Dir 0000005A (90)
0090 0093 0004 26 00 00 00 Offset to Central Dir 00000026 (38)
0094 0095 0002 00 00 Comment Length 0000 (0)
#
# Done
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions t/files/0002-7z/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ create zip files as follows
7z a 7z-linux-lzma.zip lorem.txt -mm=lzma
7z a 7z-linux-ppmd.zip lorem.txt -mm=ppmd

Create a directory

mkdir somedir
7z a 7z-linux-directory.zip somedir
rmdif somedir

# Notes

Expand Down
Binary file not shown.
72 changes: 72 additions & 0 deletions t/files/0002-7z/windows/7z-windows-aes128/stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

0000 LOCAL HEADER #1 04034B50 (67324752)
0004 Extract Zip Spec 33 (51) '5.1'
0005 Extract OS 00 (0) 'MS-DOS'
0006 General Purpose Flag 0001 (1)
[Bit 0] 1 'Encryption'
0008 Compression Method 0063 (99) 'AES Encryption'
000A Last Mod Date/Time 56F34719 (1458784025) 'Wed Jul 19 08:56:50 2023'
000E CRC 00000000 (0)
0012 Compressed Size 0000011E (286)
0016 Uncompressed Size 000001BE (446)
001A Filename Length 0009 (9)
001C Extra Length 000B (11)
001E Filename 'lorem.txt'
0027 Extra ID #1 9901 (39169) 'AES Encryption'
0029 Length 0007 (7)
002B Vendor Version 0002 (2) 'AE-2'
002D Vendor ID 4541 (17729) 'AE'
002F Encryption Strength 01 (1) '128-bit encryption key'
0030 Compression Method 0008 (8) 'Deflated'
0032 AES Salt EF 11 A3 8A E9 EE FE D9
003A AES Pwd Ver 14 25
003C PAYLOAD
0146 AES Auth ED EF 61 E6 50 C0 1F 71 B6 28

0150 CENTRAL HEADER #1 02014B50 (33639248)
0154 Created Zip Spec 3F (63) '6.3'
0155 Created OS 00 (0) 'MS-DOS'
0156 Extract Zip Spec 33 (51) '5.1'
0157 Extract OS 00 (0) 'MS-DOS'
0158 General Purpose Flag 0001 (1)
[Bit 0] 1 'Encryption'
015A Compression Method 0063 (99) 'AES Encryption'
015C Last Mod Date/Time 56F34719 (1458784025) 'Wed Jul 19 08:56:50 2023'
0160 CRC 00000000 (0)
0164 Compressed Size 0000011E (286)
0168 Uncompressed Size 000001BE (446)
016C Filename Length 0009 (9)
016E Extra Length 002F (47)
0170 Comment Length 0000 (0)
0172 Disk Start 0000 (0)
0174 Int File Attributes 0000 (0)
[Bit 0] 0 'Binary Data'
0176 Ext File Attributes 00000020 (32)
[Bit 5] Archive
017A Local Header Offset 00000000 (0)
017E Filename 'lorem.txt'
0187 Extra ID #1 000A (10) 'NTFS FileTimes'
0189 Length 0020 (32)
018B Reserved 00000000 (0)
018F Tag1 0001 (1)
0191 Size1 0018 (24)
0193 Mtime 01D9BA1EF46C993E (133342306096683326) 'Wed Jul 19 08:56:49 2023 668332600ns'
019B Atime 0000000000000000 (0) 'Mon Jan 1 00:00:00 1601 0ns'
01A3 Ctime 0000000000000000 (0) 'Mon Jan 1 00:00:00 1601 0ns'
01AB Extra ID #2 9901 (39169) 'AES Encryption'
01AD Length 0007 (7)
01AF Vendor Version 0002 (2) 'AE-2'
01B1 Vendor ID 4541 (17729) 'AE'
01B3 Encryption Strength 01 (1) '128-bit encryption key'
01B4 Compression Method 0008 (8) 'Deflated'

01B6 END CENTRAL HEADER 06054B50 (101010256)
01BA Number of this disk 0000 (0)
01BC Central Dir Disk no 0000 (0)
01BE Entries in this disk 0001 (1)
01C0 Total Entries 0001 (1)
01C2 Size of Central Dir 00000066 (102)
01C6 Offset to Central Dir 00000150 (336)
01CA Comment Length 0000 (0)
#
# Done
Loading

0 comments on commit f187a63

Please sign in to comment.