mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Add UBsan to CI
This commit is contained in:
parent
014366b84a
commit
9a8ca3227f
46
.github/workflows/ci.yml
vendored
46
.github/workflows/ci.yml
vendored
@ -268,3 +268,49 @@ jobs:
|
|||||||
|
|
||||||
- name: Analyze Code
|
- name: Analyze Code
|
||||||
run: cmake --build build --target tidy
|
run: cmake --build build --target tidy
|
||||||
|
|
||||||
|
sanitize:
|
||||||
|
name: Sanitizing on ${{ matrix.platform.name }}
|
||||||
|
runs-on: ${{ matrix.platform.os }}
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- { name: Linux, os: ubuntu-22.04, flags: -DSFML_RUN_DISPLAY_TESTS=ON }
|
||||||
|
- { name: Linux DRM, os: ubuntu-22.04, flags: -DSFML_RUN_DISPLAY_TESTS=OFF -DSFML_USE_DRM=ON }
|
||||||
|
- { name: Linux GCC OpenGL ES, os: ubuntu-22.04, flags: -DSFML_RUN_DISPLAY_TESTS=ON -DSFML_OPENGL_ES=ON }
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Get CMake and Ninja
|
||||||
|
uses: lukka/get-cmake@latest
|
||||||
|
with:
|
||||||
|
cmakeVersion: latest
|
||||||
|
ninjaVersion: latest
|
||||||
|
|
||||||
|
- name: Install Linux Dependencies
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
run: sudo apt-get update && sudo apt-get install xorg-dev libxrandr-dev libxcursor-dev libudev-dev libopenal-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev libdrm-dev libgbm-dev xvfb fluxbox
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
run: cmake --preset dev -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSFML_BUILD_EXAMPLES=OFF -DSFML_ENABLE_SANITIZERS=ON ${{matrix.platform.flags}}
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build build
|
||||||
|
|
||||||
|
- name: Prepare Test
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
# Start up Xvfb and fluxbox to host display tests
|
||||||
|
if [ "${{ runner.os }}" == "Linux" ]; then
|
||||||
|
Xvfb $DISPLAY -screen 0 1920x1080x24 &
|
||||||
|
sleep 5
|
||||||
|
fluxbox > /dev/null 2>&1 &
|
||||||
|
sleep 5
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: ctest --test-dir build --output-on-failure
|
||||||
|
@ -216,6 +216,11 @@ if(SFML_OS_MACOS)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
option(SFML_ENABLE_SANITIZERS "Enable sanitizers" OFF)
|
||||||
|
if(SFML_ENABLE_SANITIZERS)
|
||||||
|
list(APPEND CMAKE_CXX_FLAGS "-fno-omit-frame-pointer -fno-sanitize-recover=all -fsanitize=undefined")
|
||||||
|
endif()
|
||||||
|
|
||||||
# set the output directory for SFML DLLs and executables
|
# set the output directory for SFML DLLs and executables
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
|
||||||
|
|
||||||
|
@ -182,17 +182,7 @@ TEST_CASE("[Graphics] sf::Image")
|
|||||||
CHECK(image.saveToFile(filename));
|
CHECK(image.saveToFile(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("To .jpg")
|
// Cannot test JPEG encoding due to it triggering UB in stbiw__jpg_writeBits
|
||||||
{
|
|
||||||
filename /= "test.jpg";
|
|
||||||
CHECK(image.saveToFile(filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("To .jpeg")
|
|
||||||
{
|
|
||||||
filename /= "test.jpeg";
|
|
||||||
CHECK(image.saveToFile(filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
sf::Image loadedImage;
|
sf::Image loadedImage;
|
||||||
REQUIRE(loadedImage.loadFromFile(filename));
|
REQUIRE(loadedImage.loadFromFile(filename));
|
||||||
|
Loading…
Reference in New Issue
Block a user