diff --git a/inflate/Makefile b/inflate/Makefile index e95ee0e..f6efca5 100644 --- a/inflate/Makefile +++ b/inflate/Makefile @@ -20,7 +20,7 @@ all: depacker degzip # Test harness for inflate.S test_inflate: degzip test_inflate.o $(CC) -o $@ $@.o $(LDFLAGS) - $(PYTHON) test_inflate.py *.[cSo] *.asm ../cracking/protections/* ../cracking/cracks/nzs/gnu_c/* ../testkit/* + $(PYTHON) test_inflate.py *.[cSo] *.asm ../cracking/protections/* ../cracking/cracks/nzs/gnu_c/* ../testkit/* test_assets/* %.o: %.S $(CC) -o $@ -c $< $(AFLAGS) diff --git a/inflate/test_assets/XenonIcon.gz b/inflate/test_assets/XenonIcon.gz new file mode 100644 index 0000000..27b4772 Binary files /dev/null and b/inflate/test_assets/XenonIcon.gz differ diff --git a/inflate/test_inflate.py b/inflate/test_inflate.py index 4407b94..4ce210c 100644 --- a/inflate/test_inflate.py +++ b/inflate/test_inflate.py @@ -13,6 +13,7 @@ # Command for creating gzip files. GZIP = "zopfli --i32 -c" #GZIP = "gzip -c9" +GUNZIP = "gunzip -c" HUNK_HEADER = 0x3f3 HUNK_CODE = 0x3e9 @@ -34,15 +35,22 @@ def main(argv): def test(name): print("Testing '%s'..." % name) - # _test_0: Local copy of original file - os.system('cp "' + name + '" ' + PREFIX + '0') + if name.endswith('.gz'): + # _test_1: Local copy of original gzipped file + os.system('cp "' + name + '" ' + PREFIX + '1') + # _test_0: Uncompressed file + os.system(GUNZIP + ' ' + PREFIX + '1 >' + PREFIX + '0') + else: + # _test_0: Local copy of original uncompressed file + os.system('cp "' + name + '" ' + PREFIX + '0') + # _test_1: Gzipped file + os.system(GZIP + ' ' + PREFIX + '0 >' + PREFIX + '1') + + # CRC of uncompressed data crc16 = crcmod.predefined.Crc('crc-ccitt-false') with open(PREFIX + '0', 'rb') as f: crc16.update(f.read()) - # _test_1: Gzipped file - os.system(GZIP + ' ' + PREFIX + '0 >' + PREFIX + '1') - # _test_2: DEFLATE stream + custom header/footer os.system('degzip -H ' + PREFIX + '1 ' + PREFIX + '2')