Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
ebiggers committed Feb 19, 2024
1 parent b0ff384 commit 88b0830
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 278 deletions.
236 changes: 0 additions & 236 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,107 +2,6 @@ name: CI
on: [pull_request]

jobs:
x86_64-build-and-test:
name: Build and test (x86_64, ${{ matrix.os }}, ${{ matrix.compiler }})
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-20.04]
compiler: [gcc, clang]
runs-on: ${{ matrix.os }}
env:
CC: ${{ matrix.compiler }}
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang llvm libz-dev valgrind
- run: scripts/run_tests.sh
- name: Direct compilation without official build system
run: $CC -O2 -Wall -Werror lib/*{,/*}.c programs/{gzip,prog_util,tgetopt}.c -o libdeflate-gzip

other-arch-build-and-test:
name: Build and test (${{ matrix.arch }}, ${{ matrix.distro }}, ${{ matrix.compiler }})
strategy:
matrix:
include:
- { arch: armv6, distro: bullseye, compiler: gcc }
- { arch: armv6, distro: bullseye, compiler: clang }
- { arch: armv7, distro: bullseye, compiler: gcc }
- { arch: armv7, distro: bullseye, compiler: clang }
- { arch: aarch64, distro: bullseye, compiler: gcc }
- { arch: aarch64, distro: bullseye, compiler: clang }
- { arch: s390x, distro: bullseye, compiler: gcc }
- { arch: s390x, distro: bullseye, compiler: clang }
- { arch: ppc64le, distro: bullseye, compiler: gcc }
- { arch: ppc64le, distro: bullseye, compiler: clang }
- { arch: riscv64, distro: ubuntu_latest, compiler: gcc }
- { arch: riscv64, distro: ubuntu_latest, compiler: clang }
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: uraimo/run-on-arch-action@v2.5.0
with:
arch: ${{ matrix.arch }}
distro: ${{ matrix.distro }}
githubToken: ${{ github.token }}
install: |
apt-get update
apt-get install -y build-essential cmake clang llvm libz-dev
run: |
tests=(regular)
if [ ${{matrix.compiler}} = clang ]; then
tests+=(ubsan)
fi
CC=${{matrix.compiler}} scripts/run_tests.sh "${tests[@]}"
macos-build-and-test:
name: Build and test (macOS)
runs-on: macos-latest
env:
CFLAGS: -Werror -DLIBDEFLATE_ENABLE_ASSERTIONS
steps:
- uses: actions/checkout@v4
- run: cmake -B build -DLIBDEFLATE_BUILD_TESTS=1
- run: cmake --build build --verbose
- run: DESTDIR=build/install cmake --install build --verbose
- run: ctest --test-dir build
- name: Direct compilation without official build system
run: cc -O2 -Wall -Werror lib/*{,/*}.c programs/{gzip,prog_util,tgetopt}.c -o libdeflate-gzip

windows-msys2-build-and-test:
name: Build and test (Windows, MSYS2, ${{matrix.sys}})
runs-on: windows-latest
strategy:
matrix:
include:
- { sys: mingw64, env: x86_64 }
- { sys: mingw32, env: i686 }
defaults:
run:
shell: msys2 {0}
env:
CFLAGS: -Werror -DLIBDEFLATE_ENABLE_ASSERTIONS
steps:
- uses: actions/checkout@v4
- uses: msys2/setup-msys2@v2
with:
msystem: ${{matrix.sys}}
update: true
install: >
make
mingw-w64-${{matrix.env}}-cc
mingw-w64-${{matrix.env}}-cmake
mingw-w64-${{matrix.env}}-ninja
mingw-w64-${{matrix.env}}-zlib
# Note: as per the CMake documentation, DESTDIR is unsupported on Windows.
- run: cmake -B build -G Ninja -DLIBDEFLATE_BUILD_TESTS=1 -DCMAKE_INSTALL_PREFIX=build\install
- run: cmake --build build --verbose
- run: cmake --install build --verbose
- run: ctest --test-dir build
- name: Direct compilation without official build system
run: cc -O2 -Wall -Werror -municode lib/*{,/*}.c programs/{gzip,prog_util,tgetopt}.c -o libdeflate-gzip.exe

windows-visualstudio-build-and-test:
name: Build and test (Windows, ${{matrix.gen}}, ${{matrix.toolset}}, ${{matrix.vs}})
strategy:
Expand Down Expand Up @@ -153,138 +52,3 @@ jobs:
-DCMAKE_INSTALL_PREFIX=build\install
- run: cmake --build build --verbose --config Release
- run: cmake --install build --verbose --config Release

run-clang-static-analyzer:
name: Run clang static analyzer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang-tools
- run: scan-build cmake -B build -DLIBDEFLATE_BUILD_TESTS=1
- run: scan-build cmake --build build --verbose

run-shellcheck:
name: Run shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y shellcheck
- name: Run shellcheck
run: shellcheck scripts/*.sh

cross-compile-for-windows:
name: Cross compile for Windows
runs-on: ubuntu-latest
env:
CFLAGS: -Werror -DLIBDEFLATE_ENABLE_ASSERTIONS
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 libz-mingw-w64-dev
# Unfortunately Ubuntu doesn't have {i686,x86_64}-w64-mingw32-cmake like
# some distros have, so we have to provide our own toolchain files here.
- name: 32-bit build
run: |
scripts/cmake-helper.sh -DLIBDEFLATE_BUILD_TESTS=1 \
-DCMAKE_TOOLCHAIN_FILE=scripts/toolchain-i686-w64-mingw32.cmake
cmake --build build --verbose
DESTDIR=build/install cmake --install build --verbose
- name: 64-bit build
run: |
scripts/cmake-helper.sh -DLIBDEFLATE_BUILD_TESTS=1 \
-DCMAKE_TOOLCHAIN_FILE=scripts/toolchain-x86_64-w64-mingw32.cmake
cmake --build build --verbose
DESTDIR=build/install cmake --install build --verbose
cross-compile-for-android:
name: Cross compile for ${{matrix.abi}} Android on ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
abi: [armeabi-v7a, arm64-v8a, x86, x86_64]
runs-on: ${{matrix.os}}
env:
CFLAGS: -Werror -DLIBDEFLATE_ENABLE_ASSERTIONS
steps:
- uses: actions/checkout@v4
- run: |
scripts/cmake-helper.sh \
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_LATEST_HOME"/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=${{matrix.abi}} \
-DANDROID_PLATFORM=28 \
-DLIBDEFLATE_BUILD_TESTS=1
cmake --build build --verbose
DESTDIR=build/install cmake --install build --verbose
cpu-features-regression-tests:
name: Test building adler32.c and crc32.c with various flags
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu
- name: Compile tests
run: |
cflags="-O0 -Wall -Werror"
for file in lib/adler32.c lib/crc32.c; do
echo "arm32, default options, file=$file"
arm-linux-gnueabihf-gcc -c $cflags $file
for arch in armv4 armv4t armv5t armv5te armv5tej armv6 armv6j armv6k \
armv6z armv6kz armv6zk armv6t2; do
echo "arm32, -march=$arch, file=$file"
arm-linux-gnueabihf-gcc -c -march=$arch -mfpu=vfp -marm $cflags $file
done
for arch in armv7 armv7-a armv7ve armv7-r armv7-m armv7e-m; do
echo "arm32, -march=$arch, file=$file"
arm-linux-gnueabihf-gcc -c -march=$arch -mfpu=vfp $cflags $file
done
echo "arm64, -mcpu=emag"
aarch64-linux-gnu-gcc -c -mcpu=emag $cflags $file
done
fuzz-with-libFuzzer:
name: Fuzz with libFuzzer (${{matrix.target}} ${{matrix.sanitizer}})
strategy:
matrix:
include:
- target: deflate_compress
sanitizer:
- target: deflate_compress
sanitizer: --asan
- target: deflate_compress
sanitizer: --msan
- target: deflate_compress
sanitizer: --ubsan
- target: deflate_decompress
sanitizer:
- target: deflate_decompress
sanitizer: --asan
- target: deflate_decompress
sanitizer: --msan
- target: deflate_decompress
sanitizer: --ubsan
- target: zlib_decompress
sanitizer:
- target: gzip_decompress
sanitizer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang llvm
- name: Fuzz
run: |
scripts/libFuzzer/fuzz.sh --time=120 ${{matrix.sanitizer}} \
${{matrix.target}}
84 changes: 42 additions & 42 deletions lib/x86/crc32_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,55 +74,55 @@
#endif

/* VPCLMULQDQ/AVX2 implementation. Uses 256-bit vectors. */
#if HAVE_VPCLMULQDQ_INTRIN && HAVE_PCLMULQDQ_INTRIN && HAVE_AVX2_INTRIN
# define crc32_x86_vpclmulqdq_avx2 crc32_x86_vpclmulqdq_avx2
# define SUFFIX _vpclmulqdq_avx2
# if HAVE_VPCLMULQDQ_NATIVE && HAVE_PCLMULQDQ_NATIVE && HAVE_AVX2_NATIVE
# define ATTRIBUTES
# else
# define ATTRIBUTES _target_attribute("vpclmulqdq,pclmul,avx2")
# endif
# define VL 32
# define FOLD_LESSTHAN16BYTES 1
# define USE_TERNARYLOGIC 0
# include "crc32_pclmul_template.h"
#endif
/*#if HAVE_VPCLMULQDQ_INTRIN && HAVE_PCLMULQDQ_INTRIN && HAVE_AVX2_INTRIN*/
/*# define crc32_x86_vpclmulqdq_avx2 crc32_x86_vpclmulqdq_avx2*/
/*# define SUFFIX _vpclmulqdq_avx2*/
/*# if HAVE_VPCLMULQDQ_NATIVE && HAVE_PCLMULQDQ_NATIVE && HAVE_AVX2_NATIVE*/
/*# define ATTRIBUTES*/
/*# else*/
/*# define ATTRIBUTES _target_attribute("vpclmulqdq,pclmul,avx2")*/
/*# endif*/
/*# define VL 32*/
/*# define FOLD_LESSTHAN16BYTES 1*/
/*# define USE_TERNARYLOGIC 0*/
/*# include "crc32_pclmul_template.h"*/
/*#endif*/

/*
* VPCLMULQDQ/AVX512VL implementation. This takes advantage of some AVX-512
* instructions but uses 256-bit vectors rather than 512-bit. This can be
* useful on CPUs where 512-bit vectors cause downclocking.
*/
#if HAVE_VPCLMULQDQ_INTRIN && HAVE_PCLMULQDQ_INTRIN && HAVE_AVX512VL_INTRIN
# define crc32_x86_vpclmulqdq_avx512vl crc32_x86_vpclmulqdq_avx512vl
# define SUFFIX _vpclmulqdq_avx512vl
# if HAVE_VPCLMULQDQ_NATIVE && HAVE_PCLMULQDQ_NATIVE && HAVE_AVX512VL_NATIVE
# define ATTRIBUTES
# else
# define ATTRIBUTES _target_attribute("vpclmulqdq,pclmul,avx512vl")
# endif
# define VL 32
# define FOLD_LESSTHAN16BYTES 1
# define USE_TERNARYLOGIC 1
# include "crc32_pclmul_template.h"
#endif
/*#if HAVE_VPCLMULQDQ_INTRIN && HAVE_PCLMULQDQ_INTRIN && HAVE_AVX512VL_INTRIN*/
/*# define crc32_x86_vpclmulqdq_avx512vl crc32_x86_vpclmulqdq_avx512vl*/
/*# define SUFFIX _vpclmulqdq_avx512vl*/
/*# if HAVE_VPCLMULQDQ_NATIVE && HAVE_PCLMULQDQ_NATIVE && HAVE_AVX512VL_NATIVE*/
/*# define ATTRIBUTES*/
/*# else*/
/*# define ATTRIBUTES _target_attribute("vpclmulqdq,pclmul,avx512vl")*/
/*# endif*/
/*# define VL 32*/
/*# define FOLD_LESSTHAN16BYTES 1*/
/*# define USE_TERNARYLOGIC 1*/
/*# include "crc32_pclmul_template.h"*/
/*#endif*/

/* VPCLMULQDQ/AVX512F/AVX512VL implementation. Uses 512-bit vectors. */
#if HAVE_VPCLMULQDQ_INTRIN && HAVE_PCLMULQDQ_INTRIN && \
HAVE_AVX512F_INTRIN && HAVE_AVX512VL_INTRIN
# define crc32_x86_vpclmulqdq_avx512f_avx512vl crc32_x86_vpclmulqdq_avx512f_avx512vl
# define SUFFIX _vpclmulqdq_avx512f_avx512vl
#if HAVE_VPCLMULQDQ_NATIVE && HAVE_PCLMULQDQ_NATIVE && \
HAVE_AVX512F_NATIVE && HAVE_AVX512VL_NATIVE
# define ATTRIBUTES
# else
# define ATTRIBUTES _target_attribute("vpclmulqdq,pclmul,avx512f,avx512vl")
# endif
# define VL 64
# define FOLD_LESSTHAN16BYTES 1
# define USE_TERNARYLOGIC 1
# include "crc32_pclmul_template.h"
#endif
/*[> VPCLMULQDQ/AVX512F/AVX512VL implementation. Uses 512-bit vectors. <]*/
/*#if HAVE_VPCLMULQDQ_INTRIN && HAVE_PCLMULQDQ_INTRIN && \*/
/*HAVE_AVX512F_INTRIN && HAVE_AVX512VL_INTRIN*/
/*# define crc32_x86_vpclmulqdq_avx512f_avx512vl crc32_x86_vpclmulqdq_avx512f_avx512vl*/
/*# define SUFFIX _vpclmulqdq_avx512f_avx512vl*/
/*#if HAVE_VPCLMULQDQ_NATIVE && HAVE_PCLMULQDQ_NATIVE && \*/
/*HAVE_AVX512F_NATIVE && HAVE_AVX512VL_NATIVE*/
/*# define ATTRIBUTES*/
/*# else*/
/*# define ATTRIBUTES _target_attribute("vpclmulqdq,pclmul,avx512f,avx512vl")*/
/*# endif*/
/*# define VL 64*/
/*# define FOLD_LESSTHAN16BYTES 1*/
/*# define USE_TERNARYLOGIC 1*/
/*# include "crc32_pclmul_template.h"*/
/*#endif*/

/* Choose the best implementation at runtime. */
static inline crc32_func_t
Expand Down

0 comments on commit 88b0830

Please sign in to comment.