Skip to content

Commit a39a9f0

Browse files
committed
Added tests for HTTP2 --filter=[core]
1 parent 34d2454 commit a39a9f0

File tree

7 files changed

+471
-6
lines changed

7 files changed

+471
-6
lines changed

.github/workflows/core.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- uses: actions/checkout@v4
3535

3636
- name: install dependencies
37-
run: sudo apt update -y && sudo apt install -y googletest libgtest-dev redis-server libboost-stacktrace-dev libbrotli-dev nodejs npm
37+
run: sudo apt update -y && sudo apt install -y googletest libgtest-dev libnghttp2-dev libboost-stacktrace-dev libbrotli-dev redis-server nodejs npm nghttp2-client
3838

3939
- name: configure
4040
run: phpize && ./configure --enable-sockets --enable-mysqlnd --enable-openssl

core-tests/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,24 @@ set(core_tests_link_directories /usr/local/lib)
1616

1717
list(APPEND core_tests_libraries pthread gtest gtest_main)
1818

19+
find_package(PkgConfig REQUIRED)
20+
1921
# find GTest
2022
find_package(GTest REQUIRED)
2123
if (!${GTEST_FOUND})
2224
message(FATAL_ERROR "Not found GTest")
2325
endif()
2426
message(STATUS "Found GTest")
2527

28+
pkg_check_modules(NGHTTP2 REQUIRED libnghttp2)
29+
if (${NGHTTP2_FOUND})
30+
message(STATUS "Found nghttp2")
31+
list(APPEND core_tests_includes ${NGHTTP2_INCLUDE_DIR})
32+
list(APPEND core_tests_libraries ${NGHTTP2_LIBRARIES})
33+
else()
34+
message(STATUS "Not found nghttp2")
35+
endif()
36+
2637
list(APPEND core_tests_libraries ${GTEST_BOTH_LIBRARIES})
2738
list(APPEND core_tests_includes ${GTEST_INCLUDE_DIRS})
2839

core-tests/src/network/client.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ TEST(client, tcp) {
4040

4141
pid = proc.start();
4242

43-
sleep(1); // wait for the test server to start
43+
usleep(300000); // wait for the test server to start
4444

4545
Client cli(SW_SOCK_TCP, false);
4646
ASSERT_NE(cli.socket, nullptr);
@@ -52,6 +52,11 @@ TEST(client, tcp) {
5252
ASSERT_EQ(ret, GREETER_SIZE);
5353
ASSERT_STREQ(GREETER, buf);
5454

55+
Address peer_name;
56+
ASSERT_EQ(cli.get_peer_name(&peer_name), 0);
57+
ASSERT_STREQ(peer_name.get_addr(), "127.0.0.1");
58+
ASSERT_EQ(peer_name.get_port(), port);
59+
5560
ASSERT_EQ(cli.close(), SW_OK);
5661
ASSERT_EQ(cli.close(), SW_ERR);
5762

0 commit comments

Comments
 (0)