File: ndctl-commands

package info (click to toggle)
ndctl 82-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,460 kB
  • sloc: ansic: 42,027; sh: 3,974; makefile: 28
file content (45 lines) | stat: -rwxr-xr-x 1,330 bytes parent folder | download | duplicates (5)
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