From 692607ddd6504b9814affdcbc0b68ab9cbe6ce62 Mon Sep 17 00:00:00 2001 From: Robert Marklund Date: Thu, 23 Jan 2025 11:31:29 +0100 Subject: [PATCH 1/4] add shellcheck script and workflow add yamllint and workflow Signed-off-by: Robert Marklund --- .github/workflows/shellcheck.yml | 23 +++++++++++++++++++++++ .github/workflows/yamllint.yml | 25 +++++++++++++++++++++++++ do_shellcheck.sh | 20 ++++++++++++++++++++ do_yamllint.sh | 21 +++++++++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 .github/workflows/shellcheck.yml create mode 100644 .github/workflows/yamllint.yml create mode 100755 do_shellcheck.sh create mode 100755 do_yamllint.sh diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 0000000..1976aef --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,23 @@ +--- +name: run shellcheck on scripts + +"on": + push: + branches: + - main + - devel + pull_request: + + +jobs: + build: + name: Runs the shellcheck on scripts + runs-on: ubuntu-24.04 + + steps: + - name: checkout + uses: actions/checkout@v4 + - name: install packages + run: sudo apt install shellcheck + - name: run shellcheck + run: ./do_shellcheck.sh diff --git a/.github/workflows/yamllint.yml b/.github/workflows/yamllint.yml new file mode 100644 index 0000000..4ddf79f --- /dev/null +++ b/.github/workflows/yamllint.yml @@ -0,0 +1,25 @@ +--- +name: run yamllint on files + +"on": + push: + branches: + - main + - devel + pull_request: + + +jobs: + build: + name: Runs the yamllint on files + runs-on: ubuntu-24.04 + + steps: + - name: checkout + uses: actions/checkout@v4 + - name: install packages + run: sudo apt install python3 + - name: install yamllint + run: python3 -m venv .venv && .venv/bin/python3 -m pip install yamllint + - name: run yamllint + run: ./do_yamllint.sh diff --git a/do_shellcheck.sh b/do_shellcheck.sh new file mode 100755 index 0000000..64ffafa --- /dev/null +++ b/do_shellcheck.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +set -e + +me=$(basename "$0") + + +echo "$me: run shellcheck on shellscripts" +( + # use this when all issues are fixed + # git ls-files | grep -v "^testcases" | grep -E ".sh$" | xargs shellcheck + shellcheck do_shellcheck.sh do_yamllint.sh +) + +echo "$me: run shellcheck on testcases" +( + # use this when all issues are fixed + # cd testcases && git ls-files | grep -E ".sh$" | xargs shellcheck -x +) + diff --git a/do_yamllint.sh b/do_yamllint.sh new file mode 100755 index 0000000..4a2cd43 --- /dev/null +++ b/do_yamllint.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e + +YMLLINT="" +if which yamllint >/dev/null 2>/dev/null; then + YMLLINT="yamllint" +elif [ -f .venv/bin/yamllint ]; then + YMLLINT=".venv/bin/yamllint" +else + echo "could not find yamllint please install" + echo "for debian based systems: apt -y install libxml2-utils" + echo "for redhat based systems: dnf install yamllint" + echo "local install: python3 -m venv .venv && .venv/bin/python3 -m pip install yamllint" + exit 3 +fi + +# run this when all issues are fixed +# git ls-files | grep -E "*.yml$" | xargs "$YMLLINT" + +"$YMLLINT" .github/workflows/shellcheck.yml .github/workflows/yamllint.yml From ec413aa404c641c6753e7cecb797967a607b457d Mon Sep 17 00:00:00 2001 From: Robert Marklund Date: Thu, 23 Jan 2025 16:26:16 +0100 Subject: [PATCH 2/4] fix shellcheck in all files except test cases enable shellcheck tests in do_shellcheck.sh Signed-off-by: Robert Marklund --- bootstrap.sh | 4 +- cppcheck/run_cppcheck.sh | 18 ++-- do_clang_format.sh | 8 +- do_quality_checks.sh | 181 +++++++++++++++++++++------------------ do_shellcheck.sh | 4 +- 5 files changed, 113 insertions(+), 102 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index 43a9417..626b20f 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -8,11 +8,11 @@ #bail out on error set -e -me=$(basename $0) +me="$(basename "$0")" for prog in aclocal autoheader automake autoconf make; do if ! which $prog >/dev/null 2>&1 ; then - echo $me: please install $prog + echo "$me: please install $prog" exit 1 fi done diff --git a/cppcheck/run_cppcheck.sh b/cppcheck/run_cppcheck.sh index 523c01b..bfe265b 100755 --- a/cppcheck/run_cppcheck.sh +++ b/cppcheck/run_cppcheck.sh @@ -2,24 +2,26 @@ set -eu -outdir=$(dirname $0)/out -me=$(basename $0) +outdir="$(dirname "$0")/out" +me="$(basename "$0")" -mkdir -p $outdir +mkdir -p "$outdir" args="--enable=all --inconclusive --std=c++17 -I . --quiet --suppress=missingIncludeSystem" # cppcheck can not produce an xml report and a reulgar text file at the same time, so run twice -cppcheck $args *.cc *.hh --template='{severity}:{file}:{line}:{message}' 2>$outdir/cppcheck.out +# shellcheck disable=SC2086 +cppcheck $args --template='{severity}:{file}:{line}:{message}' ./*.cc ./*.hh 2>"$outdir/cppcheck.out" -cppcheck $args *.cc *.hh --xml 2>$outdir/cppcheck.xml +# shellcheck disable=SC2086 +cppcheck $args --xml ./*.cc ./*.hh 2>"$outdir/cppcheck.xml" -cppcheck-htmlreport --source-dir=. --title=rdfind --file=$outdir/cppcheck.xml --report-dir=$outdir +cppcheck-htmlreport --source-dir=. --title=rdfind --file="$outdir/cppcheck.xml" --report-dir="$outdir" #is anything serious found? -if grep --quiet -v -E '^(style|information|performance):' $outdir/cppcheck.out ; then - echo $me: cppcheck found serious issues. see $outdir/cppcheck.out +if grep --quiet -v -E '^(style|information|performance):' "$outdir/cppcheck.out"; then + echo "$me: cppcheck found serious issues. see $outdir/cppcheck.out" exit 1 fi diff --git a/do_clang_format.sh b/do_clang_format.sh index b34a787..b677aa2 100755 --- a/do_clang_format.sh +++ b/do_clang_format.sh @@ -8,14 +8,14 @@ # See LICENSE for further details. #find clang format (usually named clang-format-3.x or clang-format, who knows) -CLANGFORMAT=$(find /usr/local/bin /usr/bin -executable -name "clang-format*" |grep -v -- -diff |sort -g |tail -n1) +CLANGFORMAT="$(find /usr/local/bin /usr/bin -executable -name "clang-format*" |grep -v -- -diff |sort -g |tail -n1)" if [ ! -x "$CLANGFORMAT" ] ; then - echo failed finding clangformat + echo "failed finding clangformat" exit 1 else - echo found clang format: $CLANGFORMAT + echo "found clang format: $CLANGFORMAT" fi find . -maxdepth 1 -type f \( -name "*.h" -o -name "*.cpp" -o -name "*.cc" -o -name "*.hh" \) -print0 | \ - xargs -0 -n1 $CLANGFORMAT -i + xargs -0 -n1 "$CLANGFORMAT" -i diff --git a/do_quality_checks.sh b/do_quality_checks.sh index 4d8166f..b754ab6 100755 --- a/do_quality_checks.sh +++ b/do_quality_checks.sh @@ -34,15 +34,15 @@ set -e export LANG= -rootdir=$(dirname $0) -me=$(basename $0) +rootdir="$(dirname "$0")" +me="$(basename "$0")" #flags to configure, for assert. ASSERT= ############################################################################### start_from_scratch() { - cd $rootdir + cd "$rootdir" if [ -e Makefile ] ; then make distclean >/dev/null 2>&1 fi @@ -54,7 +54,8 @@ start_from_scratch() { #argument 3 (optional) is appended to CXXFLAGS compile_and_test_standard() { start_from_scratch - /bin/echo -n "$me: using $(basename $1) with standard $2" + # shellcheck disable=SC3037 + /bin/echo -n "$me: using $(basename "$1") with standard $2" if [ -n "$3" ] ; then echo " (with additional CXXFLAGS $3)" else @@ -62,11 +63,11 @@ compile_and_test_standard() { fi if ! ./bootstrap.sh >bootstrap.log 2>&1; then - echo $me:failed bootstrap - see bootstrap.log + echo "$me: failed bootstrap - see bootstrap.log" exit 1 fi - if ! ./configure $ASSERT --enable-warnings CXX=$1 CXXFLAGS="-std=$2 $3" >configure.log 2>&1 ; then - echo $me: failed configure - see configure.log + if ! ./configure $ASSERT --enable-warnings CXX="$1" CXXFLAGS="-std=$2 $3" >configure.log 2>&1 ; then + echo "$me: failed configure - see configure.log" exit 1 fi #make sure it compiles @@ -75,22 +76,22 @@ compile_and_test_standard() { exit 1 fi if ! /usr/bin/time --format=%e --output=time.log make >make.log 2>&1; then - echo $me: failed make + echo "$me: failed make" exit 1 fi - if [ ! -z $MEASURE_COMPILE_TIME ] ; then - echo $me: " compile with $(basename $1) $2 took $(cat time.log) seconds" + if [ -n "$MEASURE_COMPILE_TIME" ] ; then + echo "$me: compile with $(basename "$1") '$2' took $(cat time.log) seconds" fi #check for warnings if grep -q "warning" make.log; then # store as an artifact instead of erroring out - name=$(cat *.log |sha256sum |head -c 12) - cp make.log make_${name}.log - echo $me: found compile warning - see make.log, also stored as make_${name}.log + name="$(cat ./*.log |sha256sum |head -c 12)" + cp make.log "make_${name}.log" + echo "$me: found compile warning - see make.log, also stored as make_${name}.log" fi #run the tests if ! make check >makecheck.log 2>&1 ; then - echo $me: failed make check - see makecheck.log + echo "$me: failed make check - see makecheck.log" exit 1 fi } @@ -99,10 +100,10 @@ compile_and_test_standard() { compile_and_test() { #this is the test program to compile, so we know the compiler and standard lib #works. clang 4 with c++2a does not. - /bin/echo -e "#include ">x.cpp + echo "#include ">x.cpp #does the compiler understand c++17? That is mandatory. if ! $1 -c x.cpp -std=c++17 >/dev/null 2>&1 ; then - echo $me: this compiler $1 does not understand c++17 + echo "$me: this compiler '$1' does not understand c++17" return 0 fi @@ -110,16 +111,16 @@ compile_and_test() { #use the code words. for std in 1z 2a 2b ; do if ! $1 -c x.cpp -std=c++$std >/dev/null 2>&1 ; then - echo $me: compiler does not understand c++$std, skipping this combination. + echo "$me: compiler does not understand c++$std, skipping this combination." else # debug build ASSERT=--enable-assert - compile_and_test_standard $1 c++$std "-Og" + compile_and_test_standard "$1" "c++$std" "-Og" # release build ASSERT=--disable-assert #compile_and_test_standard $1 c++$std "-O2" - compile_and_test_standard $1 c++$std "-O3" + compile_and_test_standard "$1" "c++$std" "-O3" #compile_and_test_standard $1 c++$std "-Os" fi done @@ -130,31 +131,31 @@ compile_and_test() { # finds the latest clang on the form clang++- and if none found, checks for # clang++. first found is assigned to variable latestclang get_latest_clang() { - for ver in $(seq 30 -1 10); do - candidate=clang++-$ver - if which $candidate >/dev/null 2>&1; then - latestclang=$candidate - return - fi - done - if which clang++ >/dev/null 2>&1; then - latestclang=clang++ - return - fi - latestclang= + for ver in $(seq 30 -1 10); do + candidate="clang++-$ver" + if which "$candidate" >/dev/null 2>&1; then + latestclang="$candidate" + return + fi + done + if which clang++ >/dev/null 2>&1; then + latestclang=clang++ + return + fi + latestclang= } ############################################################################### run_with_sanitizer() { - echo $me: "running with sanitizer (options $1)" + echo "$me: running with sanitizer (options $1)" get_latest_clang - if [ -z $latestclang ] ; then + if [ -z "$latestclang" ] ; then echo "$me: could not find any clang compiler (on the form clang++-ver)" return 0 fi start_from_scratch ./bootstrap.sh >bootstrap.log - ./configure $ASSERT CXX=$latestclang CXXFLAGS="-std=c++17 $1" >configure.log + ./configure "$ASSERT" "CXX=$latestclang" CXXFLAGS="-std=c++17 $1" >configure.log make > make.log 2>&1 export UBSAN_OPTIONS="halt_on_error=true exitcode=1" export ASAN_OPTIONS="halt_on_error=true exitcode=1" @@ -165,29 +166,29 @@ run_with_sanitizer() { ############################################################################### #This tries to mimic how the debian package is built run_with_debian_buildflags() { - echo $me: "running with buildflags from debian dpkg-buildflags" + echo "$me: running with buildflags from debian dpkg-buildflags" if ! which dpkg-buildflags >/dev/null ; then - echo $me: dpkg-buildflags not found - skipping + echo "$me: dpkg-buildflags not found - skipping" return 0 fi start_from_scratch ./bootstrap.sh >bootstrap.log - eval $(DEB_BUILD_MAINT_OPTIONS="hardening=+all qa=+all,-canary reproducible=+all" dpkg-buildflags --export=sh) + eval "$(DEB_BUILD_MAINT_OPTIONS="hardening=+all qa=+all,-canary reproducible=+all" dpkg-buildflags --export=sh)" ./configure >configure.log make > make.log 2>&1 #check for warnings if grep -q "warning" make.log; then # store as an artifact instead of erroring out - name=$(cat *.log |sha256sum |head -c 12) - cp make.log make_${name}.log - echo $me: found compile warnings - see make.log, also stored as make_${name}.log + name="$(cat ./*.log |sha256sum |head -c 12)" + cp make.log "make_${name}.log" + echo "$me: found compile warnings - see make.log, also stored as make_${name}.log" fi make check >make-check.log 2>&1 #restore the build environment for flag in $(dpkg-buildflags |cut -f1 -d=) ; do - unset $flag + unset "$flag" done } ############################################################################### @@ -196,48 +197,51 @@ run_with_libcpp() { echo "#include int main() { std::cout<<\"libc++ works!\"<x.cpp get_latest_clang - if [ ! -z $latestclang ] ; then - if ! $latestclang -std=c++17 -stdlib=libc++ -lc++abi x.cpp >/dev/null 2>&1 || [ ! -x ./a.out ] || ! ./a.out ; then - echo $me: "debug: $latestclang could not compile with libc++ - perhaps uninstalled." - continue + if [ -n "$latestclang" ] ; then + if ! "$latestclang" -std=c++17 -stdlib=libc++ -lc++abi x.cpp >/dev/null 2>&1 || [ ! -x ./a.out ] || ! ./a.out ; then + echo "$me: debug: $latestclang could not compile with libc++ - perhaps uninstalled." + return fi - compile_and_test_standard $latestclang c++17 "-stdlib=libc++ -D_LIBCPP_DEBUG=1" + compile_and_test_standard "$latestclang" c++17 "-stdlib=libc++ -D_LIBCPP_DEBUG=1" return fi # we will get here if no clang could be found. that is not an error, # having clang and libc++ installed is optional - echo $me: no working clang with libc++ found, skipping. + echo "$me: no working clang with libc++ found, skipping." } ############################################################################### verify_packaging() { #make sure the packaging works as intended. - echo $me: "trying to make a tar ball for release and building it..." + echo "$me: trying to make a tar ball for release and building it..." log="$(pwd)/packagetest.log" - ./bootstrap.sh >$log - ./configure >>$log + ./bootstrap.sh >"$log" + ./configure >>"$log" touch dummy - make dist >>$log + make dist >>"$log" TARGZ=$(find "$(pwd)" -newer dummy -name "rdfind*gz" -type f |head -n1) rm dummy - temp=$(mktemp -d) + temp="$(mktemp -d)" cp "$TARGZ" "$temp" cd "$temp" - tar xzf $(basename "$TARGZ") >>$log - cd $(basename "$TARGZ" .tar.gz) - ./configure --prefix=$temp >>$log - make >>$log - make check >>$log - make install >>$log - $temp/bin/rdfind --version >>$log + tar xzf "$(basename "$TARGZ")" >>"$log" + cd "$(basename "$TARGZ" .tar.gz)" + { + ./configure --prefix="$temp" + make + make check + make install + "$temp/bin/rdfind" --version + } >>"$log" #coming here means all went fine, go back to the source dir. - cd $(dirname "$TARGZ") + cd "$(dirname "$TARGZ")" rm -rf "$temp" } ############################################################################### verify_self_contained_headers() { + # shellcheck disable=SC3037 /bin/echo -n "$me: verify that all header files are self contained..." if [ ! -e configure ]; then ./bootstrap.sh >bootstrap.log 2>&1 @@ -246,7 +250,7 @@ verify_self_contained_headers() { ./configure >configure.log 2>&1 fi for header in *.hh ; do - cp $header tmp.cc + cp "$header" tmp.cc if ! g++ -std=c++17 -I. -c tmp.cc -o /dev/null >header.log 2>&1 ; then echo "$me: found a header which is not self contained: $header." echo "$me: see header.log for details" @@ -262,16 +266,16 @@ build_32bit() { #compiling to 32 bit, on amd64. #apt install libc6-i386 gcc-multilib g++-multilib # - if [ $(uname -m) != x86_64 ] ; then - echo $me: "not on x64, won't cross compile with -m32" + if [ "$(uname -m)" != x86_64 ] ; then + echo "$me: not on x64, won't cross compile with -m32" return; fi - echo $me: "trying to compile in 32 bit mode with -m32..." + echo "$me: trying to compile in 32 bit mode with -m32..." configureflags="--build=i686-pc-linux-gnu CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32" - here=$(pwd) + here="$(pwd)" nettleinstall=$here/nettle32bit if [ -d "$nettleinstall" ] ; then - echo $me: "local nettle already seems to be installed" + echo "$me: local nettle already seems to be installed" else mkdir "$nettleinstall" cd "$nettleinstall" @@ -282,11 +286,12 @@ build_32bit() { sha256sum --strict --quiet -c checksum tar xzf nettle-$nettleversion.tar.gz cd nettle-$nettleversion - echo $me: trying to configure nettle - ./configure $configureflags --prefix="$nettleinstall" >$here/nettle.configure.log 2>&1 - make install >$here/nettle.install.log 2>&1 - echo $me: "local nettle install went ok" - cd $here + echo "$me: trying to configure nettle" + # shellcheck disable=SC2086 + ./configure $configureflags --prefix="$nettleinstall" >"$here/nettle.configure.log" 2>&1 + make install >"$here/nettle.install.log" 2>&1 + echo "$me: local nettle install went ok" + cd "$here" fi ./bootstrap.sh >bootstrap.log 2>&1 echo "$me: attempting configure with 32 bit flags... (see configure.log if it fails)" @@ -308,29 +313,35 @@ echo "">inodes_for_tested_compilers.txt #try all variants of g++ if which g++ >/dev/null ; then - for COMPILER in $(ls $(which g++)* |grep -v libc); do - inode=$(stat --dereference --format=%i $COMPILER) - if grep -q "^$inode\$" inodes_for_tested_compilers.txt ; then - echo $me: skipping this compiler $COMPILER - already tested + for COMPILER in "$(which g++)"*; do + if echo "$COMPILER" | grep libc; then + continue + fi + inode=$(stat --dereference --format=%i "$COMPILER") + if [ -f inodes_for_tested_compilers.txt ] && grep -q "^$inode\$" inodes_for_tested_compilers.txt >/dev/null; then + echo "$me: skipping this compiler $COMPILER - already tested" else #echo trying gcc $GCC:$($GCC --version|head -n1) - echo $inode >>inodes_for_tested_compilers.txt - compile_and_test $COMPILER + echo "$inode" >>inodes_for_tested_compilers.txt + compile_and_test "$COMPILER" fi done fi #try all variants of clang get_latest_clang -if which $latestclang >/dev/null ; then - for COMPILER in $(ls $(dirname $(which $latestclang))/clang++* |grep -v libc); do - inode=$(stat --dereference --format=%i $COMPILER) - if grep -q "^$inode\$" inodes_for_tested_compilers.txt ; then - echo $me: skipping this compiler $COMPILER - already tested +if which "$latestclang" >/dev/null ; then + for COMPILER in "$(dirname "$(which "$latestclang")")"/clang++*; do + if echo "$COMPILER" | grep libc; then + continue + fi + inode=$(stat --dereference --format=%i "$COMPILER") + if [ -f inodes_for_tested_compilers.txt ] && grep -q "^$inode\$" inodes_for_tested_compilers.txt >/dev/null; then + echo "$me: skipping this compiler $COMPILER - already tested" else #echo trying gcc $GCC:$($GCC --version|head -n1) - echo $inode >>inodes_for_tested_compilers.txt - compile_and_test $COMPILER + echo "$inode" >>inodes_for_tested_compilers.txt + compile_and_test "$COMPILER" fi done fi @@ -359,7 +370,7 @@ run_with_libcpp #test build with running through valgrind if which valgrind >/dev/null; then - echo $me: running unit tests through valgrind + echo "$me: running unit tests through valgrind" ASSERT="--disable-assert" compile_and_test_standard g++ c++17 "-O3" VALGRIND=valgrind make check >make-check.log diff --git a/do_shellcheck.sh b/do_shellcheck.sh index 64ffafa..0d249b4 100755 --- a/do_shellcheck.sh +++ b/do_shellcheck.sh @@ -7,9 +7,7 @@ me=$(basename "$0") echo "$me: run shellcheck on shellscripts" ( - # use this when all issues are fixed - # git ls-files | grep -v "^testcases" | grep -E ".sh$" | xargs shellcheck - shellcheck do_shellcheck.sh do_yamllint.sh + git ls-files | grep -v "^testcases" | grep -E ".sh$" | xargs shellcheck ) echo "$me: run shellcheck on testcases" From c8c0a039a011d58482bf9a5af5a1f1343974c101 Mon Sep 17 00:00:00 2001 From: Robert Marklund Date: Thu, 23 Jan 2025 17:08:47 +0100 Subject: [PATCH 3/4] fix shellcheck in test cases enable shellcheck tests for these files in do_shellcheck.sh Signed-off-by: Robert Marklund --- do_shellcheck.sh | 3 +- testcases/checksum_options.sh | 6 +-- testcases/common_funcs.sh | 36 ++++++++------- testcases/hardlink_fails.sh | 24 +++++----- testcases/largefilesupport.sh | 2 +- testcases/md5collisions.sh | 2 +- testcases/sha1collisions.sh | 2 +- testcases/symlinking_action.sh | 49 ++++++++++----------- testcases/verify_deterministic_operation.sh | 33 +++++++------- testcases/verify_dryrun_option.sh | 14 +++--- testcases/verify_filesize_option.sh | 34 +++++++------- testcases/verify_maxfilesize_option.sh | 8 ++-- testcases/verify_ranking.sh | 32 +++++++------- 13 files changed, 123 insertions(+), 122 deletions(-) diff --git a/do_shellcheck.sh b/do_shellcheck.sh index 0d249b4..3fe577b 100755 --- a/do_shellcheck.sh +++ b/do_shellcheck.sh @@ -12,7 +12,6 @@ echo "$me: run shellcheck on shellscripts" echo "$me: run shellcheck on testcases" ( - # use this when all issues are fixed - # cd testcases && git ls-files | grep -E ".sh$" | xargs shellcheck -x + cd testcases && git ls-files | grep -E ".sh$" | xargs shellcheck -x ) diff --git a/testcases/checksum_options.sh b/testcases/checksum_options.sh index 445693c..b4b98ca 100755 --- a/testcases/checksum_options.sh +++ b/testcases/checksum_options.sh @@ -15,7 +15,7 @@ for checksumtype in $allchecksumtypes; do dbgecho "trying checksum $checksumtype with small files" echo checksumtest >a echo checksumtest >b - $rdfind -checksum $checksumtype -deleteduplicates true a b + $rdfind -checksum "$checksumtype" -deleteduplicates true a b [ -e a ] [ ! -e b ] done @@ -25,7 +25,7 @@ for checksumtype in $allchecksumtypes; do dbgecho "trying checksum $checksumtype with large files" head -c 1000000 /dev/zero >a head -c 1000000 /dev/zero >b - $rdfind -checksum $checksumtype -deleteduplicates true a b + $rdfind -checksum "$checksumtype" -deleteduplicates true a b [ -e a ] [ ! -e b ] done @@ -35,7 +35,7 @@ for checksumtype in $allchecksumtypes; do dbgecho "trying checksum $checksumtype with large files that differ only in the middle" ( head -c 1000000 /dev/zero; echo =====a=====; head -c 1000000 /dev/zero) >a ( head -c 1000000 /dev/zero; echo =====b=====; head -c 1000000 /dev/zero) >b - $rdfind -checksum $checksumtype -deleteduplicates true a b + $rdfind -checksum "$checksumtype" -deleteduplicates true a b [ -e a ] [ -e b ] done diff --git a/testcases/common_funcs.sh b/testcases/common_funcs.sh index 31c8760..ce1af80 100755 --- a/testcases/common_funcs.sh +++ b/testcases/common_funcs.sh @@ -6,9 +6,10 @@ #bail out on the first error set -e -me=$(basename $0) +me="$(basename "$0")" +# shellcheck disable=SC3037 /bin/echo -n "$me: checking for rdfind ..." rdfind=$PWD/rdfind if [ ! -x "$rdfind" ]; then @@ -17,8 +18,8 @@ if [ ! -x "$rdfind" ]; then fi echo " OK." -/bin/echo -n "checking for valgrind ..." -if [ -z $VALGRIND ] ; then +printf "checking for valgrind ..." +if [ -z "$VALGRIND" ] ; then echo "not used." else echo "active! here is the command: $VALGRIND" @@ -27,15 +28,15 @@ fi rdfind="$VALGRIND $rdfind" #where is the test scripts dir? -testscriptsdir=$(dirname $(readlink -f $0)) - +testscriptsdir="$(dirname "$(readlink -f "$0")")" +export testscriptsdir dbgecho() { echo "$0 debug: " "$@" } -echo -n "checking for mktemp ..." +printf "checking for mktemp ..." which mktemp >/dev/null echo " OK." @@ -52,39 +53,40 @@ cleanup () { rm -rf "$datadir" } -if [ -z $KEEPTEMPDIR ] ; then +if [ -z "$KEEPTEMPDIR" ] ; then trap cleanup INT QUIT EXIT fi -[ -d $datadir ] -cd $datadir +[ -d "$datadir" ] +cd "$datadir" reset_teststate() { cd / rm -rf "$datadir" - mkdir -p $datadir + mkdir -p "$datadir" cd "$datadir" } verify() { - if ! $@ ; then - echo "failed asserting $@" + if ! "$@" ; then + echo "failed asserting $*" exit 1 fi } # where to mount disorderfs for the determinism tests -DISORDERED_MNT=$datadir/disordered_mnt -DISORDERED_ROOT=$datadir/disordered_root +DISORDERED_MNT="$datadir/disordered_mnt" +DISORDERED_ROOT="$datadir/disordered_root" # do we have a working disorder fs? hasdisorderfs=false if which disorderfs fusermount >/dev/null 2>&1; then - mkdir -p $DISORDERED_MNT $DISORDERED_ROOT - if disorderfs $DISORDERED_ROOT $DISORDERED_MNT >/dev/null 2>&1 ; then + mkdir -p "$DISORDERED_MNT" "$DISORDERED_ROOT" + if disorderfs "$DISORDERED_ROOT" "$DISORDERED_MNT" >/dev/null 2>&1 ; then # "Sälj inte skinnet förrän björnen är skjuten - Don't count your chickens until they're hatched" - fusermount -z -u $DISORDERED_MNT + fusermount -z -u "$DISORDERED_MNT" hasdisorderfs=true fi fi +export hasdisorderfs diff --git a/testcases/hardlink_fails.sh b/testcases/hardlink_fails.sh index 713f806..9fde52a 100755 --- a/testcases/hardlink_fails.sh +++ b/testcases/hardlink_fails.sh @@ -13,17 +13,17 @@ reset_teststate files="a subdir/b c some/deeply/nested/subdir/d" nfiles=4 for n in $files ; do - mkdir -p $(dirname $datadir/$n) - echo "hello hardlink" > $datadir/$n + mkdir -p "$(dirname "$datadir/$n")" + echo "hello hardlink" > "$datadir/$n" done #eliminate them. -$rdfind -makehardlinks true $datadir/ +$rdfind -makehardlinks true "$datadir/" #make sure one is a hard link to the other. for n in $files ; do - nhardlinks=$(stat -c %h $datadir/$n) - if [ $nhardlinks -ne $nfiles ] ; then + nhardlinks=$(stat -c %h "$datadir/$n") + if [ "$nhardlinks" -ne "$nfiles" ] ; then dbgecho "expected $nfiles hardlinks, got $nhardlinks" exit 1 fi @@ -33,10 +33,10 @@ dbgecho passed the happy path # try to make a hardlink to somewhere that fails. reset_teststate -mkdir -p $datadir/readonly.d/ -echo xxx > $datadir/readonly.d/a -echo xxx > $datadir/readonly.d/b -chmod 500 $datadir/readonly.d/ +mkdir -p "$datadir/readonly.d/" +echo xxx > "$datadir/readonly.d/a" +echo xxx > "$datadir/readonly.d/b" +chmod 500 "$datadir/readonly.d/" if [ "$(id -u)" -eq 0 ]; then # if running as root, directory rights are not respected. drop the capability @@ -53,13 +53,13 @@ fi #make sure that our own copy is still there for f in a b ; do - if [ ! -e $datadir/readonly.d/$f ] ; then - dbgecho file $f is missing, rdfind should not have removed it! + if [ ! -e "$datadir/readonly.d/$f" ] ; then + dbgecho "file $f is missing, rdfind should not have removed it!" exit 1 fi done # make sure it can be cleaned up -chmod 700 $datadir/readonly.d/ +chmod 700 "$datadir/readonly.d/" dbgecho "all is good in this test!" diff --git a/testcases/largefilesupport.sh b/testcases/largefilesupport.sh index f7476ac..c648c20 100755 --- a/testcases/largefilesupport.sh +++ b/testcases/largefilesupport.sh @@ -8,7 +8,7 @@ reset_teststate #create a large file, sparse. filesizem1=2147483647 #size, in bytes. This is no problem. -filesize=$(($filesizem1+1)) #size, in bytes. This is a problematic value. +filesize=$((filesizem1+1)) #size, in bytes. This is a problematic value. #below, dd is used and the file is later appended to, to avoid problems #on Hurd which currently (20130619) can not take $filesize as argument to diff --git a/testcases/md5collisions.sh b/testcases/md5collisions.sh index 8545761..83cda84 100755 --- a/testcases/md5collisions.sh +++ b/testcases/md5collisions.sh @@ -10,7 +10,7 @@ reset_teststate #check md5 collision files mkdir md5coll -cp $testscriptsdir/md5collisions/*.ps md5coll +cp "$testscriptsdir/md5collisions/"*.ps md5coll sync #make sure nothing happens when using sha diff --git a/testcases/sha1collisions.sh b/testcases/sha1collisions.sh index 7c2711e..fa7aa9a 100755 --- a/testcases/sha1collisions.sh +++ b/testcases/sha1collisions.sh @@ -9,7 +9,7 @@ set -e reset_teststate #unpack collisions example from https://shattered.it/static/shattered.pdf -base64 --decode <$testscriptsdir/sha1collisions/coll.tar.bz2.b64 |tar xvfj - +base64 --decode <"$testscriptsdir/sha1collisions/coll.tar.bz2.b64" | tar xvfj - #make sure nothing happens when using sha256 $rdfind -checksum sha256 -deleteduplicates true . 2>&1 |tee rdfind.out diff --git a/testcases/symlinking_action.sh b/testcases/symlinking_action.sh index c6959f5..05103b7 100755 --- a/testcases/symlinking_action.sh +++ b/testcases/symlinking_action.sh @@ -10,20 +10,19 @@ reset_teststate #make identical files. files="first subdir/b c some/deeply/nested/subdir/d" -nfiles=4 for n in $files ; do - mkdir -p $(dirname $datadir/$n) - echo "hello symlink" > $datadir/$n + mkdir -p "$(dirname "$datadir/$n")" + echo "hello symlink" > "$datadir/$n" done #eliminate them. -$rdfind -makesymlinks true $datadir/first $datadir/ +$rdfind -makesymlinks true "$datadir/first" "$datadir/" #make sure the first one is untouched (it has the highest rank), and the rest are symlinks. export LANG= for n in $files ; do - if [ $n = "first" ]; then + if [ "$n" = "first" ]; then inodeforfirst=$(stat -c %i "$datadir/first") if [ x"$(stat -c %F "$datadir/first")" != x"regular file" ] ; then dbgecho "expected first to be a regular file" @@ -35,7 +34,7 @@ for n in $files ; do exit 1 fi inodeforn=$(stat --dereference -c %i "$datadir/$n") - if [ $inodeforfirst != $inodeforn ] ; then + if [ "$inodeforfirst" != "$inodeforn" ] ; then dbgecho "$n does not refer to first - inode mismatch $inodeforfirst vs $inodeforn" exit 1 fi @@ -47,10 +46,10 @@ dbgecho passed the happy path # try to make a symlink somewhere where it fails. reset_teststate -mkdir -p $datadir/readonly.d/ -echo xxx > $datadir/readonly.d/a -echo xxx > $datadir/readonly.d/b -chmod 500 $datadir/readonly.d/ +mkdir -p "$datadir/readonly.d/" +echo xxx > "$datadir/readonly.d/a" +echo xxx > "$datadir/readonly.d/b" +chmod 500 "$datadir/readonly.d/" if [ "$(id -u)" -eq 0 ]; then # if running as root, directory rights are not respected. drop the capability @@ -67,16 +66,16 @@ fi # make sure that our own copy is still there for f in a b ; do - if [ ! -e $datadir/readonly.d/$f ] ; then - dbgecho file $f is missing, rdfind should not have removed it! + if [ ! -e "$datadir/readonly.d/$f" ] ; then + dbgecho "file $f is missing, rdfind should not have removed it!" exit 1 fi done # make sure it can be cleaned up -chmod 700 $datadir/readonly.d/ +chmod 700 "$datadir/readonly.d/" -dbgecho passed the test with trying to write to a readonly directory +dbgecho "passed the test with trying to write to a readonly directory" @@ -85,13 +84,13 @@ dbgecho passed the test with trying to write to a readonly directory # argument 1 is path to file 1. argument 2 is path to file 2. pathsimplification() { reset_teststate - mkdir -p $(dirname $1) && echo "simplification test" >$1 - mkdir -p $(dirname $2) && echo "simplification test" >$2 + mkdir -p "$(dirname "$1")" && echo "simplification test" >"$1" + mkdir -p "$(dirname "$2")" && echo "simplification test" >"$2" #dbgecho "state before (args $1 $2)" #tree - $rdfind -makesymlinks true $1 $2 2>&1 |tee rdfind.out + $rdfind -makesymlinks true "$1" "$2" 2>&1 |tee rdfind.out # $2 should be a symlink to $1 if [ x"$(stat -c %F "$1")" != x"regular file" ] ; then dbgecho "expected file $1 to be a regular file" @@ -103,14 +102,14 @@ pathsimplification() { fi inodefor1=$(stat -c %i "$1") inodefor2=$(stat --dereference -c %i "$2") - if [ $inodefor1 != $inodefor2 ] ; then + if [ "$inodefor1" != "$inodefor2" ] ; then dbgecho "inode mismatch $inodefor1 vs $inodefor2" exit 1 fi #switching directory should still give the correct answer - cd $(dirname $2) - inodefor2=$(stat --dereference -c %i $(basename "$2")) - if [ $inodefor1 != $inodefor2 ] ; then + cd "$(dirname "$2")" + inodefor2="$(stat --dereference -c %i "$(basename "$2")")" + if [ "$inodefor1" != "$inodefor2" ] ; then dbgecho "inode mismatch $inodefor1 vs $inodefor2" exit 1 fi @@ -128,10 +127,10 @@ pathsimplification subdir1/../a subdir2/b pathsimplification subdir1/../a subdir2/./././b pathsimplification subdir2/./././b subdir1/../a pathsimplification a subdir2/./././b -pathsimplification $(pwd)/a b -pathsimplification a $(pwd)/b -pathsimplification $(pwd)/a $(pwd)/b -pathsimplification $(pwd)/subdir/../a $(pwd)/b +pathsimplification "$(pwd)/a" b +pathsimplification a "$(pwd)/b" +pathsimplification "$(pwd)/a" "$(pwd)/b" +pathsimplification "$(pwd)/subdir/../a" "$(pwd)/b" pathsimplification ./a b pathsimplification ./a ./b pathsimplification a ./b diff --git a/testcases/verify_deterministic_operation.sh b/testcases/verify_deterministic_operation.sh index b74a02b..e8c1a4c 100755 --- a/testcases/verify_deterministic_operation.sh +++ b/testcases/verify_deterministic_operation.sh @@ -16,9 +16,9 @@ fi #unmount disordered unmount_disordered() { - if [ -d $DISORDERED_MNT ]; then - if ! fusermount --quiet -u $DISORDERED_MNT ; then - dbgecho failed unmounting disordered + if [ -d "$DISORDERED_MNT" ]; then + if ! fusermount --quiet -u "$DISORDERED_MNT" ; then + dbgecho "failed unmounting disordered" fi fi } @@ -28,17 +28,18 @@ DISORDERED_FLAGS_ASC="--shuffle-dirents=no --sort-dirents=yes --reverse-dirents= DISORDERED_FLAGS_DESC="--shuffle-dirents=no --sort-dirents=yes --reverse-dirents=yes" DISORDERED_FLAGS=$DISORDERED_FLAGS_RANDOM mount_disordered() { - mkdir -p $DISORDERED_MNT - mkdir -p $DISORDERED_ROOT - disorderfs $DISORDERED_FLAGS $DISORDERED_ROOT $DISORDERED_MNT >/dev/null + mkdir -p "$DISORDERED_MNT" + mkdir -p "$DISORDERED_ROOT" + # shellcheck disable=SC2086 + disorderfs $DISORDERED_FLAGS "$DISORDERED_ROOT" "$DISORDERED_MNT" >/dev/null } #create cr8() { while [ $# -gt 0 ] ; do - mkdir -p $(dirname $1) + mkdir -p "$(dirname "$1")" # make sure the file is longer than what fits in the byte buffer - head -c1000 /dev/zero >$1 + head -c1000 /dev/zero >"$1" shift done } @@ -46,17 +47,17 @@ local_reset() { unmount_disordered reset_teststate mount_disordered - cr8 $@ + cr8 "$@" } #sets global variable outcome to which file was preserved, a or b. #$1 - value of -deterministic flag (true or false) run_outcome() { - local_reset $DISORDERED_MNT/a $DISORDERED_MNT/b - $rdfind -deterministic $1 -deleteduplicates true $DISORDERED_MNT >rdfind.out - if [ -f $DISORDERED_MNT/a -a ! -e $DISORDERED_MNT/b ] ; then + local_reset "$DISORDERED_MNT/a" "$DISORDERED_MNT/b" + $rdfind -deterministic "$1" -deleteduplicates true "$DISORDERED_MNT" >rdfind.out + if [ -f "$DISORDERED_MNT/a" ] && [ ! -e "$DISORDERED_MNT/b" ] ; then outcome=a - elif [ ! -e $DISORDERED_MNT/a -a -f $DISORDERED_MNT/b ] ; then + elif [ ! -e "$DISORDERED_MNT/a" ] && [ -f "$DISORDERED_MNT/b" ] ; then outcome=b else dbgecho "bad result! test failed!" @@ -86,15 +87,15 @@ dbgecho "tests for deterministic false passed ok (non-randomized)" #depending on the output from the file system DISORDERED_FLAGS=$DISORDERED_FLAGS_RANDOM run_outcome false -last_outcome=$outcome +last_outcome="$outcome" for i in $(seq 128) ; do run_outcome false - if [ $last_outcome != $outcome ] ; then + if [ "$last_outcome" != "$outcome" ] ; then #proved that both outcomes can happen. good! dbgecho "got a different outcome after $i random tries" break else - if [ $i -eq 64 ] ; then + if [ "$i" -eq 64 ] ; then dbgecho "reached max number of iterations without getting different results". exit 1 fi diff --git a/testcases/verify_dryrun_option.sh b/testcases/verify_dryrun_option.sh index 9916ede..73712d3 100755 --- a/testcases/verify_dryrun_option.sh +++ b/testcases/verify_dryrun_option.sh @@ -30,12 +30,12 @@ for dryrunopt in -dryrun -n ; do $rdfind $dryrunopt true -makesymlinks true a b >rdfind.out [ -f a ] [ -f b ] - [ $(stat -c %i a) != $(stat --dereference -c %i b) ] + [ "$(stat -c %i a)" != "$(stat --dereference -c %i b)" ] dbgecho "files still there, good" $rdfind $dryrunopt false -makesymlinks true a b >rdfind.out [ -f a ] [ -L b ] - [ $(stat -c %i a) = $(stat --dereference -c %i b) ] + [ "$(stat -c %i a)" = "$(stat --dereference -c %i b)" ] dbgecho "b was replaced with a symlink, good" @@ -44,15 +44,15 @@ for dryrunopt in -dryrun -n ; do $rdfind $dryrunopt true -makehardlinks true a b >rdfind.out [ -f a ] [ -f b ] - [ $(stat -c %i a) != $(stat -c %i b) ] - [ $(stat -c %h a) -eq 1 ] + [ "$(stat -c %i a)" != "$(stat -c %i b)" ] + [ "$(stat -c %h a)" -eq 1 ] dbgecho "files still there, good" $rdfind $dryrunopt false -makehardlinks true a b >rdfind.out [ -f a ] [ -f b ] - [ $(stat -c %i a) = $(stat -c %i b) ] - [ $(stat -c %h a) -eq 2 ] - [ $(stat -c %h b) -eq 2 ] + [ "$(stat -c %i a)" = "$(stat -c %i b)" ] + [ "$(stat -c %h a)" -eq 2 ] + [ "$(stat -c %h b)" -eq 2 ] dbgecho "b was replaced with a hard link, good" diff --git a/testcases/verify_filesize_option.sh b/testcases/verify_filesize_option.sh index 4fb5f27..6743c62 100755 --- a/testcases/verify_filesize_option.sh +++ b/testcases/verify_filesize_option.sh @@ -9,8 +9,8 @@ set -e #make pairs of files, with specific sizes makefiles() { for i in $(seq 0 4) ; do - head -c$i /dev/zero >a$i - head -c$i /dev/zero >b$i + head -c"$i" /dev/zero >"a$i" + head -c"$i" /dev/zero >"b$i" done } @@ -20,11 +20,11 @@ makefiles #try eliminate them, but they are correctly ignored. $rdfind -ignoreempty true -deleteduplicates true a* b* -verify [ -e a0 ] -verify [ -e b0 ] +verify [ -e "a0" ] +verify [ -e "b0" ] for i in $(seq 1 4) ; do - verify [ -e a$i ] - verify [ ! -e b$i ] + verify [ -e "a$i" ] + verify [ ! -e "b$i" ] done dbgecho "passed ignoreempty true test case" @@ -36,8 +36,8 @@ $rdfind -ignoreempty false -deleteduplicates true a* b* verify [ -e a0 ] verify [ ! -e b0 ] for i in $(seq 1 4) ; do - verify [ -e a$i ] - verify [ ! -e b$i ] + verify [ -e "a$i" ] + verify [ ! -e "b$i" ] done dbgecho "passed ignoreempty false test case" @@ -49,8 +49,8 @@ $rdfind -minsize 0 -deleteduplicates true a* b* verify [ -e a0 ] verify [ ! -e b0 ] for i in $(seq 1 4) ; do - verify [ -e a$i ] - verify [ ! -e b$i ] + verify [ -e "a$i" ] + verify [ ! -e "b$i" ] done dbgecho "passed -minsize 0 test case" @@ -62,8 +62,8 @@ $rdfind -minsize 1 -deleteduplicates true a* b* verify [ -e a0 ] verify [ -e b0 ] for i in $(seq 1 4) ; do - verify [ -e a$i ] - verify [ ! -e b$i ] + verify [ -e "a$i" ] + verify [ ! -e "b$i" ] done dbgecho "passed -minsize 1 test case" @@ -73,13 +73,13 @@ dbgecho "passed -minsize 1 test case" for cutoff in $(seq 0 4) ; do reset_teststate makefiles - $rdfind -minsize $cutoff -deleteduplicates true a* b* + $rdfind -minsize "$cutoff" -deleteduplicates true a* b* for i in $(seq 0 4) ; do - verify [ -e a$i ] - if [ $i -lt $cutoff ] ; then - verify [ -e b$i ] + verify [ -e "a$i" ] + if [ "$i" -lt "$cutoff" ] ; then + verify [ -e "b$i" ] else - verify [ ! -e b$i ] + verify [ ! -e "b$i" ] fi done dbgecho "passed -minsize $cutoff test case" diff --git a/testcases/verify_maxfilesize_option.sh b/testcases/verify_maxfilesize_option.sh index 999852d..033161d 100755 --- a/testcases/verify_maxfilesize_option.sh +++ b/testcases/verify_maxfilesize_option.sh @@ -11,8 +11,8 @@ set -e makefiles() { #make pairs of files, with specific sizes for i in $(seq 0 4) ; do - head -c$i /dev/zero >a$i - head -c$i /dev/zero >b$i + head -c"$i" /dev/zero >"a$i" + head -c"$i" /dev/zero >"b$i" done } @@ -43,8 +43,8 @@ $rdfind -deleteduplicates true -minsize 2 -maxsize 3 a* b* verify [ -e a2 ] verify [ ! -e b2 ] for i in $(seq 0 1) $(seq 3 4); do - verify [ -e a$i ] - verify [ -e b$i ] + verify [ -e "a$i" ] + verify [ -e "b$i" ] done dbgecho "passed specific size test" diff --git a/testcases/verify_ranking.sh b/testcases/verify_ranking.sh index 60fb19b..daf78c7 100755 --- a/testcases/verify_ranking.sh +++ b/testcases/verify_ranking.sh @@ -12,27 +12,27 @@ unmount_disordered() { if ! $hasdisorderfs ; then return fi - if [ -d $DISORDERED_MNT ]; then - if ! fusermount --quiet -z -u $DISORDERED_MNT ; then + if [ -d "$DISORDERED_MNT" ]; then + if ! fusermount --quiet -z -u "$DISORDERED_MNT" ; then dbgecho failed unmounting disordered fi fi } mount_disordered() { - mkdir -p $DISORDERED_MNT $DISORDERED_ROOT - if ! $hasdisorderfs ; then + mkdir -p "$DISORDERED_MNT" "$DISORDERED_ROOT" + if ! $hasdisorderfs; then return fi - disorderfs --sort-dirents=yes --reverse-dirents=no $DISORDERED_ROOT $DISORDERED_MNT >/dev/null + disorderfs --sort-dirents=yes --reverse-dirents=no "$DISORDERED_ROOT" "$DISORDERED_MNT" >/dev/null } #create cr8() { while [ $# -gt 0 ] ; do - mkdir -p $(dirname $1) + mkdir -p "$(dirname "$1")" # make sure the file is longer than what fits in the byte buffer - head -c1000 /dev/zero >$1 + head -c1000 /dev/zero >"$1" shift done } @@ -41,7 +41,7 @@ local_reset() { unmount_disordered reset_teststate mount_disordered - cr8 $@ + cr8 "$@" } @@ -97,16 +97,16 @@ dbgecho "tests for rule 2 passed ok" #apt install disorderfs, and make sure you are member of the fuse group. if $hasdisorderfs ; then - local_reset $DISORDERED_MNT/a $DISORDERED_MNT/b - $rdfind -deleteduplicates true $DISORDERED_MNT >rdfind.out - [ -f $DISORDERED_MNT/a ] - [ ! -e $DISORDERED_MNT/b ] + local_reset "$DISORDERED_MNT/a" "$DISORDERED_MNT/b" + $rdfind -deleteduplicates true "$DISORDERED_MNT" >rdfind.out + [ -f "$DISORDERED_MNT/a" ] + [ ! -e "$DISORDERED_MNT/b" ] dbgecho "tests for rule 3 passed ok" - local_reset $DISORDERED_MNT/b $DISORDERED_MNT/a - $rdfind -deleteduplicates true $DISORDERED_MNT >rdfind.out - [ -f $DISORDERED_MNT/a ] - [ ! -e $DISORDERED_MNT/b ] + local_reset "$DISORDERED_MNT/b" "$DISORDERED_MNT/a" + $rdfind -deleteduplicates true "$DISORDERED_MNT" >rdfind.out + [ -f "$DISORDERED_MNT/a" ] + [ ! -e "$DISORDERED_MNT/b" ] dbgecho "tests for rule 3 passed ok" else dbgecho "could not execute tests for rule 3 - please install disorderfs" From 42a92c8ace01f75a83ced59c9deef5ad38c83eaa Mon Sep 17 00:00:00 2001 From: Robert Marklund Date: Thu, 23 Jan 2025 17:32:56 +0100 Subject: [PATCH 4/4] fix yamllint in workflows add all files to do_yamllint.sh Signed-off-by: Robert Marklund --- .github/workflows/clang18.yml | 38 ++++++++--------- .github/workflows/codeql.yml | 60 ++++++++++++++------------- .github/workflows/cppcheck.yml | 26 ++++++------ .github/workflows/debian-bookworm.yml | 55 ++++++++++++------------ .github/workflows/debian-bullseye.yml | 55 ++++++++++++------------ .github/workflows/debian-trixie.yml | 55 ++++++++++++------------ .github/workflows/deterministic.yml | 38 ++++++++--------- .github/workflows/fedora-40.yml | 41 +++++++++--------- .github/workflows/fedora-41.yml | 41 +++++++++--------- .github/workflows/formatting.yml | 56 ++++++++++++------------- .github/workflows/gcc10.yml | 38 ++++++++--------- .github/workflows/gcc11.yml | 38 ++++++++--------- .github/workflows/gcc12.yml | 38 ++++++++--------- .github/workflows/gcc13.yml | 46 ++++++++++---------- .github/workflows/gcc14.yml | 38 ++++++++--------- .github/workflows/gcc9.yml | 38 ++++++++--------- .github/workflows/mac.yml | 44 ++++++++++---------- .github/workflows/quality.yml | 26 ++++++------ .github/workflows/ubuntu-default.yml | 31 +++++++------- .yamllint | 39 +++++++++++++++++ do_yamllint.sh | 4 +- 21 files changed, 446 insertions(+), 399 deletions(-) create mode 100644 .yamllint diff --git a/.github/workflows/clang18.yml b/.github/workflows/clang18.yml index 299b861..7d8f05d 100644 --- a/.github/workflows/clang18.yml +++ b/.github/workflows/clang18.yml @@ -1,6 +1,7 @@ +--- name: clang 18 -on: +"on": push: branches: - main @@ -14,21 +15,20 @@ jobs: runs-on: ubuntu-24.04 steps: - - name: checkout - uses: actions/checkout@v4 - - name: install packages - run: sudo apt install build-essential nettle-dev time clang-18 - - name: bootstrap - run: ./bootstrap.sh - - name: configure - run: ./configure CXX=clang++-18 - - name: build - run: make - - name: check - run: make check - - name: store the logs as an artifact - if: ${{ always() }} - uses: actions/upload-artifact@v4 - with: - path: '**/*.log' - + - name: checkout + uses: actions/checkout@v4 + - name: install packages + run: sudo apt install build-essential nettle-dev time clang-18 + - name: bootstrap + run: ./bootstrap.sh + - name: configure + run: ./configure CXX=clang++-18 + - name: build + run: make + - name: check + run: make check + - name: store the logs as an artifact + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + path: '**/*.log' diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index cc7b490..1c83bb2 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,3 +1,4 @@ +--- # For most projects, this workflow file will not need changing; you simply need # to commit it to your repository. # @@ -11,12 +12,12 @@ # name: "CodeQL" -on: +"on": push: - branches: [ "main", "devel" ] + branches: ["main", "devel"] pull_request: # The branches below must be a subset of the branches above - branches: [ "main", "devel" ] + branches: ["main", "devel"] schedule: - cron: '39 4 * * 0' @@ -32,39 +33,40 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'cpp' ] + language: ['cpp'] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ] # Use only 'java' to analyze code written in Java, Kotlin or both # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install autoconf autoconf-archive nettle-dev build-essential g++ -y + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install autoconf autoconf-archive nettle-dev build-essential g++ -y - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. - # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - name: Build - run: | - ./bootstrap.sh - ./configure - make + # For more details on CodeQL's query packs, refer to: + # https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + - name: Build + run: | + ./bootstrap.sh + ./configure + make - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/cppcheck.yml b/.github/workflows/cppcheck.yml index bd2bccd..8ac7f10 100644 --- a/.github/workflows/cppcheck.yml +++ b/.github/workflows/cppcheck.yml @@ -1,6 +1,7 @@ +--- name: cppcheck -on: +"on": push: branches: - main @@ -14,15 +15,14 @@ jobs: runs-on: ubuntu-20.04 steps: - - name: checkout - uses: actions/checkout@v4 - - name: install packages - run: sudo apt install cppcheck - - name: run cppcheck - run: cppcheck/run_cppcheck.sh - - name: store the cppcheck output as an artifact - if: ${{ always() }} - uses: actions/upload-artifact@v4 - with: - path: 'cppcheck/out/*' - + - name: checkout + uses: actions/checkout@v4 + - name: install packages + run: sudo apt install cppcheck + - name: run cppcheck + run: cppcheck/run_cppcheck.sh + - name: store the cppcheck output as an artifact + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + path: 'cppcheck/out/*' diff --git a/.github/workflows/debian-bookworm.yml b/.github/workflows/debian-bookworm.yml index 06d0f84..c189d0c 100644 --- a/.github/workflows/debian-bookworm.yml +++ b/.github/workflows/debian-bookworm.yml @@ -1,6 +1,7 @@ +--- name: debian 12 bookworm -on: +"on": push: branches: - main @@ -14,29 +15,29 @@ jobs: container: image: debian:bookworm-slim steps: - - name: checkout - uses: actions/checkout@v4 - - name: install packages - run: apt-get update && apt-get install autoconf build-essential nettle-dev libcap2-bin --yes - - name: bootstrap - run: ./bootstrap.sh - - name: configure - run: ./configure --enable-warnings CXXFLAGS=-std=c++17 - - name: make - run: make - - name: make check - run: make check - - name: make distcheck - run: make distcheck CXXFLAGS=-std=c++17 - - name: build with hardened build flags - run: | - make clean - eval $(DEB_CXXFLAGS_APPEND=-std=c++17 DEB_BUILD_MAINT_OPTIONS="hardening=+all qa=+all,-canary reproducible=+all" dpkg-buildflags --export=sh) - ./configure - make - make check - - name: store the logs as an artifact - if: ${{ always() }} - uses: actions/upload-artifact@v4 - with: - path: '**/*.log' + - name: checkout + uses: actions/checkout@v4 + - name: install packages + run: apt-get update && apt-get install autoconf build-essential nettle-dev libcap2-bin --yes + - name: bootstrap + run: ./bootstrap.sh + - name: configure + run: ./configure --enable-warnings CXXFLAGS=-std=c++17 + - name: make + run: make + - name: make check + run: make check + - name: make distcheck + run: make distcheck CXXFLAGS=-std=c++17 + - name: build with hardened build flags + run: | + make clean + eval $(DEB_CXXFLAGS_APPEND=-std=c++17 DEB_BUILD_MAINT_OPTIONS="hardening=+all qa=+all,-canary reproducible=+all" dpkg-buildflags --export=sh) + ./configure + make + make check + - name: store the logs as an artifact + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + path: '**/*.log' diff --git a/.github/workflows/debian-bullseye.yml b/.github/workflows/debian-bullseye.yml index f1087bb..7501383 100644 --- a/.github/workflows/debian-bullseye.yml +++ b/.github/workflows/debian-bullseye.yml @@ -1,6 +1,7 @@ +--- name: debian 11 bullseye -on: +"on": push: branches: - main @@ -14,29 +15,29 @@ jobs: container: image: debian:bullseye-slim steps: - - name: checkout - uses: actions/checkout@v4 - - name: install packages - run: apt-get update && apt-get install autoconf build-essential nettle-dev libcap2-bin --yes - - name: bootstrap - run: ./bootstrap.sh - - name: configure - run: ./configure --enable-warnings CXXFLAGS=-std=c++17 - - name: make - run: make - - name: make check - run: make check - - name: make distcheck - run: make distcheck CXXFLAGS=-std=c++17 - - name: build with hardened build flags - run: | - make clean - eval $(DEB_CXXFLAGS_APPEND=-std=c++17 DEB_BUILD_MAINT_OPTIONS="hardening=+all qa=+all,-canary reproducible=+all" dpkg-buildflags --export=sh) - ./configure - make - make check - - name: store the logs as an artifact - if: ${{ always() }} - uses: actions/upload-artifact@v4 - with: - path: '**/*.log' + - name: checkout + uses: actions/checkout@v4 + - name: install packages + run: apt-get update && apt-get install autoconf build-essential nettle-dev libcap2-bin --yes + - name: bootstrap + run: ./bootstrap.sh + - name: configure + run: ./configure --enable-warnings CXXFLAGS=-std=c++17 + - name: make + run: make + - name: make check + run: make check + - name: make distcheck + run: make distcheck CXXFLAGS=-std=c++17 + - name: build with hardened build flags + run: | + make clean + eval $(DEB_CXXFLAGS_APPEND=-std=c++17 DEB_BUILD_MAINT_OPTIONS="hardening=+all qa=+all,-canary reproducible=+all" dpkg-buildflags --export=sh) + ./configure + make + make check + - name: store the logs as an artifact + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + path: '**/*.log' diff --git a/.github/workflows/debian-trixie.yml b/.github/workflows/debian-trixie.yml index f13b320..6a31b2b 100644 --- a/.github/workflows/debian-trixie.yml +++ b/.github/workflows/debian-trixie.yml @@ -1,6 +1,7 @@ +--- name: debian 13 trixie -on: +"on": push: branches: - main @@ -14,29 +15,29 @@ jobs: container: image: debian:trixie-slim steps: - - name: checkout - uses: actions/checkout@v4 - - name: install packages - run: apt-get update && apt-get install autoconf build-essential nettle-dev libcap2-bin --yes - - name: bootstrap - run: ./bootstrap.sh - - name: configure - run: ./configure --enable-warnings CXXFLAGS=-std=c++17 - - name: make - run: make - - name: make check - run: make check - - name: make distcheck - run: make distcheck CXXFLAGS=-std=c++17 - - name: build with hardened build flags - run: | - make clean - eval $(DEB_CXXFLAGS_APPEND=-std=c++17 DEB_BUILD_MAINT_OPTIONS="hardening=+all qa=+all,-canary reproducible=+all" dpkg-buildflags --export=sh) - ./configure - make - make check - - name: store the logs as an artifact - if: ${{ always() }} - uses: actions/upload-artifact@v4 - with: - path: '**/*.log' + - name: checkout + uses: actions/checkout@v4 + - name: install packages + run: apt-get update && apt-get install autoconf build-essential nettle-dev libcap2-bin --yes + - name: bootstrap + run: ./bootstrap.sh + - name: configure + run: ./configure --enable-warnings CXXFLAGS=-std=c++17 + - name: make + run: make + - name: make check + run: make check + - name: make distcheck + run: make distcheck CXXFLAGS=-std=c++17 + - name: build with hardened build flags + run: | + make clean + eval $(DEB_CXXFLAGS_APPEND=-std=c++17 DEB_BUILD_MAINT_OPTIONS="hardening=+all qa=+all,-canary reproducible=+all" dpkg-buildflags --export=sh) + ./configure + make + make check + - name: store the logs as an artifact + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + path: '**/*.log' diff --git a/.github/workflows/deterministic.yml b/.github/workflows/deterministic.yml index 9cf4ef1..e13c13a 100644 --- a/.github/workflows/deterministic.yml +++ b/.github/workflows/deterministic.yml @@ -1,6 +1,7 @@ +--- name: test deterministic operation -on: +"on": push: branches: - main @@ -14,21 +15,20 @@ jobs: runs-on: ubuntu-24.04 steps: - - name: checkout - uses: actions/checkout@v4 - - name: install packages - run: sudo apt install build-essential nettle-dev time disorderfs - - name: bootstrap - run: ./bootstrap.sh - - name: configure - run: ./configure CXXFLAGS=-std=c++17 - - name: make - run: make - - name: run determinism test - run: testcases/verify_deterministic_operation.sh - - name: store logs as artifacts - if: ${{ always() }} - uses: actions/upload-artifact@v4 - with: - path: '**/*.log' - + - name: checkout + uses: actions/checkout@v4 + - name: install packages + run: sudo apt install build-essential nettle-dev time disorderfs + - name: bootstrap + run: ./bootstrap.sh + - name: configure + run: ./configure CXXFLAGS=-std=c++17 + - name: make + run: make + - name: run determinism test + run: testcases/verify_deterministic_operation.sh + - name: store logs as artifacts + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + path: '**/*.log' diff --git a/.github/workflows/fedora-40.yml b/.github/workflows/fedora-40.yml index ebc004d..e6d159f 100644 --- a/.github/workflows/fedora-40.yml +++ b/.github/workflows/fedora-40.yml @@ -1,6 +1,7 @@ +--- name: fedora 40 -on: +"on": push: branches: - main @@ -14,22 +15,22 @@ jobs: container: image: fedora:40 steps: - - name: checkout - uses: actions/checkout@v4 - - name: install packages - run: yes | dnf install automake gcc which g++ nettle-devel - - name: bootstrap - run: ./bootstrap.sh - - name: configure - run: ./configure --enable-warnings CXXFLAGS=-std=c++17 - - name: make - run: make -j $(nproc) - - name: make check - run: make check - - name: make distcheck - run: make distcheck CXXFLAGS=-std=c++17 - - name: store the logs as an artifact - if: ${{ always() }} - uses: actions/upload-artifact@v4 - with: - path: '**/*.log' + - name: checkout + uses: actions/checkout@v4 + - name: install packages + run: yes | dnf install automake gcc which g++ nettle-devel + - name: bootstrap + run: ./bootstrap.sh + - name: configure + run: ./configure --enable-warnings CXXFLAGS=-std=c++17 + - name: make + run: make -j $(nproc) + - name: make check + run: make check + - name: make distcheck + run: make distcheck CXXFLAGS=-std=c++17 + - name: store the logs as an artifact + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + path: '**/*.log' diff --git a/.github/workflows/fedora-41.yml b/.github/workflows/fedora-41.yml index 572ad5c..6e634be 100644 --- a/.github/workflows/fedora-41.yml +++ b/.github/workflows/fedora-41.yml @@ -1,6 +1,7 @@ +--- name: fedora 41 -on: +"on": push: branches: - main @@ -14,22 +15,22 @@ jobs: container: image: fedora:41 steps: - - name: checkout - uses: actions/checkout@v4 - - name: install packages - run: yes | dnf install automake gcc which g++ nettle-devel - - name: bootstrap - run: ./bootstrap.sh - - name: configure - run: ./configure --enable-warnings CXXFLAGS=-std=c++17 - - name: make - run: make -j $(nproc) - - name: make check - run: make check - - name: make distcheck - run: make distcheck CXXFLAGS=-std=c++17 - - name: store the logs as an artifact - if: ${{ always() }} - uses: actions/upload-artifact@v4 - with: - path: '**/*.log' + - name: checkout + uses: actions/checkout@v4 + - name: install packages + run: yes | dnf install automake gcc which g++ nettle-devel + - name: bootstrap + run: ./bootstrap.sh + - name: configure + run: ./configure --enable-warnings CXXFLAGS=-std=c++17 + - name: make + run: make -j $(nproc) + - name: make check + run: make check + - name: make distcheck + run: make distcheck CXXFLAGS=-std=c++17 + - name: store the logs as an artifact + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + path: '**/*.log' diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index 224cce3..06adf1b 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -1,6 +1,7 @@ +--- name: code formatting -on: +"on": push: branches: - main @@ -14,30 +15,29 @@ jobs: runs-on: ubuntu-24.04 steps: - - name: checkout - uses: actions/checkout@v4 - - name: install packages - run: sudo apt install clang-18 - - name: run clang format - run: | - ./do_clang_format.sh - - name: check for differences - run: | - git diff >clang-format.patch - if [ $(wc -c clang-format.patch + if [ $(wc -c