Skip to content

Commit 67f3986

Browse files
authored
Merge pull request #187 from ngtcp2/munit
Migrate to munit form cunit
2 parents fd63249 + 832d431 commit 67f3986

22 files changed

+859
-941
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@ jobs:
3232
autotools-dev \
3333
libtool \
3434
pkg-config \
35-
libcunit1-dev \
3635
cmake \
3736
cmake-data
3837
- name: MacOS setup
3938
if: runner.os == 'macOS'
4039
run: |
41-
brew install cunit autoconf automake pkg-config libtool
40+
brew install autoconf automake pkg-config libtool
4241
- name: Setup clang (Linux)
4342
if: runner.os == 'Linux' && matrix.compiler == 'clang'
4443
run: |
@@ -59,6 +58,9 @@ jobs:
5958
run: |
6059
echo 'CC=gcc' >> $GITHUB_ENV
6160
echo 'CXX=g++' >> $GITHUB_ENV
61+
- name: git submodule
62+
run: |
63+
git submodule update --init --depth 1
6264
- name: Configure autotools
6365
if: matrix.buildtool == 'autotools'
6466
run: |
@@ -117,26 +119,20 @@ jobs:
117119
libtool \
118120
pkg-config \
119121
wine
120-
- name: Build CUnit
121-
run: |
122-
curl -LO https://jaist.dl.sourceforge.net/project/cunit/CUnit/2.1-3/CUnit-2.1-3.tar.bz2
123-
tar xf CUnit-2.1-3.tar.bz2
124-
cd CUnit-2.1-3
125-
./bootstrap
126-
./configure --disable-shared --host="$HOST" --prefix="$PWD/build"
127-
make -j$(nproc) install
128122
- name: Configure autotools
129123
run: |
124+
git submodule update --init --depth 1
130125
autoreconf -i && \
131-
./configure --enable-werror --enable-lib-only --with-cunit \
132-
--host="$HOST" PKG_CONFIG_PATH="$PWD/CUnit-2.1-3/build/lib/pkgconfig"
126+
./configure --enable-werror --enable-lib-only --host="$HOST" \
127+
LIBS="-pthread"
133128
- name: Build nghttp3
134129
run: |
135130
make -j$(nproc)
136131
make -j$(nproc) check TESTS=""
137132
- name: Run tests
138133
if: matrix.host == 'x86_64-w64-mingw32'
139134
run: |
135+
export WINEPATH=/usr/x86_64-w64-mingw32/lib
140136
cd tests
141137
wine main.exe
142138
@@ -154,11 +150,9 @@ jobs:
154150

155151
steps:
156152
- uses: actions/checkout@v4
157-
- uses: microsoft/setup-msbuild@v1
158-
- run: |
159-
vcpkg --triplet=${{ matrix.arch }}-windows install cunit
160153
- name: Configure cmake
161154
run: |
155+
git submodule update --init --depth 1
162156
mkdir build
163157
cd build
164158
cmake -DENABLE_WERROR=ON -DENABLE_LIB_ONLY=ON -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_GENERATOR_PLATFORM=${{ matrix.platform }} -DVCPKG_TARGET_TRIPLET=${{ matrix.arch}}-windows ..

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "tests/munit"]
2+
path = tests/munit
3+
url = https://github.com/ngtcp2/munit

CMakeLists.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,8 @@ foreach(_build_type "Release" "MinSizeRel" "RelWithDebInfo")
6363
endforeach()
6464
endforeach()
6565

66-
find_package(CUnit 2.1)
6766
enable_testing()
68-
set(HAVE_CUNIT ${CUNIT_FOUND})
69-
if(HAVE_CUNIT)
70-
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
71-
endif()
67+
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
7268

7369
# Checks for header files.
7470
include(CheckIncludeFile)
@@ -211,8 +207,6 @@ message(STATUS "summary of build options:
211207
Library:
212208
Shared: ${ENABLE_SHARED_LIB}
213209
Static: ${ENABLE_STATIC_LIB}
214-
Test:
215-
CUnit: ${HAVE_CUNIT} (LIBS='${CUNIT_LIBRARIES}')
216210
Library only: ${ENABLE_LIB_ONLY}
217211
Examples: ${ENABLE_EXAMPLES}
218212
")

Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ EXTRA_DIST = \
3131
cmakeconfig.h.in \
3232
CMakeLists.txt \
3333
CMakeOptions.txt \
34-
cmake/FindCUnit.cmake \
3534
cmake/PickyWarningsC.cmake \
3635
cmake/PickyWarningsCXX.cmake \
3736
cmake/Version.cmake

README.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ Documentation
1313

1414
`Online documentation <https://nghttp2.org/nghttp3/>`_ is available.
1515

16+
Build from git
17+
---------------
18+
19+
.. code-block:: shell
20+
21+
$ git clone https://github.com/ngtcp2/nghttp3
22+
$ cd nghttp3
23+
$ git submodule update --init
24+
$ autoreconf -i
25+
$ ./configure
26+
$ make -j$(nproc) check
27+
1628
HTTP/3
1729
------
1830

cmake/FindCUnit.cmake

Lines changed: 0 additions & 40 deletions
This file was deleted.

configure.ac

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ AC_ARG_ENABLE([lib-only],
8787
[Build libnghttp3 only.])],
8888
[lib_only=$enableval], [lib_only=no])
8989

90-
AC_ARG_WITH([cunit],
91-
[AS_HELP_STRING([--with-cunit],
92-
[Use cunit [default=check]])],
93-
[request_cunit=$withval], [request_cunit=check])
94-
9590
# Checks for programs
9691
AC_PROG_CC
9792
AC_PROG_CXX
@@ -107,43 +102,6 @@ AX_CXX_COMPILE_STDCXX([17], [], [optional])
107102

108103
# Checks for libraries.
109104

110-
# cunit
111-
have_cunit=no
112-
if test "x${request_cunit}" != "xno"; then
113-
PKG_CHECK_MODULES([CUNIT], [cunit >= 2.1], [have_cunit=yes], [have_cunit=no])
114-
# If pkg-config does not find cunit, check it using AC_CHECK_LIB. We
115-
# do this because Debian (Ubuntu) lacks pkg-config file for cunit.
116-
if test "x${have_cunit}" = "xno"; then
117-
AC_MSG_WARN([${CUNIT_PKG_ERRORS}])
118-
AC_CHECK_LIB([cunit], [CU_initialize_registry],
119-
[have_cunit=yes], [have_cunit=no])
120-
if test "x${have_cunit}" = "xyes"; then
121-
CUNIT_LIBS="-lcunit"
122-
CUNIT_CFLAGS=""
123-
AC_SUBST([CUNIT_LIBS])
124-
AC_SUBST([CUNIT_CFLAGS])
125-
fi
126-
fi
127-
if test "x${have_cunit}" = "xyes"; then
128-
# cunit in Mac OS X requires ncurses. Note that in Mac OS X, test
129-
# program can be built without -lncurses, but it emits runtime
130-
# error.
131-
case "${build}" in
132-
*-apple-darwin*)
133-
CUNIT_LIBS="$CUNIT_LIBS -lncurses"
134-
AC_SUBST([CUNIT_LIBS])
135-
;;
136-
esac
137-
fi
138-
fi
139-
140-
if test "x${request_cunit}" = "xyes" &&
141-
test "x${have_cunit}" != "xyes"; then
142-
AC_MSG_ERROR([cunit was requested (--with-cunit) but not found])
143-
fi
144-
145-
AM_CONDITIONAL([HAVE_CUNIT], [ test "x${have_cunit}" = "xyes" ])
146-
147105
enable_examples=yes
148106
if test "x${lib_only}" = "xyes"; then
149107
enable_examples=no
@@ -344,8 +302,6 @@ AC_MSG_NOTICE([summary of build options:
344302
Library:
345303
Shared: ${enable_shared}
346304
Static: ${enable_static}
347-
Test:
348-
CUnit: ${have_cunit} (CFLAGS='${CUNIT_CFLAGS}' LIBS='${CUNIT_LIBS}')
349305
Debug:
350306
Debug: ${debug} (CFLAGS='${DEBUGCFLAGS}')
351307
Library only: ${lib_only}

examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if(ENABLE_EXAMPLES)
3232
link_libraries(
3333
nghttp3
3434
)
35-
elseif(HAVE_CUNIT OR ENABLE_STATIC_LIB)
35+
else()
3636
link_libraries(
3737
nghttp3_static
3838
)

lib/CMakeLists.txt

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,18 @@ if(ENABLE_SHARED_LIB)
7878
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
7979
endif()
8080

81-
if(HAVE_CUNIT OR ENABLE_STATIC_LIB)
82-
# Static library (for unittests because of symbol visibility)
83-
add_library(nghttp3_static STATIC ${nghttp3_SOURCES})
84-
set_target_properties(nghttp3_static PROPERTIES
85-
COMPILE_FLAGS "${WARNCFLAGS}"
86-
VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION}
87-
ARCHIVE_OUTPUT_NAME nghttp3${STATIC_LIB_SUFFIX}
81+
# Static library (for unittests because of symbol visibility)
82+
add_library(nghttp3_static STATIC ${nghttp3_SOURCES})
83+
set_target_properties(nghttp3_static PROPERTIES
84+
COMPILE_FLAGS "${WARNCFLAGS}"
85+
VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION}
86+
ARCHIVE_OUTPUT_NAME nghttp3${STATIC_LIB_SUFFIX}
8887
)
89-
target_compile_definitions(nghttp3_static PUBLIC "-DNGHTTP3_STATICLIB")
90-
if(ENABLE_STATIC_LIB)
91-
install(TARGETS nghttp3_static
92-
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
93-
endif()
88+
target_compile_definitions(nghttp3_static PUBLIC "-DNGHTTP3_STATICLIB")
89+
if(ENABLE_STATIC_LIB)
90+
install(TARGETS nghttp3_static
91+
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
9492
endif()
9593

96-
9794
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnghttp3.pc"
9895
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")

tests/CMakeLists.txt

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,30 @@
2323
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2424
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2525

26-
if(HAVE_CUNIT)
27-
include_directories(
28-
"${CMAKE_SOURCE_DIR}/lib"
29-
"${CMAKE_SOURCE_DIR}/lib/includes"
30-
"${CMAKE_BINARY_DIR}/lib/includes"
31-
${CUNIT_INCLUDE_DIRS}
32-
)
26+
include_directories(
27+
"${CMAKE_SOURCE_DIR}/lib"
28+
"${CMAKE_SOURCE_DIR}/lib/includes"
29+
"${CMAKE_BINARY_DIR}/lib/includes"
30+
)
3331

34-
set(main_SOURCES
35-
main.c
36-
nghttp3_qpack_test.c
37-
nghttp3_conn_test.c
38-
nghttp3_tnode_test.c
39-
nghttp3_http_test.c
40-
nghttp3_conv_test.c
41-
nghttp3_test_helper.c
42-
)
32+
set(main_SOURCES
33+
main.c
34+
nghttp3_qpack_test.c
35+
nghttp3_conn_test.c
36+
nghttp3_tnode_test.c
37+
nghttp3_http_test.c
38+
nghttp3_conv_test.c
39+
nghttp3_test_helper.c
40+
munit/munit.c
41+
)
4342

44-
add_executable(main EXCLUDE_FROM_ALL
45-
${main_SOURCES}
46-
)
47-
target_include_directories(main PRIVATE ${CUNIT_INCLUDE_DIRS})
48-
# FIXME enable and fix warnings
49-
#set_target_properties(main PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}")
50-
target_link_libraries(main
51-
nghttp3_static
52-
${CUNIT_LIBRARIES}
53-
)
54-
add_test(main main)
55-
add_dependencies(check main)
56-
endif()
43+
add_executable(main EXCLUDE_FROM_ALL
44+
${main_SOURCES}
45+
)
46+
# FIXME enable and fix warnings
47+
#set_target_properties(main PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}")
48+
target_link_libraries(main
49+
nghttp3_static
50+
)
51+
add_test(main main)
52+
add_dependencies(check main)

0 commit comments

Comments
 (0)