From 83a82dd9296400d811b78c06e9ca429e24dd1e5c Mon Sep 17 00:00:00 2001 From: evpobr Date: Fri, 6 Nov 2020 11:38:42 +0500 Subject: Add tests to CMake project Related to https://github.com/xiph/vorbis/issues/73. Signed-off-by: Ralph Giles --- .gitlab-ci.yml | 2 ++ CMakeLists.txt | 5 +++++ test/CMakeLists.txt | 3 +++ test/Makefile.am | 2 ++ 4 files changed, 12 insertions(+) create mode 100644 test/CMakeLists.txt diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e438d972..8b117e1d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -25,3 +25,5 @@ cmake: - mkdir build - cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release - cmake --build build + - cd build + - ctest diff --git a/CMakeLists.txt b/CMakeLists.txt index c42f6a5b..197dfc23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ project(vorbis) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") # Required modules +include(CTest) include(GNUInstallDirs) include(CheckIncludeFiles) include(CheckLibraryExists) @@ -71,6 +72,10 @@ endif() add_subdirectory(lib) +if(BUILD_TESTING) + add_subdirectory(test) +endif() + configure_pkg_config_file(vorbis.pc.in) configure_pkg_config_file(vorbisenc.pc.in) configure_pkg_config_file(vorbisfile.pc.in) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 00000000..8cc5abe8 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(vorbis_test util.c util.h write_read.c write_read.h test.c) +target_link_libraries(vorbis_test PRIVATE Vorbis::vorbisenc) +add_test(NAME vorbis_test COMMAND vorbis_test) diff --git a/test/Makefile.am b/test/Makefile.am index b68ebdb1..a9207794 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -12,6 +12,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/include @OGG_CFLAGS@ test_SOURCES = util.c util.h write_read.c write_read.h test.c test_LDADD = ../lib/libvorbisenc.la ../lib/libvorbis.la @OGG_LIBS@ @VORBIS_LIBS@ +EXTRA_DIST = CMakeLists.txt + debug: $(MAKE) check CFLAGS="@DEBUG@" -- cgit v1.2.1