Skip to content

Commit

Permalink
Merge pull request #2511 from Nexarian/egfx_tests
Browse files Browse the repository at this point in the history
A simple working unit test for the newly introduced EGFX functions
  • Loading branch information
Nexarian authored Jan 24, 2023
2 parents 59f2ae3 + db5ea2f commit 29ef7f8
Show file tree
Hide file tree
Showing 17 changed files with 414 additions and 196 deletions.
9 changes: 2 additions & 7 deletions common/os_calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1692,12 +1692,7 @@ int
g_set_wait_obj(tintptr obj)
{
#ifdef _WIN32
if (obj == 0)
{
return 0;
}
SetEvent((HANDLE)obj);
return 0;
#error "Win32 is no longer supported."
#else
int error;
int fd;
Expand All @@ -1709,7 +1704,7 @@ g_set_wait_obj(tintptr obj)
{
return 0;
}
fd = obj & 0xffff;
fd = obj & USHRT_MAX;
if (g_fd_can_read(fd))
{
/* already signalled */
Expand Down
2 changes: 2 additions & 0 deletions libxrdp/libxrdpinc.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#include "xrdp_rail.h"

struct list;

/* struct xrdp_client_info moved to xrdp_client_info.h */

struct xrdp_brush
Expand Down
2 changes: 2 additions & 0 deletions libxrdp/xrdp_orders_rail.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#if !defined(_XRDP_ORDERS_RAIL_H)
#define _XRDP_ORDERS_RAIL_H

#include "libxrdp.h"

int
xrdp_orders_send_window_delete(struct xrdp_orders *self, int window_id);
int
Expand Down
20 changes: 20 additions & 0 deletions tests/xrdp/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ check_PROGRAMS = test_xrdp
test_xrdp_SOURCES = \
test_xrdp.h \
test_xrdp_main.c \
test_xrdp_egfx.c \
test_bitmap_load.c

test_xrdp_CFLAGS = \
Expand All @@ -37,5 +38,24 @@ test_xrdp_LDADD = \
$(top_builddir)/xrdp/xrdp_bitmap_common.o \
$(top_builddir)/xrdp/funcs.o \
$(top_builddir)/common/libcommon.la \
$(top_builddir)/libipm/libipm.la \
$(top_builddir)/libxrdp/libxrdp.la \
$(top_builddir)/libpainter/src/libpainter.la \
$(top_builddir)/librfxcodec/src/librfxencode.la \
$(top_builddir)/xrdp/lang.o \
$(top_builddir)/xrdp/xrdp_mm.o \
$(top_builddir)/xrdp/xrdp_wm.o \
$(top_builddir)/xrdp/xrdp_font.o \
$(top_builddir)/xrdp/xrdp_egfx.o \
$(top_builddir)/xrdp/xrdp_cache.o \
$(top_builddir)/xrdp/xrdp_region.o \
$(top_builddir)/xrdp/xrdp_listen.o \
$(top_builddir)/xrdp/xrdp_bitmap.o \
$(top_builddir)/xrdp/xrdp_painter.o \
$(top_builddir)/xrdp/xrdp_encoder.o \
$(top_builddir)/xrdp/xrdp_process.o \
$(top_builddir)/xrdp/xrdp_login_wnd.o \
$(top_builddir)/xrdp/xrdp_main_utils.o \
$(PIXMAN_LIBS) \
$(IMLIB2_LIBS) \
@CHECK_LIBS@
1 change: 1 addition & 0 deletions tests/xrdp/test_xrdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
#include <check.h>

Suite *make_suite_test_bitmap_load(void);
Suite *make_suite_egfx_base_functions(void);

#endif /* TEST_XRDP_H */
76 changes: 76 additions & 0 deletions tests/xrdp/test_xrdp_egfx.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Jay Sorg 2004-2021
*
* 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.
*
* Test driver for XRDP routines
*
* If you want to run this driver under valgrind to check for memory leaks,
* use the following command line:-
*
* CK_FORK=no valgrind --leak-check=full --show-leak-kinds=all \
* .libs/test_xrdp
*
* without the 'CK_FORK=no', memory still allocated by the test driver will
* be logged
*/

#if defined(HAVE_CONFIG_H)
#include "config_ac.h"
#endif

#include "log.h"
#include "os_calls.h"
#include <stdlib.h>
#include "xrdp_egfx.h"
#include "test_xrdp.h"

START_TEST(test_xrdp_egfx_send_create_surface__happy_path)
{
struct xrdp_egfx_bulk *bulk = g_new0(struct xrdp_egfx_bulk, 1);

const int surface_id = 0xFF;
const int width = 640;
const int height = 480;
const int pixel_format = 32;

struct stream *s = xrdp_egfx_create_surface(
bulk, surface_id, width, height, pixel_format);
s->p = s->data;

unsigned char descriptor;
in_uint8(s, descriptor);
ck_assert_int_eq(0xE0, descriptor);
}
END_TEST

/******************************************************************************/
Suite *
make_suite_egfx_base_functions(void)
{
Suite *s;
TCase *tc_process_monitors;

s = suite_create("test_xrdp_egfx_base_functions");

tc_process_monitors = tcase_create("xrdp_egfx_base_functions");
tcase_add_test(tc_process_monitors,
test_xrdp_egfx_send_create_surface__happy_path);

suite_add_tcase(s, tc_process_monitors);

return s;
}

1 change: 1 addition & 0 deletions tests/xrdp/test_xrdp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ int main (void)
log_config_free(logging);

sr = srunner_create (make_suite_test_bitmap_load());
srunner_add_suite(sr, make_suite_egfx_base_functions());

srunner_set_tap(sr, "-");
srunner_run_all (sr, CK_ENV);
Expand Down
3 changes: 2 additions & 1 deletion xrdp/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ xrdp_SOURCES = \
xrdp_types.h \
xrdp_egfx.c \
xrdp_egfx.h \
xrdp_wm.c
xrdp_wm.c \
xrdp_main_utils.c

xrdp_LDADD = \
$(top_builddir)/common/libcommon.la \
Expand Down
Loading

0 comments on commit 29ef7f8

Please sign in to comment.