~ubuntu-branches/ubuntu/raring/freerdp/raring-proposed

« back to all changes in this revision

Viewing changes to cunit/test_freerdp.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt, Jeremy Bicha, Jean-Louis Dupond, Martin Pitt
  • Date: 2012-01-31 10:02:14 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120131100214-jaok3uwvni7sqxth
Tags: 1.0.0-0git1
Upload current Debian packaging git to get this rolling for precise.

[ Jeremy Bicha ]
* New upstream release. Closes: #647498.
* Updated symbols and bumped soname
* debian/control:
  - Added new build dependencies
  - Bump Standards-Version to 3.9.2
* debian/source/format: Set to 3.0 (quilt)
* debian/rules: Turn on strict symbols checking
* debian/watch: Watch github

[ Jean-Louis Dupond ]
* debian/control: Updated homepage
* debian/copyright: Reflect upstream switch to the Apache license

[ Martin Pitt ]
* debian/libfreerdp0.symbols: Fix version number, should
  be 1.0~beta5, not 1.0-beta5.
* debian/control: Add libavcodec-dev build dependency, upstream build system
  checks for that. Thanks Jean-Louis Dupond!

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
#include "CUnit/Basic.h"
3
 
 
4
 
#include "test_libfreerdpgdi.h"
 
1
/**
 
2
 * FreeRDP: A Remote Desktop Protocol Client
 
3
 * FreeRDP Unit Tests
 
4
 *
 
5
 * Copyright 2010 Marc-Andre Moreau <marcandre.moreau@gmail.com>
 
6
 *
 
7
 * Licensed under the Apache License, Version 2.0 (the "License");
 
8
 * you may not use this file except in compliance with the License.
 
9
 * You may obtain a copy of the License at
 
10
 *
 
11
 *     http://www.apache.org/licenses/LICENSE-2.0
 
12
 *
 
13
 * Unless required by applicable law or agreed to in writing, software
 
14
 * distributed under the License is distributed on an "AS IS" BASIS,
 
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
16
 * See the License for the specific language governing permissions and
 
17
 * limitations under the License.
 
18
 */
 
19
 
 
20
#include <CUnit/Basic.h>
 
21
 
 
22
#include "test_per.h"
 
23
#include "test_ber.h"
 
24
#include "test_gcc.h"
 
25
#include "test_mcs.h"
 
26
#include "test_color.h"
 
27
#include "test_bitmap.h"
 
28
#include "test_libgdi.h"
 
29
#include "test_list.h"
 
30
#include "test_stream.h"
 
31
#include "test_utils.h"
 
32
#include "test_orders.h"
 
33
#include "test_license.h"
 
34
#include "test_channels.h"
 
35
#include "test_cliprdr.h"
 
36
#include "test_drdynvc.h"
 
37
#include "test_librfx.h"
5
38
#include "test_freerdp.h"
 
39
#include "test_rail.h"
 
40
#include "test_pcap.h"
 
41
#include "test_mppc.h"
 
42
 
 
43
void dump_data(unsigned char * p, int len, int width, char* name)
 
44
{
 
45
        unsigned char *line = p;
 
46
        int i, thisline, offset = 0;
 
47
 
 
48
        printf("\n%s[%d][%d]:\n", name, len / width, width);
 
49
        while (offset < len)
 
50
        {
 
51
                printf("%04x ", offset);
 
52
                thisline = len - offset;
 
53
                if (thisline > width)
 
54
                        thisline = width;
 
55
 
 
56
                for (i = 0; i < thisline; i++)
 
57
                        printf("%02x ", line[i]);
 
58
 
 
59
                for (; i < width; i++)
 
60
                        printf("   ");
 
61
 
 
62
                printf("\n");
 
63
                offset += thisline;
 
64
                line += thisline;
 
65
        }
 
66
        printf("\n");
 
67
}
 
68
 
 
69
void assert_stream(STREAM* s, uint8* data, int length, const char* func, int line)
 
70
{
 
71
        int i;
 
72
        int actual_length;
 
73
        uint8* actual_data;
 
74
 
 
75
        actual_data = s->data;
 
76
        actual_length = stream_get_length(s);
 
77
 
 
78
        if (actual_length != length)
 
79
        {
 
80
                printf("\n %s (%d): length mismatch, actual:%d, expected:%d\n", func, line, actual_length, length);
 
81
 
 
82
                printf("\nActual:\n");
 
83
                freerdp_hexdump(actual_data, actual_length);
 
84
 
 
85
                printf("Expected:\n");
 
86
                freerdp_hexdump(data, length);
 
87
 
 
88
                CU_FAIL("assert_stream, length mismatch");
 
89
                return;
 
90
        }
 
91
 
 
92
        for (i = 0; i < length; i++)
 
93
        {
 
94
                if (actual_data[i] != data[i])
 
95
                {
 
96
                        printf("\n %s (%d): buffer mismatch:\n", func, line);
 
97
 
 
98
                        printf("\nActual:\n");
 
99
                        freerdp_hexdump(actual_data, length);
 
100
 
 
101
                        printf("Expected:\n");
 
102
                        freerdp_hexdump(data, length);
 
103
 
 
104
                        CU_FAIL("assert_stream, buffer mismatch");
 
105
                        return;
 
106
                }
 
107
        }
 
108
}
6
109
 
7
110
int main(int argc, char* argv[])
8
111
{
 
112
        int index = 1;
 
113
        int *pindex = &index;
 
114
        int ret = 0;
 
115
 
9
116
        if (CU_initialize_registry() != CUE_SUCCESS)
10
117
                return CU_get_error();
11
118
 
12
 
        add_libfreerdpgdi_suite();
 
119
        if (argc < *pindex + 1)
 
120
        {
 
121
                add_per_suite();
 
122
                add_ber_suite();
 
123
                add_gcc_suite();
 
124
                add_mcs_suite();
 
125
                add_color_suite();
 
126
                add_bitmap_suite();
 
127
                add_libgdi_suite();
 
128
                add_list_suite();
 
129
                add_orders_suite();
 
130
                add_license_suite();
 
131
                add_stream_suite();
 
132
                add_mppc_suite();
 
133
        }
 
134
        else
 
135
        {
 
136
                while (*pindex < argc)
 
137
                {
 
138
                        if (strcmp("rail", argv[*pindex]) == 0)
 
139
                        {
 
140
                                add_rail_suite();
 
141
                        }
 
142
                        if (strcmp("color", argv[*pindex]) == 0)
 
143
                        {
 
144
                                add_color_suite();
 
145
                        }
 
146
                        if (strcmp("bitmap", argv[*pindex]) == 0)
 
147
                        {
 
148
                                add_bitmap_suite();
 
149
                        }
 
150
                        else if (strcmp("libgdi", argv[*pindex]) == 0)
 
151
                        {
 
152
                                add_libgdi_suite();
 
153
                        }
 
154
                        else if (strcmp("list", argv[*pindex]) == 0)
 
155
                        {
 
156
                                add_list_suite();
 
157
                        }
 
158
                        else if (strcmp("orders", argv[*pindex]) == 0)
 
159
                        {
 
160
                                add_orders_suite();
 
161
                        }
 
162
                        else if (strcmp("license", argv[*pindex]) == 0)
 
163
                        {
 
164
                                add_license_suite();
 
165
                        }
 
166
                        else if (strcmp("stream", argv[*pindex]) == 0)
 
167
                        {
 
168
                                add_stream_suite();
 
169
                        }
 
170
                        else if (strcmp("utils", argv[*pindex]) == 0)
 
171
                        {
 
172
                                add_utils_suite();
 
173
                        }
 
174
                        else if (strcmp("chanman", argv[*pindex]) == 0)
 
175
                        {
 
176
                                add_chanman_suite();
 
177
                        }
 
178
                        else if (strcmp("cliprdr", argv[*pindex]) == 0)
 
179
                        {
 
180
                                add_cliprdr_suite();
 
181
                        }
 
182
                        else if (strcmp("drdynvc", argv[*pindex]) == 0)
 
183
                        {
 
184
                                add_drdynvc_suite();
 
185
                        }
 
186
                        else if (strcmp("librfx", argv[*pindex]) == 0)
 
187
                        {
 
188
                                add_librfx_suite();
 
189
                        }
 
190
                        else if (strcmp("per", argv[*pindex]) == 0)
 
191
                        {
 
192
                                add_per_suite();
 
193
                        }
 
194
                        else if (strcmp("pcap", argv[*pindex]) == 0)
 
195
                        {
 
196
                                add_pcap_suite();
 
197
                        }
 
198
                        else if (strcmp("ber", argv[*pindex]) == 0)
 
199
                        {
 
200
                                add_ber_suite();
 
201
                        }
 
202
                        else if (strcmp("gcc", argv[*pindex]) == 0)
 
203
                        {
 
204
                                add_gcc_suite();
 
205
                        }
 
206
                        else if (strcmp("mcs", argv[*pindex]) == 0)
 
207
                        {
 
208
                                add_mcs_suite();
 
209
                        }
 
210
                        else if (strcmp("mppc", argv[*pindex]) == 0)
 
211
                        {
 
212
                                add_mppc_suite();
 
213
                        }
 
214
 
 
215
                        *pindex = *pindex + 1;
 
216
                }
 
217
        }
13
218
 
14
219
        CU_basic_set_mode(CU_BRM_VERBOSE);
15
220
        CU_basic_run_tests();
 
221
        ret = CU_get_number_of_failure_records();
16
222
        CU_cleanup_registry();
17
223
 
18
 
        return CU_get_error();
 
224
        return ret;
19
225
}
20
226