OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [services/] [compress/] [zlib/] [v2_0/] [tests/] [zlib1.c] - Blame information for rev 565

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//=================================================================
2
//
3
//        zlib1.c
4
//
5
//        zlib compression/decompression test 1
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 Red Hat, 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 version.
16
//
17
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
// for more details.
21
//
22
// You should have received a copy of the GNU General Public License along
23
// with eCos; if not, write to the Free Software Foundation, Inc.,
24
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
//
26
// As a special exception, if other files instantiate templates or use macros
27
// or inline functions from this file, or you compile this file and link it
28
// with other works to produce a work based on this file, this file does not
29
// by itself cause the resulting work to be covered by the GNU General Public
30
// License. However the source code for this file must still be made available
31
// in accordance with section (3) of the GNU General Public License.
32
//
33
// This exception does not invalidate any other reasons why a work based on
34
// this file might be covered by the GNU General Public License.
35
//
36
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37
// at http://sources.redhat.com/ecos/ecos-license/
38
// -------------------------------------------
39
//####ECOSGPLCOPYRIGHTEND####
40
//==========================================================================
41
//#####DESCRIPTIONBEGIN####
42
//
43
// Author(s):     jskov
44
// Contributors:  jskov
45
// Date:          2001-03-09
46
// Description:   Tests zlib compress/decompress functionality.
47
//####DESCRIPTIONEND####
48
 
49
 
50
#include <cyg/hal/hal_arch.h>           // CYGNUM_HAL_STACK_SIZE_TYPICAL
51
 
52
#include <cyg/kernel/kapi.h>
53
 
54
#include <cyg/infra/testcase.h>
55
 
56
#ifdef CYGFUN_KERNEL_API_C
57
 
58
#include <cyg/compress/zlib.h>
59
#include <stdlib.h>
60
 
61
#define NTHREADS 1
62
#define STACKSIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL > 8192 ? CYGNUM_HAL_STACK_SIZE_TYPICAL : 8192)
63
 
64
static cyg_handle_t thread[NTHREADS];
65
 
66
static cyg_thread thread_obj[NTHREADS];
67
static char stack[NTHREADS][STACKSIZE];
68
 
69
static char license_txt[] =
70
"Red Hat eCos Public License v1.1
71
 
72
 
73
1. DEFINITIONS
74
 
75
1.1. \"Contributor\" means each entity that creates or
76
contributes to the creation of Modifications.
77
 
78
1.2. \"Contributor Version\" means the combination of the
79
Original Code, prior Modifications used by a
80
Contributor, and the Modifications made by that
81
particular Contributor.
82
 
83
1.3. \"Covered Code\" means the Original Code or
84
Modifications or the combination of the Original Code
85
and Modifications, in each case including portions
86
thereof.
87
 
88
1.4. \"Electronic Distribution Mechanism\" means a
89
mechanism generally accepted in the software development
90
community for the electronic transfer of data.
91
 
92
1.5. \"Executable\" means Covered Code in any form other
93
than Source Code.
94
1.6. \"Initial Developer\" means the individual or entity
95
identified as the Initial Developer in the Source Code
96
notice required by Exhibit A.
97
 
98
1.7. \"Larger Work\" means a work which combines Covered
99
Code or portions thereof with code not governed by the
100
terms of this License.
101
 
102
1.8. \"License\" means this document.
103
 
104
1.9. \"Modifications\" means any addition to or deletion
105
from the substance or structure of either the Original
106
Code or any previous Modifications. When Covered Code is
107
released as a series of files, a Modification is:
108
 
109
     A. Any addition to or deletion from the
110
     contents of a file containing Original Code or
111
     previous Modifications.
112
 
113
     B. Any new file that contains any part of the
114
     Original Code or previous Modifications.
115
 
116
1.10. \"Original Code\" means Source Code of computer
117
software code which is described in the Source Code
118
notice required by Exhibit A as Original Code, and
119
which, at the time of its release under this License is
120
not already Covered Code governed by this License.
121
 
122
1.11. \"Source Code\" means the preferred form of the
123
Covered Code for making modifications to it, including
124
all modules it contains, plus any associated interface
125
definition files, scripts used to control compilation
126
and installation of an Executable, or a list of source
127
code differential comparisons against either the
128
Original Code or another well known, available Covered
129
Code of the Contributor's choice. The Source Code can be
130
in a compressed or archival form, provided the
131
appropriate decompression or de-archiving software is
132
widely available for no charge.
133
 
134
1.12. \"You\" means an individual or a legal entity
135
exercising rights under, and complying with all of the
136
terms of, this License or a future version of this
137
License issued under Section 6.1. For legal entities,
138
\"You\" includes any entity which controls, is controlled
139
by, or is under common control with You. For purposes of
140
this definition, \"control\" means (a) the power, direct
141
or indirect, to cause the direction or management of
142
such entity, whether by contract or otherwise, or (b)
143
ownership of fifty percent (50%) or more of the
144
outstanding shares or beneficial ownership of such
145
entity.
146
 
147
1.13. \"Red Hat Branded Code\" is code that Red Hat
148
distributes and/or permits others to distribute under
149
different terms than the Red Hat eCos Public License.
150
Red Hat's Branded Code may contain part or all of the
151
Covered Code.
152
";
153
 
154
static void entry0( cyg_addrword_t data )
155
{
156
    int i;
157
    unsigned long len;
158
    int err;
159
    int buf_size = sizeof(license_txt)+512;
160
    unsigned char* packed = malloc(buf_size);
161
    unsigned char* unpacked = malloc(buf_size);
162
 
163
    if (NULL == packed || NULL == unpacked)
164
        CYG_TEST_NA("Not enough memory for buffers");
165
 
166
    CYG_TEST_INFO("Compressing");
167
 
168
    len = buf_size;
169
    err = compress(packed, &len, license_txt, sizeof(license_txt));
170
 
171
    if (Z_OK != err)
172
        CYG_TEST_NA("Not enough memory for compression");
173
 
174
 
175
    CYG_TEST_INFO("Decompressing");
176
    err = uncompress(unpacked, &buf_size, packed, len);
177
 
178
    switch (err) {
179
    case Z_OK:
180
        break;
181
    case Z_MEM_ERROR:
182
        CYG_TEST_NA("Not enough memory for decompression");
183
        break;
184
    case Z_BUF_ERROR:
185
        CYG_TEST_FAIL_FINISH("Decompressed data larger than original");
186
        break;
187
    case Z_DATA_ERROR:
188
        CYG_TEST_FAIL_FINISH("Decompression failed");
189
        break;
190
    default:
191
        CYG_TEST_FAIL_FINISH("Unknown decompression error");
192
        break;
193
    }
194
 
195
    for (i = 0; i < sizeof(license_txt)-1; i++) {
196
        if (license_txt[i] != unpacked[i])
197
            CYG_TEST_FAIL_FINISH("Verify failed");
198
    }
199
 
200
    CYG_TEST_PASS_FINISH("zlib1 OK");
201
}
202
 
203
void zlib1_main( void )
204
{
205
    CYG_TEST_INIT();
206
 
207
    cyg_thread_create(4, entry0 , (cyg_addrword_t)0, "zlib1",
208
        (void *)stack[0], STACKSIZE,&thread[0], &thread_obj[0]);
209
    cyg_thread_resume(thread[0]);
210
 
211
    cyg_scheduler_start();
212
 
213
    CYG_TEST_FAIL_FINISH("Not reached");
214
}
215
 
216
externC void
217
cyg_start( void )
218
{
219
    zlib1_main();
220
}
221
 
222
#else /* def CYGFUN_KERNEL_API_C */
223
externC void
224
cyg_start( void )
225
{
226
    CYG_TEST_INIT();
227
    CYG_TEST_NA("Kernel C API layer disabled");
228
}
229
#endif /* def CYGFUN_KERNEL_API_C */
230
 
231
// EOF zlib1.c

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.