xref: /nrf52832-nimble/rt-thread/components/dfs/filesystems/jffs2/cyg/compress/tests/zlib2.c (revision 104654410c56c573564690304ae786df310c91fc)
1 //=================================================================
2 //
3 //        zlib2.c
4 //
5 //        zlib decompression test 2
6 //
7 //==========================================================================
8 // ####ECOSGPLCOPYRIGHTBEGIN####
9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
12 //
13 // eCos is free software; you can redistribute it and/or modify it under
14 // the terms of the GNU General Public License as published by the Free
15 // Software Foundation; either version 2 or (at your option) any later
16 // version.
17 //
18 // eCos is distributed in the hope that it will be useful, but WITHOUT
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21 // for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with eCos; if not, write to the Free Software Foundation, Inc.,
25 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
26 //
27 // As a special exception, if other files instantiate templates or use
28 // macros or inline functions from this file, or you compile this file
29 // and link it with other works to produce a work based on this file,
30 // this file does not by itself cause the resulting work to be covered by
31 // the GNU General Public License. However the source code for this file
32 // must still be made available in accordance with section (3) of the GNU
33 // General Public License v2.
34 //
35 // This exception does not invalidate any other reasons why a work based
36 // on this file might be covered by the GNU General Public License.
37 // -------------------------------------------
38 // ####ECOSGPLCOPYRIGHTEND####
39 //==========================================================================
40 //#####DESCRIPTIONBEGIN####
41 //
42 // Author(s):     jskov
43 // Contributors:  jskov
44 // Date:          2001-03-09
45 // Description:   Tests zlib compression of gz compressed image.
46 //####DESCRIPTIONEND####
47 
48 
49 #include <cyg/hal/hal_arch.h>           // CYGNUM_HAL_STACK_SIZE_TYPICAL
50 
51 #include <cyg/kernel/kapi.h>
52 
53 #include <cyg/infra/testcase.h>
54 
55 #ifdef CYGFUN_KERNEL_API_C
56 
57 #include <cyg/compress/zlib.h>
58 #include <stdlib.h>
59 
60 #define NTHREADS 1
61 #define STACKSIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL > 8192 ? CYGNUM_HAL_STACK_SIZE_TYPICAL : 8192)
62 
63 static cyg_handle_t thread[NTHREADS];
64 
65 static cyg_thread thread_obj[NTHREADS];
66 static char stack[NTHREADS][STACKSIZE];
67 
68 
69 unsigned char gzip_test[] = {
70 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x8d, 0x56, 0xdb, 0x6e, 0xe3, 0x36,
71 0x10, 0xed, 0x33, 0xbf, 0x82, 0x08, 0x50, 0x74, 0x03, 0xb8, 0xee, 0xa6, 0xed, 0x6e, 0x2f, 0x6f,
72 0xd9, 0x24, 0x8b, 0x06, 0xd8, 0x4b, 0x91, 0x2c, 0xba, 0xe8, 0x23, 0x4d, 0x8d, 0x6c, 0x22, 0x12,
73 0xa9, 0x92, 0x94, 0x9d, 0xfc, 0x7d, 0xcf, 0x0c, 0x25, 0x59, 0x72, 0x1a, 0xa0, 0x7e, 0x32, 0x45,
74 0x72, 0xe6, 0xcc, 0xcc, 0x99, 0x33, 0xbc, 0xa3, 0x4a, 0xff, 0x61, 0xb2, 0xa6, 0xab, 0x90, 0xf4,
75 0x9f, 0xfd, 0xa6, 0x71, 0x56, 0x7f, 0x70, 0x96, 0x7c, 0x22, 0xbd, 0xbf, 0x58, 0x5f, 0x28, 0xfc,
76 0x2e, 0xd6, 0xfa, 0xfa, 0xe6, 0xfd, 0xed, 0xa7, 0xdb, 0x2f, 0xb7, 0x9f, 0x3f, 0xdd, 0xf3, 0x1a,
77 0x5f, 0xce, 0xae, 0x82, 0xcf, 0xd1, 0x6d, 0xfa, 0x1c, 0xe2, 0x99, 0x6e, 0xc9, 0xf8, 0xa4, 0xc9,
78 0xd8, 0x9d, 0x26, 0x9f, 0x5d, 0x7e, 0xd2, 0x79, 0x07, 0xab, 0x36, 0x92, 0xc9, 0x94, 0x74, 0x88,
79 0x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9f, 0x29, 0xb6, 0xa9, 0xd0, 0xc6, 0xa5,
102 0xb1, 0x81, 0x05, 0xc5, 0xaf, 0x8c, 0xa2, 0xac, 0x8f, 0x99, 0xc0, 0x99, 0x2a, 0xd8, 0x9e, 0xeb,
103 0x25, 0x87, 0x7e, 0xc3, 0xa1, 0x05, 0xb5, 0x26, 0xb0, 0x48, 0xba, 0xa9, 0x2a, 0x27, 0x2c, 0x41,
104 0xdb, 0x02, 0x59, 0x85, 0x72, 0xf2, 0x52, 0xd5, 0x31, 0xb4, 0x85, 0x06, 0xfd, 0x26, 0x65, 0xe3,
105 0xad, 0x00, 0x07, 0xab, 0x7a, 0x9b, 0x7b, 0x90, 0x02, 0x68, 0xc8, 0x31, 0xfc, 0x05, 0x97, 0xa7,
106 0x08, 0xd9, 0x74, 0x17, 0x69, 0xef, 0x42, 0x9f, 0x4e, 0xda, 0x5f, 0x7f, 0xdd, 0x91, 0x3f, 0x21,
107 0x40, 0x52, 0x11, 0x8e, 0x4d, 0x2a, 0x55, 0x32, 0x3a, 0x51, 0x74, 0x24, 0x21, 0xd7, 0xae, 0x21,
108 0xf4, 0x82, 0x59, 0x18, 0xc1, 0x85, 0xdf, 0x95, 0xd2, 0xfc, 0xbb, 0x5c, 0xeb, 0xcb, 0x97, 0xc3,
109 0xd0, 0x63, 0x18, 0xe5, 0x30, 0xcb, 0x14, 0xb2, 0x22, 0x86, 0x8d, 0x98, 0x96, 0x4f, 0xc6, 0x79,
110 0x6e, 0xac, 0x67, 0x9d, 0x2c, 0x77, 0x5e, 0x88, 0x62, 0x70, 0xff, 0xae, 0xb8, 0xf7, 0x74, 0x28,
111 0xe6, 0x8a, 0x30, 0x16, 0x9b, 0x25, 0xc1, 0x2c, 0x2b, 0xa3, 0x7e, 0xc9, 0x95, 0x53, 0x37, 0x2f,
112 0x7b, 0x80, 0x14, 0xbf, 0x46, 0xed, 0x16, 0x17, 0xc6, 0xda, 0xcd, 0xc8, 0xca, 0xd6, 0x41, 0xb5,
113 0x0e, 0xea, 0x1b, 0xd5, 0xd4, 0xb5, 0xc2, 0xa6, 0xc2, 0x43, 0x26, 0x04, 0x25, 0x0b, 0x41, 0x38,
114 0x76, 0xf7, 0xff, 0x25, 0x3b, 0xd7, 0xe3, 0x44, 0x76, 0x21, 0x55, 0x4a, 0x0c, 0xe3, 0x6f, 0x16,
115 0x63, 0xd9, 0xb5, 0x82, 0xc2, 0x21, 0xb5, 0x43, 0x21, 0x75, 0xef, 0x2b, 0x21, 0xc7, 0x91, 0xb1,
116 0x5c, 0x66, 0xa6, 0xb7, 0x69, 0x30, 0x1a, 0xaa, 0xa7, 0x25, 0x05, 0x96, 0x9c, 0x3f, 0xa1, 0xf9,
117 0x05, 0x8f, 0xa4, 0x19, 0xe2, 0x79, 0xd7, 0x23, 0x7b, 0x90, 0x1c, 0xb6, 0x53, 0xf4, 0xa3, 0x64,
118 0x7a, 0x61, 0x9b, 0xa5, 0xaa, 0x35, 0x0f, 0x5c, 0xe3, 0x76, 0x21, 0xce, 0x20, 0x8b, 0xcb, 0xab,
119 0xa3, 0xb6, 0x2a, 0x08, 0x21, 0x1f, 0xe9, 0xc1, 0x39, 0xec, 0x4c, 0x85, 0xc4, 0xa8, 0x69, 0xfa,
120 0xa1, 0x5f, 0x52, 0x0a, 0xd6, 0x99, 0xa2, 0x93, 0x48, 0x78, 0x6d, 0x2c, 0xa9, 0x8a, 0x6a, 0xe7,
121 0x0b, 0xff, 0x06, 0xbe, 0x72, 0xb6, 0xbb, 0x3c, 0x8c, 0x23, 0xb8, 0x91, 0x01, 0x19, 0x1a, 0xa9,
122 0x93, 0x6b, 0xc4, 0xbd, 0x48, 0x3e, 0x8c, 0x67, 0x38, 0x9d, 0x06, 0x03, 0x64, 0xef, 0x28, 0x96,
123 0x2b, 0xe9, 0x24, 0xdd, 0x40, 0xcc, 0x79, 0x2f, 0x49, 0x02, 0x94, 0x14, 0x16, 0x51, 0x20, 0x6a,
124 0x96, 0x36, 0x53, 0x8c, 0x9a, 0xe8, 0x12, 0x87, 0x64, 0xb6, 0x0c, 0x38, 0xcf, 0x9a, 0x53, 0x3d,
125 0x23, 0x9c, 0xf1, 0xa2, 0xb2, 0xfa, 0x40, 0x08, 0xf7, 0xc1, 0x87, 0x83, 0x47, 0x25, 0xf7, 0x06,
126 0xb8, 0xe0, 0xf4, 0x44, 0xac, 0xca, 0xac, 0x9a, 0x0d, 0xc4, 0xef, 0x92, 0xb6, 0xbb, 0x80, 0xe2,
127 0xac, 0xf5, 0x97, 0x25, 0x8f, 0x30, 0xa8, 0xbc, 0xde, 0x90, 0x62, 0x39, 0x17, 0x4c, 0x91, 0x12,
128 0x87, 0xcf, 0x1e, 0xa3, 0xdd, 0xb9, 0x3d, 0x20, 0x70, 0x8d, 0x78, 0x70, 0x07, 0x08, 0x35, 0xc9,
129 0x48, 0x56, 0xa6, 0xc3, 0x12, 0xa3, 0x1c, 0x39, 0x05, 0x4d, 0xc7, 0x7b, 0x92, 0x0f, 0x6e, 0xe4,
130 0xef, 0xcb, 0x5d, 0x2e, 0xde, 0xc4, 0x6d, 0x10, 0xe9, 0x80, 0xfb, 0x3c, 0xb4, 0x26, 0xd8, 0x5c,
131 0x64, 0x8f, 0x44, 0xef, 0x58, 0x94, 0x0b, 0x6b, 0xf8, 0x91, 0xf1, 0x77, 0xe8, 0x8f, 0x72, 0x77,
132 0x32, 0x22, 0x90, 0x5a, 0xda, 0xe2, 0xef, 0x30, 0x2a, 0xe8, 0x91, 0xa2, 0x75, 0x89, 0x3d, 0x21,
133 0x63, 0x3b, 0xae, 0x1e, 0x73, 0xb8, 0x3c, 0x1e, 0x18, 0x57, 0xf3, 0xc4, 0x7b, 0xa2, 0xd5, 0x4c,
134 0x94, 0x81, 0x6a, 0xa3, 0x3a, 0xaf, 0x96, 0x64, 0x17, 0xfb, 0x75, 0x2f, 0x62, 0xb9, 0x2f, 0xaf,
135 0x9b, 0x51, 0xc2, 0xd5, 0xb1, 0x21, 0x52, 0x8f, 0x2c, 0x94, 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c2, 0x20, 0x63, 0x52,
147 0x05, 0x53, 0x21, 0x14, 0xbf, 0x03, 0xef, 0x86, 0x37, 0xf5, 0x3b, 0x3c, 0x76, 0xaa, 0xe9, 0x3d,
148 0x28, 0x19, 0xaf, 0x06, 0xfd, 0x1f, 0x8e, 0xa8, 0x6a, 0x7c, 0x85, 0x49, 0xb5, 0xaa, 0x1f, 0x38,
149 0xbd, 0x20, 0x0b, 0xab, 0xa4, 0x84, 0x22, 0x02, 0x74, 0x3c, 0x54, 0xca, 0xa3, 0xa6, 0xd6, 0xd6,
150 0x85, 0x59, 0xf2, 0x16, 0xe2, 0xec, 0xdd, 0xbd, 0xfc, 0x9a, 0x5f, 0xab, 0x61, 0x13, 0xdd, 0x39,
151 0x07, 0x86, 0x24, 0x3f, 0x8d, 0x2a, 0x36, 0x4c, 0xa2, 0x38, 0xe7, 0xee, 0x5c, 0x26, 0xd7, 0xea,
152 0x9b, 0x7f, 0x01, 0x21, 0xe0, 0xda, 0x98, 0x30, 0x0c, 0x00, 0x00};
153 
154 unsigned char gzip_test_ref[] =
155 "Red Hat eCos Public License v1.1\n"
156 "\n"
157 "\n"
158 "\n"
159 "1. DEFINITIONS\n"
160 "\n"
161 "1.1. \"Contributor\" means each entity that creates or\n"
162 "contributes to the creation of Modifications.\n"
163 "\n"
164 "1.2. \"Contributor Version\" means the combination of the\n"
165 "Original Code, prior Modifications used by a\n"
166 "Contributor, and the Modifications made by that\n"
167 "particular Contributor.\n"
168 "\n"
169 "1.3. \"Covered Code\" means the Original Code or\n"
170 "Modifications or the combination of the Original Code\n"
171 "and Modifications, in each case including portions\n"
172 "thereof.\n"
173 "\n"
174 "1.4. \"Electronic Distribution Mechanism\" means a\n"
175 "mechanism generally accepted in the software development\n"
176 "community for the electronic transfer of data.\n"
177 "\n"
178 "1.5. \"Executable\" means Covered Code in any form other\n"
179 "than Source Code.\n"
180 "1.6. \"Initial Developer\" means the individual or entity\n"
181 "identified as the Initial Developer in the Source Code\n"
182 "notice required by Exhibit A.\n"
183 "\n"
184 "1.7. \"Larger Work\" means a work which combines Covered\n"
185 "Code or portions thereof with code not governed by the\n"
186 "terms of this License.\n"
187 "\n"
188 "1.8. \"License\" means this document.\n"
189 "\n"
190 "1.9. \"Modifications\" means any addition to or deletion\n"
191 "from the substance or structure of either the Original\n"
192 "Code or any previous Modifications. When Covered Code is\n"
193 "released as a series of files, a Modification is:\n"
194 "\n"
195 "     A. Any addition to or deletion from the\n"
196 "     contents of a file containing Original Code or\n"
197 "     previous Modifications.\n"
198 "\n"
199 "     B. Any new file that contains any part of the\n"
200 "     Original Code or previous Modifications.\n"
201 "\n"
202 "1.10. \"Original Code\" means Source Code of computer\n"
203 "software code which is described in the Source Code\n"
204 "notice required by Exhibit A as Original Code, and\n"
205 "which, at the time of its release under this License is\n"
206 "not already Covered Code governed by this License.\n"
207 "\n"
208 "1.11. \"Source Code\" means the preferred form of the\n"
209 "Covered Code for making modifications to it, including\n"
210 "all modules it contains, plus any associated interface\n"
211 "definition files, scripts used to control compilation\n"
212 "and installation of an Executable, or a list of source\n"
213 "code differential comparisons against either the\n"
214 "Original Code or another well known, available Covered\n"
215 "Code of the Contributor's choice. The Source Code can be\n"
216 "in a compressed or archival form, provided the\n"
217 "appropriate decompression or de-archiving software is\n"
218 "widely available for no charge.\n"
219 "\n"
220 "1.12. \"You\" means an individual or a legal entity\n"
221 "exercising rights under, and complying with all of the\n"
222 "terms of, this License or a future version of this\n"
223 "License issued under Section 6.1. For legal entities,\n"
224 "\"You\" includes any entity which controls, is controlled\n"
225 "by, or is under common control with You. For purposes of\n"
226 "this definition, \"control\" means (a) the power, direct\n"
227 "or indirect, to cause the direction or management of\n"
228 "such entity, whether by contract or otherwise, or (b)\n"
229 "ownership of fifty percent (50%) or more of the\n"
230 "outstanding shares or beneficial ownership of such\n"
231 "entity.\n"
232 "\n"
233 "1.13. \"Red Hat Branded Code\" is code that Red Hat\n"
234 "distributes and/or permits others to distribute under\n"
235 "different terms than the Red Hat eCos Public License.\n"
236 "Red Hat's Branded Code may contain part or all of the\n"
237 "Covered Code.\n";
238 
entry0(cyg_addrword_t data)239 static void entry0( cyg_addrword_t data )
240 {
241     int i;
242     unsigned long len;
243     int err;
244     int buf_size = sizeof(gzip_test_ref)+512;
245     unsigned char* unpacked = malloc(buf_size);
246 
247     if (NULL == unpacked)
248         CYG_TEST_NA("Not enough memory for buffers");
249 
250     CYG_TEST_INFO("Decompressing");
251     len = buf_size;
252     err = uncompress(unpacked, &len, gzip_test, sizeof(gzip_test));
253 
254     switch (err) {
255     case Z_OK:
256         break;
257     case Z_MEM_ERROR:
258         CYG_TEST_NA("Not enough memory for decompression");
259         break;
260     case Z_BUF_ERROR:
261         CYG_TEST_FAIL_FINISH("Decompressed data larger than original");
262         break;
263     case Z_DATA_ERROR:
264         CYG_TEST_FAIL_FINISH("Decompression failed");
265         break;
266     default:
267         CYG_TEST_FAIL_FINISH("Unknown decompression error");
268         break;
269     }
270 
271     for (i = 0; i < sizeof(gzip_test_ref)-1; i++) {
272         if (gzip_test_ref[i] != unpacked[i])
273             CYG_TEST_FAIL_FINISH("Verify failed");
274     }
275 
276     CYG_TEST_PASS_FINISH("zlib2 OK");
277 }
278 
zlib2_main(void)279 void zlib2_main( void )
280 {
281     CYG_TEST_INIT();
282 
283     cyg_thread_create(4, entry0 , (cyg_addrword_t)0, "zlib1",
284         (void *)stack[0], STACKSIZE,&thread[0], &thread_obj[0]);
285     cyg_thread_resume(thread[0]);
286 
287     cyg_scheduler_start();
288 
289     CYG_TEST_FAIL_FINISH("Not reached");
290 }
291 
292 externC void
cyg_start(void)293 cyg_start( void )
294 {
295     zlib2_main();
296 }
297 
298 #else /* def CYGFUN_KERNEL_API_C */
299 externC void
cyg_start(void)300 cyg_start( void )
301 {
302     CYG_TEST_INIT();
303     CYG_TEST_NA("Kernel C API layer disabled");
304 }
305 #endif /* def CYGFUN_KERNEL_API_C */
306 
307 // EOF zlib1.c
308