mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
ctest: add tests for evlib foreign example
This just runs each of the eventlib-foreign cases that are enabled, it doesn't do a client action during the test yet since that's hard to arrange with ctest, but it will catch most breakage. Change the LD_LIBRARY_PATH order when looking for evlib plugins, so that it searches there first, if given
This commit is contained in:
parent
f1e5e573e6
commit
bdf472b411
3 changed files with 111 additions and 41 deletions
|
@ -486,48 +486,49 @@ lws_create_context(const struct lws_context_creation_info *info)
|
|||
if (!lws_check_opt(info->options, map[n].flag))
|
||||
continue;
|
||||
|
||||
if (lws_plugins_init(&evlib_plugin_list,
|
||||
/*
|
||||
* Check LD_LIBRARY_PATH override path first if present
|
||||
*/
|
||||
|
||||
if (ld_env) {
|
||||
char temp[128];
|
||||
struct lws_tokenize ts;
|
||||
const char * tok[2] = { temp, NULL };
|
||||
|
||||
memset(&ts, 0, sizeof(ts));
|
||||
ts.start = ld_env;
|
||||
ts.len = strlen(ld_env);
|
||||
ts.flags = LWS_TOKENIZE_F_SLASH_NONTERM |
|
||||
LWS_TOKENIZE_F_DOT_NONTERM |
|
||||
LWS_TOKENIZE_F_MINUS_NONTERM |
|
||||
LWS_TOKENIZE_F_NO_INTEGERS |
|
||||
LWS_TOKENIZE_F_NO_FLOATS;
|
||||
|
||||
do {
|
||||
ts.e = (int8_t)lws_tokenize(&ts);
|
||||
if (ts.e != LWS_TOKZE_TOKEN)
|
||||
continue;
|
||||
|
||||
lws_strnncpy(temp, ts.token,
|
||||
ts.token_len,
|
||||
sizeof(temp));
|
||||
|
||||
if (!lws_plugins_init(
|
||||
&evlib_plugin_list, tok,
|
||||
"lws_evlib_plugin",
|
||||
map[n].name,
|
||||
NULL, NULL)) {
|
||||
ok = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
} while (ts.e > 0);
|
||||
}
|
||||
|
||||
if (!ok &&
|
||||
!lws_plugins_init(&evlib_plugin_list,
|
||||
dlist, "lws_evlib_plugin",
|
||||
map[n].name, NULL, NULL)) {
|
||||
|
||||
/*
|
||||
* No joy in the canned paths, try LD_LIBRARY_PATH
|
||||
*/
|
||||
|
||||
if (ld_env) {
|
||||
char temp[128];
|
||||
struct lws_tokenize ts;
|
||||
const char * tok[2] = { temp, NULL };
|
||||
|
||||
memset(&ts, 0, sizeof(ts));
|
||||
ts.start = ld_env;
|
||||
ts.len = strlen(ld_env);
|
||||
ts.flags = LWS_TOKENIZE_F_SLASH_NONTERM |
|
||||
LWS_TOKENIZE_F_DOT_NONTERM |
|
||||
LWS_TOKENIZE_F_NO_INTEGERS |
|
||||
LWS_TOKENIZE_F_NO_FLOATS;
|
||||
|
||||
do {
|
||||
ts.e = (int8_t)lws_tokenize(&ts);
|
||||
if (ts.e != LWS_TOKZE_TOKEN)
|
||||
continue;
|
||||
|
||||
lws_strnncpy(temp, ts.token,
|
||||
ts.token_len,
|
||||
sizeof(temp));
|
||||
|
||||
if (!lws_plugins_init(
|
||||
&evlib_plugin_list, tok,
|
||||
"lws_evlib_plugin",
|
||||
map[n].name,
|
||||
NULL, NULL)) {
|
||||
ok = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
} while (ts.e > 0);
|
||||
}
|
||||
} else
|
||||
map[n].name, NULL, NULL))
|
||||
ok = 1;
|
||||
|
||||
if (!ok) {
|
||||
|
|
|
@ -91,6 +91,28 @@ endif()
|
|||
|
||||
if (requirements)
|
||||
add_executable(${SAMP} ${SRCS})
|
||||
|
||||
#
|
||||
# tests are running in the same machine context in parallel so they
|
||||
# compete for the same ports. Select a base port from which sai
|
||||
# instance we are running in, add another digit at the actual test
|
||||
# according to which subtest it is. Then there can be no clashes
|
||||
# regardless of how many build and tests in parallel.
|
||||
#
|
||||
|
||||
set(PORT_HSEF_SRV "961")
|
||||
if ("$ENV{SAI_INSTANCE_IDX}" STREQUAL "0")
|
||||
set(PORT_HSEF_SRV 962)
|
||||
endif()
|
||||
if ("$ENV{SAI_INSTANCE_IDX}" STREQUAL "1")
|
||||
set(PORT_HSEF_SRV 963)
|
||||
endif()
|
||||
if ("$ENV{SAI_INSTANCE_IDX}" STREQUAL "2")
|
||||
set(PORT_HSEF_SRV 964)
|
||||
endif()
|
||||
if ("$ENV{SAI_INSTANCE_IDX}" STREQUAL "3")
|
||||
set(PORT_HSEF_SRV 965)
|
||||
endif()
|
||||
|
||||
if (websockets_shared)
|
||||
target_link_libraries(${SAMP} websockets_shared ${extralibs} ${PTHREAD_LIB} ${LIBWEBSOCKETS_DEP_LIBS})
|
||||
|
@ -98,4 +120,49 @@ if (requirements)
|
|||
else()
|
||||
target_link_libraries(${SAMP} websockets ${extralibs} ${PTHREAD_LIB} ${LIBWEBSOCKETS_DEP_LIBS})
|
||||
endif()
|
||||
|
||||
# notice we override the evlib plugin source via LD_LIBRARY_PATH so
|
||||
# we are using the evlibs we just built, if any
|
||||
|
||||
if (LWS_WITH_LIBUV)
|
||||
add_test(NAME hs_evlib_foreign_uv COMMAND lws-minimal-http-server-eventlib-foreign --uv -p ${PORT_HSEF_SRV}1)
|
||||
set_tests_properties(hs_evlib_foreign_uv
|
||||
PROPERTIES
|
||||
ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib"
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/http-server/minimal-http-server-eventlib-foreign
|
||||
TIMEOUT 50)
|
||||
endif()
|
||||
if (LWS_WITH_LIBEVENT)
|
||||
add_test(NAME hs_evlib_foreign_event COMMAND lws-minimal-http-server-eventlib-foreign --event -p ${PORT_HSEF_SRV}2)
|
||||
set_tests_properties(hs_evlib_foreign_event
|
||||
PROPERTIES
|
||||
ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib"
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/http-server/minimal-http-server-eventlib-foreign
|
||||
TIMEOUT 50)
|
||||
endif()
|
||||
if (LWS_WITH_LIBEV)
|
||||
add_test(NAME hs_evlib_foreign_ev COMMAND lws-minimal-http-server-eventlib-foreign --ev -p ${PORT_HSEF_SRV}3)
|
||||
set_tests_properties(hs_evlib_foreign_ev
|
||||
PROPERTIES
|
||||
ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib"
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/http-server/minimal-http-server-eventlib-foreign
|
||||
TIMEOUT 50)
|
||||
endif()
|
||||
if (LWS_WITH_GLIB)
|
||||
add_test(NAME hs_evlib_foreign_glib COMMAND lws-minimal-http-server-eventlib-foreign --glib -p ${PORT_HSEF_SRV}4)
|
||||
set_tests_properties(hs_evlib_foreign_glib
|
||||
PROPERTIES
|
||||
ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib"
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/http-server/minimal-http-server-eventlib-foreign
|
||||
TIMEOUT 50)
|
||||
endif()
|
||||
if (LWS_WITH_SDEVENT)
|
||||
add_test(NAME hs_evlib_foreign_sd COMMAND lws-minimal-http-server-eventlib-foreign --sd -p ${PORT_HSEF_SRV}5)
|
||||
set_tests_properties(hs_evlib_foreign_sd
|
||||
PROPERTIES
|
||||
ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib"
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/minimal-examples/http-server/minimal-http-server-eventlib-foreign
|
||||
TIMEOUT 50)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
|
|
@ -152,6 +152,8 @@ int main(int argc, const char **argv)
|
|||
|
||||
memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
|
||||
info.port = 7681;
|
||||
if ((p = lws_cmdline_option(argc, argv, "-p")))
|
||||
info.port = atoi(p);
|
||||
info.mounts = &mount;
|
||||
info.error_document_404 = "/404.html";
|
||||
info.pcontext = &context;
|
||||
|
|
Loading…
Add table
Reference in a new issue