1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#!/bin/sh
set -e
result=0
# In version 60.1 of this package, there are 22 commands.
# We don't want this test to fail if newer versions don't have
# exactly that count, but we don't also want to miss suddenly
# a bunch of commands disappearing because of a build problem.
# This sounds like a good number to check for:
command_count_threshold=10
commands=$(ndctl --list-cmds) || result=$?
if [ "${result}" -ne "0" ]; then
echo "ERROR: ndctl --list-cmds failed with exit code: ${result}. Output:"
echo "${commands}"
exit "${result}"
fi
echo "Available commands from ndctl --list-cmds:"
echo "${commands}"
lines=$(echo "${commands}" | wc -l)
if [ "${lines}" -lt "${command_count_threshold}" ]; then
echo "ERROR: Something is possibly wrong with --list-cmds' output."
echo "Got less than 10 lines. If that is correct, adjust the threshold"
echo "in this test please."
exit 1
fi
echo "Checking we have a working version command:"
version=$(ndctl version) || result=$?
if [ "${result}" -ne "0" ]; then
echo "ERROR: ndctl version failed with exit code ${result}. Output:"
echo "${version}"
exit "${result}"
fi
if [ -z "${version}" ]; then
echo "ERROR: the version command returned an empty string instead"
echo "of a version string"
exit 1
fi
echo "Version: ${version}"
exit 0
|