Skip to content

Commit

Permalink
Migrate to munit form cunit
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsuhiro-t committed Feb 2, 2024
1 parent fd63249 commit dd10d94
Show file tree
Hide file tree
Showing 22 changed files with 860 additions and 939 deletions.
24 changes: 9 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ jobs:
autotools-dev \
libtool \
pkg-config \
libcunit1-dev \
cmake \
cmake-data
- name: MacOS setup
if: runner.os == 'macOS'
run: |
brew install cunit autoconf automake pkg-config libtool
brew install autoconf automake pkg-config libtool
- name: Setup clang (Linux)
if: runner.os == 'Linux' && matrix.compiler == 'clang'
run: |
Expand All @@ -59,6 +58,9 @@ jobs:
run: |
echo 'CC=gcc' >> $GITHUB_ENV
echo 'CXX=g++' >> $GITHUB_ENV
- name: git submodule
run: |
git submodule update --init --depth 1
- name: Configure autotools
if: matrix.buildtool == 'autotools'
run: |
Expand Down Expand Up @@ -117,26 +119,20 @@ jobs:
libtool \
pkg-config \
wine
- name: Build CUnit
run: |
curl -LO https://jaist.dl.sourceforge.net/project/cunit/CUnit/2.1-3/CUnit-2.1-3.tar.bz2
tar xf CUnit-2.1-3.tar.bz2
cd CUnit-2.1-3
./bootstrap
./configure --disable-shared --host="$HOST" --prefix="$PWD/build"
make -j$(nproc) install
- name: Configure autotools
run: |
git submodule update --init --depth 1
autoreconf -i && \
./configure --enable-werror --enable-lib-only --with-cunit \
--host="$HOST" PKG_CONFIG_PATH="$PWD/CUnit-2.1-3/build/lib/pkgconfig"
./configure --enable-werror --enable-lib-only --host="$HOST" \
LIBS="-pthread"
- name: Build nghttp3
run: |
make -j$(nproc)
make -j$(nproc) check TESTS=""
- name: Run tests
if: matrix.host == 'x86_64-w64-mingw32'
run: |
export WINEPATH=/usr/x86_64-w64-mingw32/lib
cd tests
wine main.exe
Expand All @@ -154,11 +150,9 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: microsoft/setup-msbuild@v1
- run: |
vcpkg --triplet=${{ matrix.arch }}-windows install cunit
- name: Configure cmake
run: |
git submodule update --init --depth 1
mkdir build
cd build
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 ..
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tests/munit"]
path = tests/munit
url = https://github.com/ngtcp2/munit
8 changes: 1 addition & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,8 @@ foreach(_build_type "Release" "MinSizeRel" "RelWithDebInfo")
endforeach()
endforeach()

find_package(CUnit 2.1)
enable_testing()
set(HAVE_CUNIT ${CUNIT_FOUND})
if(HAVE_CUNIT)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
endif()
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})

# Checks for header files.
include(CheckIncludeFile)
Expand Down Expand Up @@ -211,8 +207,6 @@ message(STATUS "summary of build options:
Library:
Shared: ${ENABLE_SHARED_LIB}
Static: ${ENABLE_STATIC_LIB}
Test:
CUnit: ${HAVE_CUNIT} (LIBS='${CUNIT_LIBRARIES}')
Library only: ${ENABLE_LIB_ONLY}
Examples: ${ENABLE_EXAMPLES}
")
1 change: 0 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ EXTRA_DIST = \
cmakeconfig.h.in \
CMakeLists.txt \
CMakeOptions.txt \
cmake/FindCUnit.cmake \
cmake/PickyWarningsC.cmake \
cmake/PickyWarningsCXX.cmake \
cmake/Version.cmake
Expand Down
12 changes: 12 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ Documentation

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

Build from git
---------------

.. code-block:: shell
$ git clone https://github.com/ngtcp2/nghttp3
$ cd nghttp3
$ git submodule update --init
$ autoreconf -i
$ ./configure
$ make -j$(nproc) check
HTTP/3
------

Expand Down
40 changes: 0 additions & 40 deletions cmake/FindCUnit.cmake

This file was deleted.

44 changes: 0 additions & 44 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ AC_ARG_ENABLE([lib-only],
[Build libnghttp3 only.])],
[lib_only=$enableval], [lib_only=no])

AC_ARG_WITH([cunit],
[AS_HELP_STRING([--with-cunit],
[Use cunit [default=check]])],
[request_cunit=$withval], [request_cunit=check])

# Checks for programs
AC_PROG_CC
AC_PROG_CXX
Expand All @@ -107,43 +102,6 @@ AX_CXX_COMPILE_STDCXX([17], [], [optional])

# Checks for libraries.

# cunit
have_cunit=no
if test "x${request_cunit}" != "xno"; then
PKG_CHECK_MODULES([CUNIT], [cunit >= 2.1], [have_cunit=yes], [have_cunit=no])
# If pkg-config does not find cunit, check it using AC_CHECK_LIB. We
# do this because Debian (Ubuntu) lacks pkg-config file for cunit.
if test "x${have_cunit}" = "xno"; then
AC_MSG_WARN([${CUNIT_PKG_ERRORS}])
AC_CHECK_LIB([cunit], [CU_initialize_registry],
[have_cunit=yes], [have_cunit=no])
if test "x${have_cunit}" = "xyes"; then
CUNIT_LIBS="-lcunit"
CUNIT_CFLAGS=""
AC_SUBST([CUNIT_LIBS])
AC_SUBST([CUNIT_CFLAGS])
fi
fi
if test "x${have_cunit}" = "xyes"; then
# cunit in Mac OS X requires ncurses. Note that in Mac OS X, test
# program can be built without -lncurses, but it emits runtime
# error.
case "${build}" in
*-apple-darwin*)
CUNIT_LIBS="$CUNIT_LIBS -lncurses"
AC_SUBST([CUNIT_LIBS])
;;
esac
fi
fi

if test "x${request_cunit}" = "xyes" &&
test "x${have_cunit}" != "xyes"; then
AC_MSG_ERROR([cunit was requested (--with-cunit) but not found])
fi

AM_CONDITIONAL([HAVE_CUNIT], [ test "x${have_cunit}" = "xyes" ])

enable_examples=yes
if test "x${lib_only}" = "xyes"; then
enable_examples=no
Expand Down Expand Up @@ -344,8 +302,6 @@ AC_MSG_NOTICE([summary of build options:
Library:
Shared: ${enable_shared}
Static: ${enable_static}
Test:
CUnit: ${have_cunit} (CFLAGS='${CUNIT_CFLAGS}' LIBS='${CUNIT_LIBS}')
Debug:
Debug: ${debug} (CFLAGS='${DEBUGCFLAGS}')
Library only: ${lib_only}
Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if(ENABLE_EXAMPLES)
link_libraries(
nghttp3
)
elseif(HAVE_CUNIT OR ENABLE_STATIC_LIB)
else()
link_libraries(
nghttp3_static
)
Expand Down
23 changes: 10 additions & 13 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,18 @@ if(ENABLE_SHARED_LIB)
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()

if(HAVE_CUNIT OR ENABLE_STATIC_LIB)
# Static library (for unittests because of symbol visibility)
add_library(nghttp3_static STATIC ${nghttp3_SOURCES})
set_target_properties(nghttp3_static PROPERTIES
COMPILE_FLAGS "${WARNCFLAGS}"
VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION}
ARCHIVE_OUTPUT_NAME nghttp3${STATIC_LIB_SUFFIX}
# Static library (for unittests because of symbol visibility)
add_library(nghttp3_static STATIC ${nghttp3_SOURCES})
set_target_properties(nghttp3_static PROPERTIES
COMPILE_FLAGS "${WARNCFLAGS}"
VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION}
ARCHIVE_OUTPUT_NAME nghttp3${STATIC_LIB_SUFFIX}
)
target_compile_definitions(nghttp3_static PUBLIC "-DNGHTTP3_STATICLIB")
if(ENABLE_STATIC_LIB)
install(TARGETS nghttp3_static
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif()
target_compile_definitions(nghttp3_static PUBLIC "-DNGHTTP3_STATICLIB")
if(ENABLE_STATIC_LIB)
install(TARGETS nghttp3_static
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif()


install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnghttp3.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
54 changes: 25 additions & 29 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,30 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

if(HAVE_CUNIT)
include_directories(
"${CMAKE_SOURCE_DIR}/lib"
"${CMAKE_SOURCE_DIR}/lib/includes"
"${CMAKE_BINARY_DIR}/lib/includes"
${CUNIT_INCLUDE_DIRS}
)
include_directories(
"${CMAKE_SOURCE_DIR}/lib"
"${CMAKE_SOURCE_DIR}/lib/includes"
"${CMAKE_BINARY_DIR}/lib/includes"
)

set(main_SOURCES
main.c
nghttp3_qpack_test.c
nghttp3_conn_test.c
nghttp3_tnode_test.c
nghttp3_http_test.c
nghttp3_conv_test.c
nghttp3_test_helper.c
)
set(main_SOURCES
main.c
nghttp3_qpack_test.c
nghttp3_conn_test.c
nghttp3_tnode_test.c
nghttp3_http_test.c
nghttp3_conv_test.c
nghttp3_test_helper.c
munit/munit.c
)

add_executable(main EXCLUDE_FROM_ALL
${main_SOURCES}
)
target_include_directories(main PRIVATE ${CUNIT_INCLUDE_DIRS})
# FIXME enable and fix warnings
#set_target_properties(main PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}")
target_link_libraries(main
nghttp3_static
${CUNIT_LIBRARIES}
)
add_test(main main)
add_dependencies(check main)
endif()
add_executable(main EXCLUDE_FROM_ALL
${main_SOURCES}
)
# FIXME enable and fix warnings
#set_target_properties(main PROPERTIES COMPILE_FLAGS "${WARNCFLAGS}")
target_link_libraries(main
nghttp3_static
)
add_test(main main)
add_dependencies(check main)
15 changes: 6 additions & 9 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
EXTRA_DIST = CMakeLists.txt

if HAVE_CUNIT
EXTRA_DIST = CMakeLists.txt munit/munit.c munit/munit.h munit/COPYING

check_PROGRAMS = main

Expand All @@ -35,31 +33,30 @@ OBJECTS = \
nghttp3_tnode_test.c \
nghttp3_http_test.c \
nghttp3_conv_test.c \
nghttp3_test_helper.c
nghttp3_test_helper.c \
munit/munit.c
HFILES = \
nghttp3_qpack_test.h \
nghttp3_conn_test.h \
nghttp3_tnode_test.h \
nghttp3_http_test.h \
nghttp3_conv_test.h \
nghttp3_test_helper.h
nghttp3_test_helper.h \
munit/munit.h

main_SOURCES = $(HFILES) $(OBJECTS)

# With static lib disabled and symbol hiding enabled, we have to link object
# files directly because the tests use symbols not included in public API.
main_LDADD = ${top_builddir}/lib/.libs/*.o
main_LDADD += @CUNIT_LIBS@
main_LDFLAGS = -static

AM_CFLAGS = $(WARNCFLAGS) \
-I${top_srcdir}/lib \
-I${top_srcdir}/lib/includes \
-I${top_builddir}/lib/includes \
-DBUILDING_NGHTTP3 \
@CUNIT_CFLAGS@ @DEFS@
@DEFS@
AM_LDFLAGS = -no-install

TESTS = main

endif # HAVE_CUNIT
Loading

0 comments on commit dd10d94

Please sign in to comment.