2 * FreeRDP: A Remote Desktop Protocol Client
3 * pcap File Format Unit Tests
5 * Copyright 2011 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 <freerdp/freerdp.h>
21 #include <freerdp/utils/hexdump.h>
22 #include <freerdp/utils/pcap.h>
24 #include "test_pcap.h"
26 int init_pcap_suite(void)
31 int clean_pcap_suite(void)
36 int add_pcap_suite(void)
40 add_test_function(pcap);
45 uint8 test_packet_1[16] =
46 "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA";
48 uint8 test_packet_2[32] =
49 "\xBB\xBB\xBB\xBB\xBB\xBB\xBB\xBB\xBB\xBB\xBB\xBB\xBB\xBB\xBB\xBB"
50 "\xBB\xBB\xBB\xBB\xBB\xBB\xBB\xBB\xBB\xBB\xBB\xBB\xBB\xBB\xBB\xBB";
52 uint8 test_packet_3[64] =
53 "\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC"
54 "\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC"
55 "\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC"
56 "\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC";
68 test_packet packets[3];
70 packets[0].data = test_packet_1;
71 packets[0].length = sizeof(test_packet_1);
72 packets[1].data = test_packet_2;
73 packets[1].length = sizeof(test_packet_2);
74 packets[2].data = test_packet_3;
75 packets[2].length = sizeof(test_packet_3);
77 pcap = pcap_open("/tmp/test.pcap", true);
78 pcap_add_record(pcap, test_packet_1, sizeof(test_packet_1));
80 pcap_add_record(pcap, test_packet_2, sizeof(test_packet_2));
82 pcap_add_record(pcap, test_packet_3, sizeof(test_packet_3));
85 pcap = pcap_open("/tmp/test.pcap", false);
88 while (pcap_has_next_record(pcap))
90 pcap_get_next_record(pcap, &record);
91 CU_ASSERT(record.length == packets[i].length)