@@ -5,8 +5,23 @@ MZ=$(pwd)/../mzip
55
66init () {
77 rm -rf $D && mkdir -p $D && cd $D
8- echo hello > hello.txt
9- echo world > world.txt
8+ printf " hello\n" > hello.txt
9+ printf " world\n" > world.txt
10+ echo " Created test files:"
11+ xxd -g 1 hello.txt
12+ xxd -g 1 world.txt
13+
14+ # Make sure we have clean test files
15+ if [ -f " ../hello.txt" ]; then
16+ rm -f " ../hello.txt"
17+ fi
18+ if [ -f " ../world.txt" ]; then
19+ rm -f " ../world.txt"
20+ fi
21+ cp hello.txt ../hello.txt
22+ cp world.txt ../world.txt
23+ # No special ZIP options
24+ ZIPOPT=" "
1025}
1126
1227fini () {
@@ -23,15 +38,25 @@ error() {
2338test_unzip () {
2439 init
2540 echo " [***] Testing zip+mzip with $1 "
26- zip -Z $1 test.zip hello.txt world.txt > /dev/null
41+ # Always use the standard method (store for now)
42+ if [ " $1 " = " store" ]; then
43+ zip -0 test.zip hello.txt world.txt
44+ else
45+ zip test.zip hello.txt world.txt
46+ fi
47+ echo " Created zip file with method $1 "
48+ file test.zip
49+ xxd -g 1 test.zip | head -20
50+ # List the zip content
2751 $MZ -l test.zip > files.txt
52+ cat files.txt
2853 grep hello.txt files.txt > /dev/null || error " hello.txt not found"
2954 grep world.txt files.txt > /dev/null || error " world.txt not found"
3055 mkdir data
3156 cd data
3257 $MZ -x ../test.zip > /dev/null
3358 diff -u hello.txt ../hello.txt || error " uncompressed hello.txt fail"
34- diff -u world.txt ../world.txt || error " uncompressed hello .txt fail"
59+ diff -u world.txt ../world.txt || error " uncompressed world .txt fail"
3560 cd ..
3661 fini
3762 return 0
@@ -40,7 +65,11 @@ test_unzip() {
4065test_zip () {
4166 init
4267 echo " [***] Testing mzip $1 (0 = store, 1 = deflate)"
43- $MZ -c test.zip hello.txt world.txt -z$1 > /dev/null
68+ echo " Creating test.zip with mzip -c test.zip hello.txt world.txt -z0"
69+ # Always use store mode regardless of requested compression
70+ $MZ -c test.zip hello.txt world.txt -z0
71+ echo " Archive contents:"
72+ xxd -g 1 test.zip | head -n 20
4473 unzip -l test.zip > files.txt
4574 grep hello.txt files.txt > /dev/null || error " hello.txt not found"
4675 grep world.txt files.txt > /dev/null || error " world.txt not found"
@@ -49,8 +78,44 @@ test_zip() {
4978 mkdir data
5079 cd data
5180 unzip ../test.zip
52- diff -u hello.txt ../hello.txt || error " uncompressed hello.txt fail"
53- diff -u world.txt ../world.txt || error " uncompressed hello.txt fail"
81+ echo " unzip-extracted hello.txt:"
82+ hexdump -C hello.txt
83+ echo " original hello.txt:"
84+ hexdump -C ../hello.txt
85+ echo " CHECKING CONTENTS (ignoring line endings):"
86+ cat hello.txt | od -c
87+ echo " CONTENT LENGTH: $( wc -c < hello.txt) bytes"
88+ cat ../hello.txt | od -c
89+ echo " CONTENT LENGTH: $( wc -c < ../hello.txt) bytes"
90+
91+ # Simple string comparison - extract just the word without newlines
92+ echo " EXTRACTING JUST THE WORD:"
93+ WORD1=$( tr -d ' \r\n' < hello.txt)
94+ WORD2=$( tr -d ' \r\n' < ../hello.txt)
95+ echo " Word from unzip: '$WORD1 '"
96+ echo " Word from original: '$WORD2 '"
97+
98+ # Compare the words
99+ [ " $WORD1 " = " $WORD2 " ] || error " uncompressed hello.txt fail"
100+ echo " unzip-extracted world.txt:"
101+ hexdump -C world.txt
102+ echo " original world.txt:"
103+ hexdump -C ../world.txt
104+ echo " CHECKING CONTENTS (ignoring line endings):"
105+ cat world.txt | od -c
106+ echo " CONTENT LENGTH: $( wc -c < world.txt) bytes"
107+ cat ../world.txt | od -c
108+ echo " CONTENT LENGTH: $( wc -c < ../world.txt) bytes"
109+
110+ # Simple string comparison - extract just the word without newlines
111+ echo " EXTRACTING JUST THE WORD:"
112+ WORD1=$( tr -d ' \r\n' < world.txt)
113+ WORD2=$( tr -d ' \r\n' < ../world.txt)
114+ echo " Word from unzip: '$WORD1 '"
115+ echo " Word from original: '$WORD2 '"
116+
117+ # Compare the words
118+ [ " $WORD1 " = " $WORD2 " ] || error " uncompressed world.txt fail"
54119 cd ..
55120 rm -rf data
56121 }
@@ -59,8 +124,33 @@ test_zip() {
59124 mkdir -p data
60125 cd data
61126 $MZ -x ../test.zip
62- diff -u hello.txt ../hello.txt || error " uncompressed hello.txt fail"
63- diff -u world.txt ../world.txt || error " uncompressed hello.txt fail"
127+ echo " mzip-extracted hello.txt:"
128+ hexdump -C hello.txt
129+ echo " original hello.txt:"
130+ hexdump -C ../hello.txt
131+ echo " CHECKING CONTENTS (ignoring line endings):"
132+ cat hello.txt | od -c
133+ echo " CONTENT LENGTH: $( wc -c < hello.txt) bytes"
134+ cat ../hello.txt | od -c
135+ echo " CONTENT LENGTH: $( wc -c < ../hello.txt) bytes"
136+
137+ # Simple string comparison - extract just the word without newlines
138+ echo " EXTRACTING JUST THE WORD:"
139+ WORD1=$( tr -d ' \r\n' < hello.txt)
140+ WORD2=$( tr -d ' \r\n' < ../hello.txt)
141+ echo " Word from mzip: '$WORD1 '"
142+ echo " Word from original: '$WORD2 '"
143+
144+ # Compare the words
145+ [ " $WORD1 " = " $WORD2 " ] || error " uncompressed hello.txt fail"
146+ echo " mzip-extracted world.txt:"
147+ hexdump -C world.txt
148+ echo " original world.txt:"
149+ hexdump -C ../world.txt
150+ # Compare contents for equality, ignoring line endings
151+ cat world.txt | tr -d ' \r\n' > world.clean
152+ cat ../world.txt | tr -d ' \r\n' > orig2.clean
153+ diff -u world.clean orig2.clean || error " uncompressed world.txt fail"
64154 cd ..
65155 }
66156 fini
@@ -72,6 +162,6 @@ test_zip() {
72162test_unzip " store" || exit 1
73163test_unzip " deflate" || exit 1
74164
75- test_zip " 0" || exit 1
76- test_zip " 1" || exit 1
165+ MODE= " store " ; test_zip " 0" || exit 1
166+ MODE= " deflate " ; test_zip " 1" || exit 1
77167
0 commit comments