fix problems in test and requests for cmake build

add missing stdarg header

fix hardcoded errno integer values in tests

add dependency to wstestdata and rename to prevent building it as c
source
pull/3/head
Andreas Weigel 8 years ago committed by Christian Beier
parent a90a43cda5
commit 8fefdcde27
No known key found for this signature in database
GPG Key ID: 421BB3B45C6067F8

@ -49,6 +49,7 @@ option(WITH_IPv6 "Enable IPv6 Support" ON)
option(WITH_WEBSOCKETS "Build with websockets support" ON)
if(WITH_ZLIB)
find_package(ZLIB)
endif(WITH_ZLIB)
@ -500,9 +501,11 @@ foreach(e ${LIBVNCCLIENT_EXAMPLES})
target_link_libraries(client_examples_${e} vncclient ${CMAKE_THREAD_LIBS_INIT} ${SDL_LIBRARY} ${FFMPEG_LIBRARIES})
endforeach(e ${LIBVNCCLIENT_EXAMPLES})
#
# them tests
#
if(UNIX)
set(ADDITIONAL_TEST_LIBS m)
endif(UNIX)
@ -510,41 +513,18 @@ endif(UNIX)
set(SIMPLETESTS
cargstest
copyrecttest
wstest
)
add_test(NAME cargs COMMAND test_cargstest)
add_test(NAME websockets_decode COMMAND test_wstest)
if(CMAKE_USE_PTHREADS_INI)
list(APPEND SIMPLETESTS encodingstest)
endif(CMAKE_USE_PTHREADS_INI)
if(FOUND_LIBJPEG_TURBO)
list(APPEND SIMPLETESTS tjunittest tjbench)
set(tjunittest_add_src
${TESTS_DIR}/tjutil.c
${TESTS_DIR}/tjutil.h
${COMMON_DIR}/turbojpeg.c
${COMMON_DIR}/turbojpeg.h
)
set(tjbench_add_src
${TESTS_DIR}/tjbench.c
${TESTS_DIR}/tjutil.c
${TESTS_DIR}/tjutil.h
${TESTS_DIR}/bmp.c
${TESTS_DIR}/bmp.h
${COMMON_DIR}/turbojpeg.c
${COMMON_DIR}/turbojpeg.h
if(CMAKE_USE_PTHREADS_INIT)
set(SIMPLETESTS
${SIMPLETESTS}
encodingstest
)
add_test(NAME turbojpeg COMMAND test_tjunittest)
endif(FOUND_LIBJPEG_TURBO)
endif(CMAKE_USE_PTHREADS_INIT)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
foreach(t ${SIMPLETESTS})
add_executable(test_${t} ${TESTS_DIR}/${t}.c ${${t}_add_src})
add_executable(test_${t} ${TESTS_DIR}/${t}.c)
set_target_properties(test_${t} PROPERTIES OUTPUT_NAME ${t})
set_target_properties(test_${t} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
target_link_libraries(test_${t} vncserver vncclient ${ADDITIONAL_TEST_LIBS})
@ -577,10 +557,19 @@ if(WITH_JPEG AND FOUND_LIBJPEG_TURBO)
endif(WITH_JPEG AND FOUND_LIBJPEG_TURBO)
add_executable(test_wstest
${TESTS_DIR}/wstest.c
${TESTS_DIR}/wstestdata.inc
)
set_target_properties(test_wstest PROPERTIES OUTPUT_NAME wstest)
set_target_properties(test_wstest PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
target_link_libraries(test_wstest vncserver vncclient ${ADDITIONAL_TEST_LIBS})
add_test(NAME cargs COMMAND test_cargstest)
if(FOUND_LIBJPEG_TURBO)
add_test(NAME turbojpeg COMMAND test_tjunittest)
endif(FOUND_LIBJPEG_TURBO)
add_test(NAME wstest COMMAND test_wstest)
#
# this gets the libraries needed by TARGET in "-libx -liby ..." form

@ -24,7 +24,6 @@
import websockets
import base64
import errno
'''
Create websocket frames for the wstest websocket decoding unit test.
@ -105,13 +104,13 @@ flist.append(Testframe(websockets.framing.Frame(1, 2, bytearray("Frame2 does con
#flist.append(Testframe(websockets.framing.Frame(1, 2, bytearray([(x % 26) + 65 for x in range(100000)])), "100k binary frame (ABC..YZABC..)"))
### some conn reset frames, one with no close message, one with close message
flist.append(Testframe(websockets.framing.Frame(1, 8, bytearray(list([0x03, 0xEB]))), "Close frame (Reason 1003)", experrno=errno.ECONNRESET))
flist.append(Testframe(websockets.framing.Frame(1, 8, bytearray(list([0x03, 0xEB])) + bytearray("I'm a close reason and much more than that!", encoding="utf-8")), "Close frame (Reason 1003) and msg", experrno=errno.ECONNRESET))
flist.append(Testframe(websockets.framing.Frame(1, 8, bytearray(list([0x03, 0xEB]))), "Close frame (Reason 1003)", experrno="ECONNRESET"))
flist.append(Testframe(websockets.framing.Frame(1, 8, bytearray(list([0x03, 0xEB])) + bytearray("I'm a close reason and much more than that!", encoding="utf-8")), "Close frame (Reason 1003) and msg", experrno="ECONNRESET"))
### invalid header values
flist.append(Testframe(websockets.framing.Frame(1, 1, bytearray("Testit", encoding="utf-8")), "Invalid frame: Wrong masking", experrno=errno.EPROTO, mask=False))
flist.append(Testframe(websockets.framing.Frame(1, 1, bytearray("..Lore Ipsum", encoding="utf-8")), "Invalid frame: Length of < 126 with add. 16 bit len field", experrno=errno.EPROTO, modify_bytes={ 1: 0xFE, 2: 0x00, 3: 0x0F}))
flist.append(Testframe(websockets.framing.Frame(1, 1, bytearray("........Lore Ipsum", encoding="utf-8")), "Invalid frame: Length of < 126 with add. 64 bit len field", experrno=errno.EPROTO, modify_bytes={ 1: 0xFF, 2: 0x00, 3: 0x00, 4: 0x00, 5: 0x00, 6: 0x80, 7: 0x40}))
flist.append(Testframe(websockets.framing.Frame(1, 1, bytearray("Testit", encoding="utf-8")), "Invalid frame: Wrong masking", experrno="EPROTO", mask=False))
flist.append(Testframe(websockets.framing.Frame(1, 1, bytearray("..Lore Ipsum", encoding="utf-8")), "Invalid frame: Length of < 126 with add. 16 bit len field", experrno="EPROTO", modify_bytes={ 1: 0xFE, 2: 0x00, 3: 0x0F}))
flist.append(Testframe(websockets.framing.Frame(1, 1, bytearray("........Lore Ipsum", encoding="utf-8")), "Invalid frame: Length of < 126 with add. 64 bit len field", experrno="EPROTO", modify_bytes={ 1: 0xFF, 2: 0x00, 3: 0x00, 4: 0x00, 5: 0x00, 6: 0x80, 7: 0x40}))
s = "struct ws_frame_test tests[] = {\n"
for i in range(len(flist)):

@ -29,6 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
#include <errno.h>
@ -70,7 +71,7 @@ struct ws_frame_test {
int close_sock_at;
};
#include "wstestdata.c"
#include "wstestdata.inc"
char el_log[1000000];
char *el_pos;

@ -52,7 +52,7 @@ struct ws_frame_test tests[] = {
.expectedDecodeBuf={0X03,0XEB},
.frame_len=8,
.raw_payload_len=2,
.expected_errno=104,
.expected_errno=ECONNRESET,
.descr="Close frame (Reason 1003)",
.i=0,
.simulate_sock_malfunction_at=0,
@ -64,7 +64,7 @@ struct ws_frame_test tests[] = {
.expectedDecodeBuf={0X03,0XEB,0X49,0X27,0X6D,0X20,0X61,0X20,0X63,0X6C,0X6F,0X73,0X65,0X20,0X72,0X65,0X61,0X73,0X6F,0X6E,0X20,0X61,0X6E,0X64,0X20,0X6D,0X75,0X63,0X68,0X20,0X6D,0X6F,0X72,0X65,0X20,0X74,0X68,0X61,0X6E,0X20,0X74,0X68,0X61,0X74,0X21},
.frame_len=51,
.raw_payload_len=45,
.expected_errno=104,
.expected_errno=ECONNRESET,
.descr="Close frame (Reason 1003) and msg",
.i=0,
.simulate_sock_malfunction_at=0,
@ -76,7 +76,7 @@ struct ws_frame_test tests[] = {
.expectedDecodeBuf={0X54,0X65,0X73,0X74,0X69,0X74},
.frame_len=10,
.raw_payload_len=6,
.expected_errno=71,
.expected_errno=EPROTO,
.descr="Invalid frame: Wrong masking",
.i=0,
.simulate_sock_malfunction_at=0,
@ -88,7 +88,7 @@ struct ws_frame_test tests[] = {
.expectedDecodeBuf={0X2E,0XFE,0X00,0X0F,0X72,0X65,0X20,0X49,0X70,0X73,0X75,0X6D},
.frame_len=22,
.raw_payload_len=12,
.expected_errno=71,
.expected_errno=EPROTO,
.descr="Invalid frame: Length of < 126 with add. 16 bit len field",
.i=0,
.simulate_sock_malfunction_at=0,
@ -100,7 +100,7 @@ struct ws_frame_test tests[] = {
.expectedDecodeBuf={0X2E,0XFF,0X00,0X00,0X00,0X00,0X80,0X40,0X4C,0X6F,0X72,0X65,0X20,0X49,0X70,0X73,0X75,0X6D},
.frame_len=30,
.raw_payload_len=18,
.expected_errno=71,
.expected_errno=EPROTO,
.descr="Invalid frame: Length of < 126 with add. 64 bit len field",
.i=0,
.simulate_sock_malfunction_at=0,
Loading…
Cancel
Save