Major restructuring to switch build system from old scripts to GNU Automake.
This commit is contained in:
Regular → Executable
Regular → Executable
Regular → Executable
+2
-20
@@ -8,7 +8,7 @@ testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
makeDir="${testSubject%/*}"
|
||||
if ! test -d "${makeDir}"; then
|
||||
echo "could not find the directory to run \`make' in"
|
||||
exit 2
|
||||
exit 77
|
||||
fi
|
||||
|
||||
makeCommand=$(command -v gmake 2>/dev/null)
|
||||
@@ -17,7 +17,7 @@ test -z "${makeCommand}" && makeCommand="make"
|
||||
testInstallDir=$(mktemp -d)
|
||||
if ! test -n "${testInstallDir}"; then
|
||||
echo "failed to create temporary installation directory"
|
||||
exit 2
|
||||
exit 77
|
||||
fi
|
||||
|
||||
export DESTDIR="${testInstallDir}"
|
||||
@@ -37,24 +37,6 @@ if ! find "${testInstallDir}" -type f -name "pv*" | grep -Fv "pv.1" | grep -Fq "
|
||||
exitStatus=1
|
||||
fi
|
||||
|
||||
# Only check for message catalogue files if any were defined in the Makefile.
|
||||
if grep "^CATALOGS" "${makeDir}/Makefile" 2>/dev/null | cut -d = -f 2 | grep -Fq .mo; then
|
||||
if ! find "${testInstallDir}" -type f -name "*.mo" | grep -Fq ".mo"; then
|
||||
echo "installation of localisation files failed"
|
||||
exitStatus=1
|
||||
fi
|
||||
else
|
||||
# There should always be some message catalogue files defined, if
|
||||
# msgfmt is available.
|
||||
if command -v msgfmt >/dev/null 2>&1 || command -v gmsgfmt >/dev/null 2>&1; then
|
||||
echo "no localisation files defined in the Makefile (\$CATALOGS is empty)"
|
||||
exitStatus=1
|
||||
else
|
||||
echo "no \`msgfmt', so no localisation files installed"
|
||||
test "${exitStatus}" = 0 && exitStatus=2
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -rf "${testInstallDir}"
|
||||
exit "${exitStatus}"
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+1
-1
@@ -8,7 +8,7 @@ testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
# Check we can run "kill -s 0".
|
||||
if ! kill -s 0 $$ >/dev/null 2>&1; then
|
||||
echo "cannot check process existence with \`kill -s 0'"
|
||||
exit 2
|
||||
exit 77
|
||||
fi
|
||||
|
||||
dd if=/dev/zero bs=150 count=1 2>/dev/null \
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+3
-3
@@ -11,7 +11,7 @@ workFile1FreeKiB=$(df -kP "${workFile1Dir}" | sed -n '$p' | awk '{print $(NF-2)}
|
||||
test -n "${workFile1FreeKiB}" || workFile1FreeKiB=0
|
||||
if ! test "${workFile1FreeKiB}" -gt 3300000 2>/dev/null; then
|
||||
echo "test requires at least 3GB free on ${workFile1Dir}"
|
||||
exit 2
|
||||
exit 77
|
||||
fi
|
||||
|
||||
# Generate a 3GB sparse file - we don't really need 3GB of free space unless
|
||||
@@ -19,7 +19,7 @@ fi
|
||||
true > "${workFile1}"
|
||||
if ! dd if="/dev/zero" of="${workFile1}" count=1 bs=1048576 seek=3072 2>/dev/null; then
|
||||
echo "failed to create 3GB specimen file"
|
||||
exit 2
|
||||
exit 77
|
||||
fi
|
||||
|
||||
# NB the "stat" command is not portable - BSD stat(1) has a different syntax
|
||||
@@ -29,7 +29,7 @@ fileSize=$(ls -nl "${workFile1}" 2>/dev/null | awk '{print $5}')
|
||||
test -n "${fileSize}" || fileSize=0
|
||||
if ! test "${fileSize}" -gt 3000000; then
|
||||
echo "failed to validate specimen file size"
|
||||
exit 2
|
||||
exit 77
|
||||
fi
|
||||
|
||||
# Transfer the file, and count how many bytes came through.
|
||||
Regular → Executable
+1
-1
@@ -19,7 +19,7 @@ done
|
||||
# Check that it really is GNU head, and skip the test if not.
|
||||
if ! echo | "${HEAD}" -c 10 >/dev/null 2>&1; then
|
||||
echo "GNU \`head' is required"
|
||||
exit 2
|
||||
exit 77
|
||||
fi
|
||||
|
||||
# Don't use dd. See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=324308
|
||||
Regular → Executable
+1
-1
@@ -9,7 +9,7 @@ testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2=
|
||||
# Do nothing if IPC is not supported.
|
||||
if ! "${testSubject}" -h 2>/dev/null | grep -Eq "^ -R,"; then
|
||||
echo "IPC is not supported on this platform"
|
||||
exit 2
|
||||
exit 77
|
||||
fi
|
||||
|
||||
# Generate some data.
|
||||
Regular → Executable
+1
-1
@@ -7,7 +7,7 @@
|
||||
sourcePath="${sourcePath:-.}"; testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"; workFile3="${workFile3:-.tmp3}"; workFile4="${workFile4:-.tmp4}"
|
||||
|
||||
# Load the valgrind function.
|
||||
. "${sourcePath}/autoconf/scripts/run-valgrind.sh"
|
||||
. "${sourcePath}/tests/run-valgrind.sh"
|
||||
|
||||
# Plain, no options.
|
||||
{ echo "testing" | runWithValgrind >/dev/null 2>&1; } 4>&1 || exit 1
|
||||
Regular → Executable
+2
-2
@@ -8,11 +8,11 @@ sourcePath="${sourcePath:-.}"; testSubject="${testSubject:-false}"; workFile1="$
|
||||
# Do nothing if IPC is not supported.
|
||||
if ! "${testSubject}" -h 2>/dev/null | grep -Eq "^ -R,"; then
|
||||
echo "IPC is not supported on this platform"
|
||||
exit 2
|
||||
exit 77
|
||||
fi
|
||||
|
||||
# Load the valgrind function.
|
||||
. "${sourcePath}/autoconf/scripts/run-valgrind.sh"
|
||||
. "${sourcePath}/tests/run-valgrind.sh"
|
||||
|
||||
dd if=/dev/urandom of="${workFile1}" bs=1024 count=10240 2>/dev/null
|
||||
|
||||
Regular → Executable
+2
-2
@@ -9,11 +9,11 @@ sourcePath="${sourcePath:-.}"; testSubject="${testSubject:-false}"; workFile1="$
|
||||
# Do nothing if IPC is not supported.
|
||||
if ! "${testSubject}" -h 2>/dev/null | grep -Eq "^ -R,"; then
|
||||
echo "IPC is not supported on this platform"
|
||||
exit 2
|
||||
exit 77
|
||||
fi
|
||||
|
||||
# Load the valgrind function.
|
||||
. "${sourcePath}/autoconf/scripts/run-valgrind.sh"
|
||||
. "${sourcePath}/tests/run-valgrind.sh"
|
||||
|
||||
dd if=/dev/urandom of="${workFile1}" bs=1024 count=10240 2>/dev/null
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+3
-3
@@ -8,13 +8,13 @@ testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2=
|
||||
# Skip the test if `tmux' is not available.
|
||||
if ! command -v tmux >/dev/null 2>&1; then
|
||||
echo "test requires \`tmux'"
|
||||
exit 2
|
||||
exit 77
|
||||
fi
|
||||
|
||||
# Skip the test if `tmux' does not have "-C".
|
||||
if echo "kill-server" | tmux -C -L pvtest 2>&1 | grep -Fq "tmux: unknown option"; then
|
||||
echo "test requires a newer \`tmux'"
|
||||
exit 2
|
||||
exit 77
|
||||
fi
|
||||
|
||||
# Run the given command $3 inside a terminal of the given width $1, waiting
|
||||
@@ -76,7 +76,7 @@ checkSize="100"
|
||||
detectedWidth=$(runInTerminal "${checkSize}" 1 "stty -a | tr \\\";\\\" \\\"\\\\n\\\" | grep col | sed -n 1p | tr -dc 0-9")
|
||||
if ! test "${detectedWidth}" = "${checkSize}"; then
|
||||
echo "test requires a \`tmux' that can resize a detached window (requested width ${checkSize}, detected ${detectedWidth})"
|
||||
exit 2
|
||||
exit 77
|
||||
fi
|
||||
|
||||
# Test the progress bar width at various terminal sizes.
|
||||
Regular → Executable
Regular → Executable
+1
-1
@@ -8,7 +8,7 @@ testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2=
|
||||
# Do nothing if IPC is not supported.
|
||||
if ! "${testSubject}" -h 2>/dev/null | grep -Eq "^ -R,"; then
|
||||
echo "IPC is not supported on this platform"
|
||||
exit 2
|
||||
exit 77
|
||||
fi
|
||||
|
||||
# Generate an empty test file.
|
||||
Regular → Executable
Executable
+61
@@ -0,0 +1,61 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Function to launch the test subject under valgrind.
|
||||
#
|
||||
# If valgrind is unavailable, exits the script with status 77, after writing
|
||||
# a note to file descriptor 4.
|
||||
#
|
||||
# If valgrind finds an error, writes the error to "valgrind.out" in the
|
||||
# current directory, and exits the script with status 1 after writing a note
|
||||
# to file descriptor 4.
|
||||
#
|
||||
# If valgrind does not find any errors, the function returns with the exit
|
||||
# status of the test subject.
|
||||
#
|
||||
# Source this file from test scripts that use valgrind.
|
||||
#
|
||||
# Requires ${testSubject} and ${workFile4}. This means that the caller must
|
||||
# not use file ${workFile4}, as this function will overwrite it.
|
||||
#
|
||||
|
||||
# Output file for failures.
|
||||
valgrindOutputFile="valgrind.out"
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile4="${workFile4:-.tmp4}"
|
||||
|
||||
if ! command -v valgrind >/dev/null 2>&1; then
|
||||
echo "test requires \`valgrind'"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
runWithValgrind () {
|
||||
|
||||
valgrind --tool=memcheck \
|
||||
--verbose --show-error-list=yes --log-fd=3 \
|
||||
--error-exitcode=125 \
|
||||
--track-fds=yes \
|
||||
--leak-check=full \
|
||||
"${testSubject}" "$@" \
|
||||
3>"${workFile4}" 4<&-
|
||||
|
||||
returnValue=$?
|
||||
|
||||
if test "${returnValue}" -eq 125; then
|
||||
{
|
||||
echo "================================================"
|
||||
date
|
||||
echo "Command: ${testSubject} $*"
|
||||
echo
|
||||
cat "${workFile4}"
|
||||
echo "================================================"
|
||||
echo
|
||||
} >> "${valgrindOutputFile}"
|
||||
echo "memory check failed - see file \`valgrind.out'." 1>&4
|
||||
exit 1
|
||||
fi
|
||||
|
||||
return "${returnValue}"
|
||||
}
|
||||
|
||||
# EOF
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Set up the environment variables, temporary working files, and cleanup
|
||||
# processes required to run each test.
|
||||
#
|
||||
# Tests must exit with 0 for success, 1 for failure, 77 to skip the test, or
|
||||
# 99 for a fatal error with the test framework.
|
||||
|
||||
# Parameters.
|
||||
testSubject="./pv"
|
||||
sourcePath="${srcdir}"
|
||||
|
||||
# Set everything to the "C" locale.
|
||||
LANG=C
|
||||
LC_ALL=C
|
||||
export LANG LC_ALL
|
||||
|
||||
# Temporary working files, for the test scripts to use.
|
||||
workFile1=$(mktemp 2>/dev/null) || workFile1="./.tmp1"
|
||||
workFile2=$(mktemp 2>/dev/null) || workFile2="./.tmp2"
|
||||
workFile3=$(mktemp 2>/dev/null) || workFile3="./.tmp3"
|
||||
workFile4=$(mktemp 2>/dev/null) || workFile4="./.tmp4"
|
||||
|
||||
# Clean up the temporary files on exit, in case we are interrupted.
|
||||
trap 'rm -f "${workFile1}" "${workFile2}" "${workFile3}" "${workFile4}"' EXIT
|
||||
|
||||
# Variables used by the test scripts.
|
||||
export testSubject sourcePath workFile1 workFile2 workFile3 workFile4
|
||||
Reference in New Issue
Block a user