Skip to content

Commit 29ef7f8

Browse files
authored
Merge pull request #2511 from Nexarian/egfx_tests
A simple working unit test for the newly introduced EGFX functions
2 parents 59f2ae3 + db5ea2f commit 29ef7f8

17 files changed

+414
-196
lines changed

common/os_calls.c

+2-7
Original file line numberDiff line numberDiff line change
@@ -1692,12 +1692,7 @@ int
16921692
g_set_wait_obj(tintptr obj)
16931693
{
16941694
#ifdef _WIN32
1695-
if (obj == 0)
1696-
{
1697-
return 0;
1698-
}
1699-
SetEvent((HANDLE)obj);
1700-
return 0;
1695+
#error "Win32 is no longer supported."
17011696
#else
17021697
int error;
17031698
int fd;
@@ -1709,7 +1704,7 @@ g_set_wait_obj(tintptr obj)
17091704
{
17101705
return 0;
17111706
}
1712-
fd = obj & 0xffff;
1707+
fd = obj & USHRT_MAX;
17131708
if (g_fd_can_read(fd))
17141709
{
17151710
/* already signalled */

libxrdp/libxrdpinc.h

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#include "xrdp_rail.h"
2525

26+
struct list;
27+
2628
/* struct xrdp_client_info moved to xrdp_client_info.h */
2729

2830
struct xrdp_brush

libxrdp/xrdp_orders_rail.h

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#if !defined(_XRDP_ORDERS_RAIL_H)
2020
#define _XRDP_ORDERS_RAIL_H
2121

22+
#include "libxrdp.h"
23+
2224
int
2325
xrdp_orders_send_window_delete(struct xrdp_orders *self, int window_id);
2426
int

tests/xrdp/Makefile.am

+20
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ check_PROGRAMS = test_xrdp
2626
test_xrdp_SOURCES = \
2727
test_xrdp.h \
2828
test_xrdp_main.c \
29+
test_xrdp_egfx.c \
2930
test_bitmap_load.c
3031

3132
test_xrdp_CFLAGS = \
@@ -37,5 +38,24 @@ test_xrdp_LDADD = \
3738
$(top_builddir)/xrdp/xrdp_bitmap_common.o \
3839
$(top_builddir)/xrdp/funcs.o \
3940
$(top_builddir)/common/libcommon.la \
41+
$(top_builddir)/libipm/libipm.la \
42+
$(top_builddir)/libxrdp/libxrdp.la \
43+
$(top_builddir)/libpainter/src/libpainter.la \
44+
$(top_builddir)/librfxcodec/src/librfxencode.la \
45+
$(top_builddir)/xrdp/lang.o \
46+
$(top_builddir)/xrdp/xrdp_mm.o \
47+
$(top_builddir)/xrdp/xrdp_wm.o \
48+
$(top_builddir)/xrdp/xrdp_font.o \
49+
$(top_builddir)/xrdp/xrdp_egfx.o \
50+
$(top_builddir)/xrdp/xrdp_cache.o \
51+
$(top_builddir)/xrdp/xrdp_region.o \
52+
$(top_builddir)/xrdp/xrdp_listen.o \
53+
$(top_builddir)/xrdp/xrdp_bitmap.o \
54+
$(top_builddir)/xrdp/xrdp_painter.o \
55+
$(top_builddir)/xrdp/xrdp_encoder.o \
56+
$(top_builddir)/xrdp/xrdp_process.o \
57+
$(top_builddir)/xrdp/xrdp_login_wnd.o \
58+
$(top_builddir)/xrdp/xrdp_main_utils.o \
59+
$(PIXMAN_LIBS) \
4060
$(IMLIB2_LIBS) \
4161
@CHECK_LIBS@

tests/xrdp/test_xrdp.h

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
#include <check.h>
55

66
Suite *make_suite_test_bitmap_load(void);
7+
Suite *make_suite_egfx_base_functions(void);
78

89
#endif /* TEST_XRDP_H */

tests/xrdp/test_xrdp_egfx.c

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* xrdp: A Remote Desktop Protocol server.
3+
*
4+
* Copyright (C) Jay Sorg 2004-2021
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Test driver for XRDP routines
19+
*
20+
* If you want to run this driver under valgrind to check for memory leaks,
21+
* use the following command line:-
22+
*
23+
* CK_FORK=no valgrind --leak-check=full --show-leak-kinds=all \
24+
* .libs/test_xrdp
25+
*
26+
* without the 'CK_FORK=no', memory still allocated by the test driver will
27+
* be logged
28+
*/
29+
30+
#if defined(HAVE_CONFIG_H)
31+
#include "config_ac.h"
32+
#endif
33+
34+
#include "log.h"
35+
#include "os_calls.h"
36+
#include <stdlib.h>
37+
#include "xrdp_egfx.h"
38+
#include "test_xrdp.h"
39+
40+
START_TEST(test_xrdp_egfx_send_create_surface__happy_path)
41+
{
42+
struct xrdp_egfx_bulk *bulk = g_new0(struct xrdp_egfx_bulk, 1);
43+
44+
const int surface_id = 0xFF;
45+
const int width = 640;
46+
const int height = 480;
47+
const int pixel_format = 32;
48+
49+
struct stream *s = xrdp_egfx_create_surface(
50+
bulk, surface_id, width, height, pixel_format);
51+
s->p = s->data;
52+
53+
unsigned char descriptor;
54+
in_uint8(s, descriptor);
55+
ck_assert_int_eq(0xE0, descriptor);
56+
}
57+
END_TEST
58+
59+
/******************************************************************************/
60+
Suite *
61+
make_suite_egfx_base_functions(void)
62+
{
63+
Suite *s;
64+
TCase *tc_process_monitors;
65+
66+
s = suite_create("test_xrdp_egfx_base_functions");
67+
68+
tc_process_monitors = tcase_create("xrdp_egfx_base_functions");
69+
tcase_add_test(tc_process_monitors,
70+
test_xrdp_egfx_send_create_surface__happy_path);
71+
72+
suite_add_tcase(s, tc_process_monitors);
73+
74+
return s;
75+
}
76+

tests/xrdp/test_xrdp_main.c

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ int main (void)
5151
log_config_free(logging);
5252

5353
sr = srunner_create (make_suite_test_bitmap_load());
54+
srunner_add_suite(sr, make_suite_egfx_base_functions());
5455

5556
srunner_set_tap(sr, "-");
5657
srunner_run_all (sr, CK_ENV);

xrdp/Makefile.am

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ xrdp_SOURCES = \
6060
xrdp_types.h \
6161
xrdp_egfx.c \
6262
xrdp_egfx.h \
63-
xrdp_wm.c
63+
xrdp_wm.c \
64+
xrdp_main_utils.c
6465

6566
xrdp_LDADD = \
6667
$(top_builddir)/common/libcommon.la \

0 commit comments

Comments
 (0)