diff options
-rw-r--r-- | .github/workflows/ci.yml | 20 | ||||
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 24 | ||||
-rw-r--r-- | tests/example.t.cpp | 16 |
5 files changed, 64 insertions, 3 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b66f6c56..18c381bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: CI -on: [push] +on: [push, pull_request] jobs: build: @@ -14,6 +14,7 @@ jobs: name: "Win32-Release", os: windows-latest, cmake_opts: "-A Win32 \ + -DALSOFT_TESTS=ON \ -DALSOFT_BUILD_ROUTER=ON \ -DALSOFT_REQUIRE_WINMM=ON \ -DALSOFT_REQUIRE_DSOUND=ON \ @@ -24,6 +25,7 @@ jobs: name: "Win32-Debug", os: windows-latest, cmake_opts: "-A Win32 \ + -DALSOFT_TESTS=ON \ -DALSOFT_BUILD_ROUTER=ON \ -DALSOFT_REQUIRE_WINMM=ON \ -DALSOFT_REQUIRE_DSOUND=ON \ @@ -34,6 +36,7 @@ jobs: name: "Win64-Release", os: windows-latest, cmake_opts: "-A x64 \ + -DALSOFT_TESTS=ON \ -DALSOFT_BUILD_ROUTER=ON \ -DALSOFT_REQUIRE_WINMM=ON \ -DALSOFT_REQUIRE_DSOUND=ON \ @@ -44,6 +47,7 @@ jobs: name: "Win64-Debug", os: windows-latest, cmake_opts: "-A x64 \ + -DALSOFT_TESTS=ON \ -DALSOFT_BUILD_ROUTER=ON \ -DALSOFT_REQUIRE_WINMM=ON \ -DALSOFT_REQUIRE_DSOUND=ON \ @@ -54,6 +58,7 @@ jobs: name: "Win64-UWP", os: windows-latest, cmake_opts: "-A x64 \ + -DALSOFT_TESTS=OFF \ -DCMAKE_SYSTEM_NAME=WindowsStore \ \"-DCMAKE_SYSTEM_VERSION=10.0\" \ -DALSOFT_BUILD_ROUTER=ON \ @@ -63,7 +68,8 @@ jobs: - { name: "macOS-Release", os: macos-latest, - cmake_opts: "-DALSOFT_REQUIRE_COREAUDIO=ON", + cmake_opts: "-DALSOFT_REQUIRE_COREAUDIO=ON \ + -DALSOFT_TESTS=ON", build_type: "Release" } - { @@ -74,6 +80,7 @@ jobs: -DALSOFT_REQUIRE_COREAUDIO=ON \ -DALSOFT_UTILS=OFF \ -DALSOFT_EXAMPLES=OFF \ + -DALSOFT_TESTS=OFF \ -DALSOFT_INSTALL=OFF \ \"-DCMAKE_OSX_ARCHITECTURES=arm64\"", build_type: "Release" @@ -87,7 +94,8 @@ jobs: -DALSOFT_REQUIRE_PORTAUDIO=ON \ -DALSOFT_REQUIRE_PULSEAUDIO=ON \ -DALSOFT_REQUIRE_JACK=ON \ - -DALSOFT_REQUIRE_PIPEWIRE=ON", + -DALSOFT_REQUIRE_PIPEWIRE=ON \ + -DALSOFT_TESTS=ON", deps_cmdline: "sudo apt update && sudo apt-get install -qq \ libpulse-dev \ portaudio19-dev \ @@ -119,6 +127,12 @@ jobs: run: | cmake --build build --config ${{matrix.config.build_type}} + - name: Test + shell: bash + run: | + cd build + ctest + - name: Create Archive if: ${{ matrix.config.os == 'windows-latest' }} shell: bash @@ -1,6 +1,7 @@ build*/ winbuild win64build +.vs/ ## kdevelop *.kdev4 diff --git a/CMakeLists.txt b/CMakeLists.txt index c73dee55..34fd3312 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ # CMake build file list for OpenAL cmake_minimum_required(VERSION 3.0.2) +enable_testing() if(APPLE) # The workaround for try_compile failing with code signing @@ -111,6 +112,7 @@ option(ALSOFT_UTILS "Build utility programs" ON) option(ALSOFT_NO_CONFIG_UTIL "Disable building the alsoft-config utility" OFF) option(ALSOFT_EXAMPLES "Build example programs" ON) +option(ALSOFT_TESTS "Build test programs" OFF) option(ALSOFT_INSTALL "Install main library" ON) option(ALSOFT_INSTALL_CONFIG "Install alsoft.conf sample configuration file" ON) @@ -1820,6 +1822,10 @@ if(ALSOFT_EXAMPLES) message(STATUS "") endif() +if (ALSOFT_TESTS) +add_subdirectory(tests) +endif() + if(EXTRA_INSTALLS) install(TARGETS ${EXTRA_INSTALLS} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..492587e8 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,24 @@ +add_executable(OpenAL_Tests)
+
+include(FetchContent)
+FetchContent_Declare(
+ googletest
+ GIT_REPOSITORY https://github.com/google/googletest.git
+ GIT_TAG main
+)
+# For Windows: Prevent overriding the parent project's compiler/linker settings
+set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
+FetchContent_MakeAvailable(googletest)
+
+target_link_libraries(OpenAL_Tests PRIVATE
+ OpenAL
+ GTest::gtest_main
+)
+
+target_sources(OpenAL_Tests PRIVATE
+example.t.cpp
+)
+
+# This needs to come last
+include(GoogleTest)
+gtest_discover_tests(OpenAL_Tests)
diff --git a/tests/example.t.cpp b/tests/example.t.cpp new file mode 100644 index 00000000..30341e8b --- /dev/null +++ b/tests/example.t.cpp @@ -0,0 +1,16 @@ +#include <gtest/gtest.h>
+#include <AL/al.h>
+
+class ExampleTest : public ::testing::Test {
+};
+
+
+TEST_F(ExampleTest, Basic)
+{
+ // just making sure we compile
+ ALuint source, buffer;
+ ALfloat offset;
+ ALenum state;
+}
+
+
|