Merge pull request #1027 from t-mat/examples-test-cpp

Add C++ compatibility test for `examples/`
This commit is contained in:
Yann Collet 2021-09-06 10:56:04 -07:00 committed by GitHub
commit 976170316e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 2 deletions

View File

@ -265,6 +265,7 @@ jobs:
# - ubsan
# - asan
# - unicode-lint
# - build examples
#
lz4-cppcheck:
name: make cppcheck
@ -392,6 +393,27 @@ jobs:
run: bash ./tests/unicode_lint.sh
lz4-examples:
name: make examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2 # https://github.com/actions/checkout
- name: apt-get install
run: |
sudo apt-get update
- name: Environment info
run: |
echo && type cc && which cc && cc --version
echo && type c++ && which c++ && c++ --version
- name: examples
run: make V=1 clean examples
- name: examples (compile as C++ code)
run: make V=1 -C examples clean cxxtest
###############################################################
# Platforms
#

View File

@ -95,6 +95,11 @@ test : all $(LZ4)
./frameCompress$(EXT) $(TESTFILE)
$(LZ4) -vt $(TESTFILE).lz4
.PHONY: cxxtest
cxxtest: CFLAGS := -O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror
cxxtest: clean
CC=$(CXX) $(MAKE) -C . all CFLAGS="$(CFLAGS)"
clean:
@rm -f core *.o *.dec *-0 *-9 *-8192 *.lz4s *.lz4 \
printVersion$(EXT) doubleBuffer$(EXT) dictionaryRandomAccess$(EXT) \

View File

@ -78,7 +78,7 @@ void test_compress(FILE* outFp, FILE* inpFp, void *dict, int dictSize)
}
/* Forget previously compressed data and load the dictionary */
LZ4_loadDict(lz4Stream, dict, dictSize);
LZ4_loadDict(lz4Stream, (const char*) dict, dictSize);
{
char cmpBuf[LZ4_COMPRESSBOUND(BLOCK_BYTES)];
const int cmpBytes = LZ4_compress_fast_continue(
@ -153,7 +153,7 @@ void test_decompress(FILE* outFp, FILE* inpFp, void *dict, int dictSize, int off
}
/* Load the dictionary */
LZ4_setStreamDecode(lz4StreamDecode, dict, dictSize);
LZ4_setStreamDecode(lz4StreamDecode, (const char*) dict, dictSize);
{
const int decBytes = LZ4_decompress_safe_continue(
lz4StreamDecode, cmpBuf, decBuf, cmpBytes, BLOCK_BYTES);