#!/bin/sh # # Check that size arguments are processed correctly. # Allow all tests to be skipped, e.g. during a release build test "${SKIP_ALL_TESTS}" = "1" && exit 77 true "${testSubject:?not set - call this from 'make check'}" # Pass size argument $1 and check that the last reported number is $2. checkSizeArgument () { reportedCount=$("${testSubject}" -XfnbSs "$1" /dev/zero 2>&1 | sed -n '$p' | tr -dc '0-9') if ! test "${reportedCount}" = "$2"; then echo "passed size argument $1, expected count of $2, but got ${reportedCount}" exit 1 fi } checkSizeArgument 10000 10000 checkSizeArgument 1k 1024 checkSizeArgument 1M 1048576 checkSizeArgument 8G 8589934592 exit 0