2 * FreeRDP: A Remote Desktop Protocol Client
5 * Copyright 2010 Marc-Andre Moreau <marcandre.moreau@gmail.com>
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <CUnit/Basic.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"
38 #include "test_freerdp.h"
39 #include "test_rail.h"
40 #include "test_pcap.h"
41 #include "test_mppc.h"
43 void dump_data(unsigned char * p, int len, int width, char* name)
45 unsigned char *line = p;
46 int i, thisline, offset = 0;
48 printf("\n%s[%d][%d]:\n", name, len / width, width);
51 printf("%04x ", offset);
52 thisline = len - offset;
56 for (i = 0; i < thisline; i++)
57 printf("%02x ", line[i]);
59 for (; i < width; i++)
69 void assert_stream(STREAM* s, uint8* data, int length, const char* func, int line)
75 actual_data = s->data;
76 actual_length = stream_get_length(s);
78 if (actual_length != length)
80 printf("\n %s (%d): length mismatch, actual:%d, expected:%d\n", func, line, actual_length, length);
82 printf("\nActual:\n");
83 freerdp_hexdump(actual_data, actual_length);
85 printf("Expected:\n");
86 freerdp_hexdump(data, length);
88 CU_FAIL("assert_stream, length mismatch");
92 for (i = 0; i < length; i++)
94 if (actual_data[i] != data[i])
96 printf("\n %s (%d): buffer mismatch:\n", func, line);
98 printf("\nActual:\n");
99 freerdp_hexdump(actual_data, length);
101 printf("Expected:\n");
102 freerdp_hexdump(data, length);
104 CU_FAIL("assert_stream, buffer mismatch");
110 int main(int argc, char* argv[])
113 int *pindex = &index;
116 if (CU_initialize_registry() != CUE_SUCCESS)
117 return CU_get_error();
119 if (argc < *pindex + 1)
136 while (*pindex < argc)
138 if (strcmp("rail", argv[*pindex]) == 0)
142 if (strcmp("color", argv[*pindex]) == 0)
146 if (strcmp("bitmap", argv[*pindex]) == 0)
150 else if (strcmp("libgdi", argv[*pindex]) == 0)
154 else if (strcmp("list", argv[*pindex]) == 0)
158 else if (strcmp("orders", argv[*pindex]) == 0)
162 else if (strcmp("license", argv[*pindex]) == 0)
166 else if (strcmp("stream", argv[*pindex]) == 0)
170 else if (strcmp("utils", argv[*pindex]) == 0)
174 else if (strcmp("chanman", argv[*pindex]) == 0)
178 else if (strcmp("cliprdr", argv[*pindex]) == 0)
182 else if (strcmp("drdynvc", argv[*pindex]) == 0)
186 else if (strcmp("librfx", argv[*pindex]) == 0)
190 else if (strcmp("per", argv[*pindex]) == 0)
194 else if (strcmp("pcap", argv[*pindex]) == 0)
198 else if (strcmp("ber", argv[*pindex]) == 0)
202 else if (strcmp("gcc", argv[*pindex]) == 0)
206 else if (strcmp("mcs", argv[*pindex]) == 0)
210 else if (strcmp("mppc", argv[*pindex]) == 0)
215 *pindex = *pindex + 1;
219 CU_basic_set_mode(CU_BRM_VERBOSE);
220 CU_basic_run_tests();
221 ret = CU_get_number_of_failure_records();
222 CU_cleanup_registry();