Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stefankiesz committed Mar 25, 2024
1 parent aa8ea9e commit 58da8fe
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 14 deletions.
71 changes: 58 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- master
jobs:
clang-format-check:
runs-on: macos-11
runs-on: macos-latest
steps:
- name: Clone repository
uses: actions/checkout@v3
Expand All @@ -24,13 +24,13 @@ jobs:
bash scripts/check-clang.sh
mac-os-build-gcc:
runs-on: macos-12
runs-on: macos-latest
permissions:
id-token: write
contents: read
env:
CC: /usr/local/bin/gcc-13
CXX: /usr/local/bin/g++-13
CC: gcc-13
CXX: g++-13
AWS_KVS_LOG_LEVEL: 2
steps:
- name: Clone repository
Expand All @@ -54,7 +54,7 @@ jobs:
./tst/producer_test
mac-os-build-clang:
runs-on: macos-11
runs-on: macos-latest
env:
AWS_KVS_LOG_LEVEL: 2
permissions:
Expand Down Expand Up @@ -109,14 +109,14 @@ jobs:
cd build
./tst/producer_test
mac-os-build-gcc-system-deps:
runs-on: macos-11
mac-os-build-gcc-system-openssl:
runs-on: macos-latest
permissions:
id-token: write
contents: read
env:
CC: /usr/local/bin/gcc-13
CXX: /usr/local/bin/g++-13
CC: gcc-13
CXX: g++-13
AWS_KVS_LOG_LEVEL: 2
LDFLAGS: -L/usr/local/opt/openssl@3/lib
CPPFLAGS: -I/usr/local/opt/openssl@3/include
Expand All @@ -126,10 +126,9 @@ jobs:
uses: actions/checkout@v3
- name: Build repository
run: |
brew install googletest
brew info openssl
mkdir build && cd build
cmake .. -DBUILD_TEST=TRUE -DBUILD_DEPENDENCIES=FALSE
cmake .. -DBUILD_TEST=TRUE -DBUILD_CRYPTO=FALSE
make
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
Expand All @@ -143,7 +142,7 @@ jobs:
cd build
./tst/producer_test
mac-os-build-clang-system-deps:
mac-os-build-clang-system-openssl:
runs-on: macos-latest
env:
AWS_KVS_LOG_LEVEL: 2
Expand All @@ -161,7 +160,7 @@ jobs:
brew install googletest
brew info openssl
mkdir build && cd build
cmake .. -DBUILD_TEST=TRUE -DCOMPILER_WARNINGS=TRUE -DBUILD_DEPENDENCIES=FALSE
cmake .. -DBUILD_TEST=TRUE -DCOMPILER_WARNINGS=TRUE -DBUILD_CRYPTO=FALSE
make
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
Expand All @@ -175,6 +174,52 @@ jobs:
cd build
./tst/producer_test
# Producer is not compatible with latest CURL, so build only, don't run tests.
mac-os-build-gcc-system-deps:
runs-on: macos-latest
permissions:
id-token: write
contents: read
env:
CC: gcc-13
CXX: g++-13
AWS_KVS_LOG_LEVEL: 2
LDFLAGS: -L/usr/local/opt/openssl@3/lib
CPPFLAGS: -I/usr/local/opt/openssl@3/include
OPENSSL_ROOT_DIR: /usr/local/opt/openssl@3/
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Build repository
run: |
brew install googletest
brew info openssl
mkdir build && cd build
cmake .. -DBUILD_TEST=TRUE -DBUILD_DEPENDENCIES=FALSE
make
# Producer is not compatible with latest CURL, so build only, don't run tests.
mac-os-build-clang-system-deps:
runs-on: macos-latest
env:
AWS_KVS_LOG_LEVEL: 2
LDFLAGS: -L/usr/local/opt/openssl@3/lib
CPPFLAGS: -I/usr/local/opt/openssl@3/include
OPENSSL_ROOT_DIR: /usr/local/opt/openssl@3/
permissions:
id-token: write
contents: read
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Build repository
run: |
brew install googletest
brew info openssl
mkdir build && cd build
cmake .. -DBUILD_TEST=TRUE -DCOMPILER_WARNINGS=TRUE -DBUILD_DEPENDENCIES=FALSE
make
ubuntu-os-gcc-build-lws-mbedtls:
runs-on: ubuntu-20.04
env:
Expand Down
27 changes: 26 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ if(BUILD_DEPENDENCIES)
endif()

# If building KVS Producer C Common LWS, build libwebsockets.
# NOTE: This version of LWS does not build on Mac
# NOTE: This version of LWS does not build succesfully on Mac due to a LWS bug.
if (BUILD_COMMON_LWS AND BUILD_LWS)
set(BUILD_ARGS -DBUILD_STATIC=${BUILD_STATIC}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
Expand All @@ -144,6 +144,31 @@ if(BUILD_DEPENDENCIES)
endif()

message(STATUS "Finished building dependencies.")

# GTest MUST be built if using GCC compiler because Mac system-built GTest uses Clang.
# Clang-built GTest is not compatible with GCC-built libraries. This check expects the
# CC env var to be set in the following format: "export CC=<optional path>/gcc-<version number>".
# We currently only test with BUILD_DEPENDENCIES=OFF on Mac CI.
elseif(BUILD_TEST AND APPLE AND DEFINED ENV{CC})
# Set directory where to build the dependencies.
if (NOT OPEN_SRC_INSTALL_PREFIX)
set(OPEN_SRC_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/open-source)
set(ENV{PKG_CONFIG_PATH}
"$ENV{PKG_CONFIG_PATH}:${OPEN_SRC_INSTALL_PREFIX}/lib/pkgconfig")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${OPEN_SRC_INSTALL_PREFIX})
endif()

# Create the dependency directory if it doesn't exist.
if(NOT EXISTS ${OPEN_SRC_INSTALL_PREFIX})
file(MAKE_DIRECTORY ${OPEN_SRC_INSTALL_PREFIX})
endif()

# Check if CC env var starts with "gcc".
string(STRIP $ENV{CC} CC_NAME)
message(${CC_NAME})
if(${CC_NAME} MATCHES ".*gcc-.*")
build_dependency(gtest)
endif()
endif()

find_package(PkgConfig REQUIRED)
Expand Down
1 change: 1 addition & 0 deletions tst/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set(KINESIS_VIDEO_PRODUCER_C_SRC "${CMAKE_CURRENT_SOURCE_DIR}/..")

if (OPEN_SRC_INSTALL_PREFIX)
find_package(GTest REQUIRED PATHS ${OPEN_SRC_INSTALL_PREFIX})
set(GTEST_INCLUDE_DIRS ${OPEN_SRC_INSTALL_PREFIX}/include)
else()
find_package(GTest REQUIRED)
endif()
Expand Down

0 comments on commit 58da8fe

Please sign in to comment.