Skip to content

Commit

Permalink
Fixed core tests, --filter=[core]
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Aug 22, 2024
1 parent 0df5246 commit dd9c95e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ jobs:
run: phpize && ./configure --enable-sockets --enable-mysqlnd --enable-openssl

- name: make
run: cmake . -DCODE_COVERAGE=ON -DSW_THREAD=1 &&
make VERBOSE=1 -j &&
sudo make install
run: |
cmake . -D CODE_COVERAGE=ON -D enable_thread=1
make VERBOSE=1 -j $(nproc) lib-swoole
- name: make test with valgrind
if: "contains(github.event.head_commit.message, '--valgrind')"
Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ link_directories(${LIBRARY_OUTPUT_PATH})
add_library(lib-swoole SHARED ${SRC_LIST})
set_target_properties(lib-swoole PROPERTIES OUTPUT_NAME "swoole" VERSION ${SWOOLE_VERSION})
target_link_libraries(lib-swoole ${SWOOLE_LINK_LIBRARIES})
if(CODE_COVERAGE)

if (CODE_COVERAGE)
target_link_libraries(lib-swoole coverage_config gcov)
endif(CODE_COVERAGE)

Expand Down Expand Up @@ -166,6 +167,10 @@ set_target_properties(ext-swoole PROPERTIES PREFIX "")
set_target_properties(ext-swoole PROPERTIES OUTPUT_NAME "swoole")
add_dependencies(ext-swoole lib-swoole)

if (DEFINED enable_thread)
add_definitions(-DSW_THREAD)
endif()

# find libpq
if (DEFINED libpq_dir)
target_include_directories(ext-swoole BEFORE ${LIBPQ_INCLUDE_DIRS})
Expand Down
7 changes: 5 additions & 2 deletions core-tests/run.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/bash
__DIR__=$(cd "$(dirname "$0")";pwd)
__SWOOLE_DIR__=$(cd "$(dirname "${__DIR__}")";pwd)

if [ "${SWOOLE_ENABLE_ASAN}" = 1 ]; then
cmake . -D enable_thread=1 -D enable_asan=1
cmake . -D swoole_dir="${__SWOOLE_DIR__}" -D enable_thread=1 -D enable_asan=1
else
cmake . -D enable_thread=1
cmake . -D swoole_dir="${__SWOOLE_DIR__}" -D enable_thread=1
fi
make -j8
ipcs -q
Expand Down
2 changes: 2 additions & 0 deletions core-tests/src/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ TEST(server, process) {
delete lock;
}

#ifdef SW_THREAD
TEST(server, thread) {
Server serv(Server::MODE_THREAD);
serv.worker_num = 2;
Expand Down Expand Up @@ -206,6 +207,7 @@ TEST(server, thread) {
serv.start();
t1.join();
}
#endif

TEST(server, reload_all_workers) {
Server serv(Server::MODE_PROCESS);
Expand Down
4 changes: 4 additions & 0 deletions src/server/thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ namespace swoole {
using network::Socket;

Factory *Server::create_thread_factory() {
#ifndef SW_THREAD
swoole_error("Thread support is not enabled, cannot create server with MODE_THREAD");
return nullptr;
#endif
reactor_num = worker_num;
connection_list = (Connection *) sw_calloc(max_connection, sizeof(Connection));
if (connection_list == nullptr) {
Expand Down

0 comments on commit dd9c95e

Please sign in to comment.