cunit: add utils/semaphore unit tests

This commit is contained in:
Vic Lee 2011-07-08 11:26:38 +08:00
parent 822199040a
commit 1f6fe46d03
4 changed files with 89 additions and 0 deletions

View File

@ -39,6 +39,8 @@ add_executable(test_freerdp
test_list.h
test_stream.c
test_stream.h
test_utils.c
test_utils.h
test_transport.c
test_transport.h
test_freerdp.c

View File

@ -27,6 +27,7 @@
#include "test_libgdi.h"
#include "test_list.h"
#include "test_stream.h"
#include "test_utils.h"
#include "test_transport.h"
#include "test_freerdp.h"
@ -116,6 +117,7 @@ int main(int argc, char* argv[])
add_libgdi_suite();
add_list_suite();
add_stream_suite();
add_utils_suite();
add_transport_suite();
}
else
@ -138,6 +140,10 @@ int main(int argc, char* argv[])
{
add_stream_suite();
}
else if (strcmp("utils", argv[*pindex]) == 0)
{
add_utils_suite();
}
else if (strcmp("transport", argv[*pindex]) == 0)
{
add_transport_suite();

55
cunit/test_utils.c Normal file
View File

@ -0,0 +1,55 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Utils 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/semaphore.h>
#include "test_utils.h"
int init_utils_suite(void)
{
return 0;
}
int clean_utils_suite(void)
{
return 0;
}
int add_utils_suite(void)
{
add_test_suite(utils);
add_test_function(semaphore);
return 0;
}
void test_semaphore(void)
{
freerdp_sem sem;
sem = freerdp_sem_new(1);
freerdp_sem_wait(sem);
freerdp_sem_signal(sem);
freerdp_sem_free(sem);
}

26
cunit/test_utils.h Normal file
View File

@ -0,0 +1,26 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* Utils 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_list_suite(void);
int clean_list_suite(void);
int add_list_suite(void);
void test_semaphore(void);