cunit: add transport unit test.

This commit is contained in:
Vic Lee 2011-07-03 15:54:32 +08:00
parent 5c98e98387
commit c07694a875
4 changed files with 101 additions and 0 deletions

View File

@ -21,6 +21,7 @@ include_directories(${CUNIT_INCLUDE_DIRS})
include_directories(.)
include_directories(../include)
include_directories(../libfreerdp-core)
include_directories(../libfreerdp-gdi)
add_executable(test_freerdp
@ -30,11 +31,14 @@ add_executable(test_freerdp
test_libgdi.h
test_stream.c
test_stream.h
test_transport.c
test_transport.h
test_freerdp.c
test_freerdp.h)
target_link_libraries(test_freerdp ${CUNIT_LIBRARIES})
target_link_libraries(test_freerdp freerdp-core)
target_link_libraries(test_freerdp freerdp-gdi)
target_link_libraries(test_freerdp freerdp-asn1)
target_link_libraries(test_freerdp freerdp-utils)

View File

@ -22,6 +22,7 @@
#include "test_color.h"
#include "test_libgdi.h"
#include "test_stream.h"
#include "test_transport.h"
#include "test_freerdp.h"
void dump_data(unsigned char * p, int len, int width, char* name)
@ -63,6 +64,7 @@ int main(int argc, char* argv[])
add_color_suite();
add_libgdi_suite();
add_stream_suite();
add_transport_suite();
}
else
{
@ -80,6 +82,10 @@ int main(int argc, char* argv[])
{
add_stream_suite();
}
else if (strcmp("transport", argv[*pindex]) == 0)
{
add_transport_suite();
}
*pindex = *pindex + 1;
}

65
cunit/test_transport.c Normal file
View File

@ -0,0 +1,65 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Transport Unit Tests
*
* Copyright 2011 Vic Lee
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <freerdp/freerdp.h>
#include <freerdp/utils/hexdump.h>
#include <freerdp/utils/stream.h>
#include "transport.h"
#include "test_transport.h"
static const char test_server[] = "192.168.0.1";
int init_transport_suite(void)
{
return 0;
}
int clean_transport_suite(void)
{
return 0;
}
int add_transport_suite(void)
{
add_test_suite(transport);
add_test_function(transport);
return 0;
}
void test_transport(void)
{
rdpTransport * transport;
int r;
transport = transport_new();
r = transport_connect(transport, test_server, 3389);
CU_ASSERT(r == 0);
transport_disconnect(transport);
CU_ASSERT(r == 0);
transport_free(transport);
}

26
cunit/test_transport.h Normal file
View File

@ -0,0 +1,26 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Transport Unit Tests
*
* Copyright 2011 Vic Lee
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "test_freerdp.h"
int init_transport_suite(void);
int clean_transport_suite(void);
int add_transport_suite(void);
void test_transport(void);