Skip to content

Commit

Permalink
[fix] Reading from stdin was effectively broken
Browse files Browse the repository at this point in the history
Introduced in 582d6f7 because of dumb
copy-paste error.
  • Loading branch information
mxmlnkn committed May 21, 2024
1 parent 6bb4020 commit ba82ab0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/test-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ jobs:
mkdir -p "build-sanitized-$sanitizer" && cd -- "$_"
CXX=clang++ CC=clang cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-fsanitize=$sanitizer -DSHORT_TESTS" ..
cmake --build . -- check
cmake --build .
bash ../src/tests/testRapidgzip.sh
UBSan:
name: UBSan
Expand Down
1 change: 0 additions & 1 deletion src/core/filereader/SinglePass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ class SinglePassFileReader final :
if ( underlyingSize && ( m_file->seekable() || ( *underlyingSize > 0 ) ) ) {
return *underlyingSize;
}
return m_fileno;
}
return std::nullopt;
}
Expand Down
33 changes: 33 additions & 0 deletions src/tests/testRapidgzip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

# Should be run from build folder


RAPIDGZIP='src/tools/rapidgzip'
export RAPIDGZIP

function echoerr() { echo "$@" 1>&2; }

returnError()
{
local lineNumber message
if [ $# -eq 2 ]; then
lineNumber=:$1
message=$2
else
message=$*
fi

echoerr -e "\e[37m${FUNCNAME[1]}$lineNumber <- ${FUNCNAME[*]:2}\e[0m"
echoerr -e "\e[37m$message\e[0m"
echoerr -e '\e[31mTEST FAILED!\e[0m'

exit 1
}


# Tests with stdin are hard to do in Catch2, so do them here.
[[ "$( cat ../src/tests/data/base64-256KiB.gz | $RAPIDGZIP --count )" -eq 262144 ]] ||
returnError "$LINENO" 'Stdin count test failed!'

echo -e '\e[32mAll tests ran successfully.\e[0m'

0 comments on commit ba82ab0

Please sign in to comment.