Merge pull request #2312 from bmiklautz/cmd_line_tests

Command line tests and fixes
This commit is contained in:
Marc-André Moreau 2015-01-16 07:30:10 -05:00
commit 8d32a86318
6 changed files with 109 additions and 5 deletions

View File

@ -50,6 +50,11 @@ int xf_list_monitors(xfContext* xfc)
XineramaScreenInfo* screen = NULL;
display = XOpenDisplay(NULL);
if (!display)
{
WLog_ERR(TAG, "failed to open X display");
return -1;
}
if (XineramaQueryExtension(display, &ignored, &ignored2))
{
@ -76,6 +81,11 @@ int xf_list_monitors(xfContext* xfc)
display = XOpenDisplay(NULL);
if(!display)
{
WLog_ERR(TAG, "failed to open X display");
return -1;
}
screen = ScreenOfDisplay(display, DefaultScreen(display));
WLog_DBG(TAG, " * [0] %dx%d\t+%d+%d", WidthOfScreen(screen), HeightOfScreen(screen), 0, 0);
XCloseDisplay(display);

View File

@ -1081,7 +1081,7 @@ BOOL freerdp_client_detect_command_line(int argc, char** argv, DWORD* flags)
return compatibility;
/* Check, if this may be windows style syntax... */
if (windows_cli_count && (windows_cli_count >= posix_cli_count) || (windows_cli_status <= COMMAND_LINE_STATUS_PRINT))
if ((windows_cli_count && (windows_cli_count >= posix_cli_count)) || (windows_cli_status <= COMMAND_LINE_STATUS_PRINT))
{
windows_cli_count = 1;
*flags = COMMAND_LINE_SEPARATOR_COLON;

View File

@ -6,7 +6,8 @@ set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c)
set(${MODULE_PREFIX}_TESTS
TestClientRdpFile.c
TestClientChannels.c)
TestClientChannels.c
TestClientCmdLine.c)
create_test_sourcelist(${MODULE_PREFIX}_SRCS
${${MODULE_PREFIX}_DRIVER}
@ -14,7 +15,7 @@ create_test_sourcelist(${MODULE_PREFIX}_SRCS
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client freerdp)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})

View File

@ -0,0 +1,93 @@
#include <freerdp/client.h>
#include <freerdp/client/cmdline.h>
#include <freerdp/settings.h>
#include <winpr/cmdline.h>
#include <winpr/spec.h>
#define TESTCASE(cmd, expected_return) status = freerdp_client_settings_parse_command_line(settings, ARRAYSIZE(cmd), cmd); \
if (status != expected_return) { \
printf("Test argument %s failed\n", #cmd); \
return -1; \
}
#define TESTCASE_SUCCESS(cmd) status = freerdp_client_settings_parse_command_line(settings, ARRAYSIZE(cmd), cmd); \
if (status < 0) { \
printf("Test argument %s failed\n", #cmd); \
return -1; \
}
int TestClientCmdLine(int argc, char* argv[])
{
int status;
rdpSettings* settings = freerdp_settings_new(0);
char* cmd1[] = {"xfreerdp", "--help"};
TESTCASE(cmd1, COMMAND_LINE_STATUS_PRINT_HELP);
char* cmd2[] = {"xfreerdp", "/help"};
TESTCASE(cmd2, COMMAND_LINE_STATUS_PRINT_HELP);
char* cmd3[] = {"xfreerdp", "-help"};
TESTCASE(cmd3, COMMAND_LINE_STATUS_PRINT_HELP);
char* cmd4[] = {"xfreerdp", "--version"};
TESTCASE(cmd4, COMMAND_LINE_STATUS_PRINT_VERSION);
char* cmd5[] = {"xfreerdp", "/version"};
TESTCASE(cmd5, COMMAND_LINE_STATUS_PRINT_VERSION);
char* cmd6[] = {"xfreerdp", "-version"};
TESTCASE(cmd6, COMMAND_LINE_STATUS_PRINT_VERSION);
char* cmd7[] = {"xfreerdp", "test.freerdp.com"};
TESTCASE_SUCCESS(cmd7);
char* cmd8[] = {"xfreerdp", "-v", "test.freerdp.com"};
TESTCASE_SUCCESS(cmd8);
char* cmd9[] = {"xfreerdp", "--v", "test.freerdp.com"};
TESTCASE_SUCCESS(cmd9);
char* cmd10[] = {"xfreerdp", "/v:test.freerdp.com"};
TESTCASE_SUCCESS(cmd10);
char* cmd11[] = {"xfreerdp", "--plugin", "rdpsnd", "--plugin", "rdpdr", "--data", "disk:media:/tmp", "--", "test.freerdp.com" };
TESTCASE_SUCCESS(cmd11);
char* cmd12[] = {"xfreerdp", "/sound", "/drive:media:/tmp", "/v:test.freerdp.com" };
TESTCASE_SUCCESS(cmd12);
// password gets overwritten therefore it need to be writeable
char* cmd13[6] = {"xfreerdp", "-u", "test", "-p", "test", "test.freerdp.com"};
cmd13[4] = malloc(5);
strncpy(cmd13[4], "test", 4);
TESTCASE_SUCCESS(cmd13);
free(cmd13[4]);
char* cmd14[] = {"xfreerdp", "-u", "test", "-p", "test", "-v", "test.freerdp.com"};
cmd14[4] = malloc(5);
strncpy(cmd14[4], "test", 4);
TESTCASE_SUCCESS(cmd14);
free(cmd14[4]);
char* cmd15[] = {"xfreerdp", "/u:test", "/p:test", "/v:test.freerdp.com"};
cmd15[2] = malloc(7);
strncpy(cmd15[2], "/p:test", 6);
TESTCASE_SUCCESS(cmd15);
free(cmd15[2]);
char* cmd16[] = {"xfreerdp", "-invalid"};
TESTCASE(cmd16, COMMAND_LINE_ERROR_NO_KEYWORD);
char* cmd17[] = {"xfreerdp", "--invalid"};
TESTCASE(cmd17, COMMAND_LINE_ERROR_NO_KEYWORD);
char* cmd18[] = {"xfreerdp", "/kbd-list"};
TESTCASE(cmd18, COMMAND_LINE_STATUS_PRINT);
char* cmd19[] = {"xfreerdp", "/monitor-list"};
TESTCASE(cmd19, COMMAND_LINE_STATUS_PRINT);
return 0;
}

View File

@ -201,7 +201,7 @@ BYTE* ringbuffer_ensure_linear_write(RingBuffer* rb, size_t sz)
if (rb->writePtr == rb->readPtr)
{
rb->writePtr = rb->readPtr = NULL;
rb->writePtr = rb->readPtr = 0;
}
if (rb->writePtr + sz < rb->size)

View File

@ -20,7 +20,7 @@ int TestBacktrace(int argc, char* argv[])
printf("%zd: %s\n", x, msg[x]);
rc = 0;
}
winpr_backtrace_symbols_fd(stack, stdout);
winpr_backtrace_symbols_fd(stack, fileno(stdout));
winpr_backtrace_free(stack);