| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
exec 2>&1 |
| 4 |
|
| 5 |
test_no_arguments() { |
| 6 |
( pwdx >"${stdoutF}" 2>"${stderrF}" ) |
| 7 |
rtrn=$? |
| 8 |
|
| 9 |
assertEquals "pwdx exit value" "1" "${rtrn}" |
| 10 |
grep 'Usage:' "${stderrF}" > /dev/null |
| 11 |
assertTrue 'usage message' $? |
| 12 |
} |
| 13 |
|
| 14 |
test_my_pid() { |
| 15 |
( pwdx "${myPID}" >"${stdoutF}" 2>"${stderrF}" ) |
| 16 |
rtrn=$? |
| 17 |
|
| 18 |
assertEquals "pwdx exit value" "0" "${rtrn}" |
| 19 |
|
| 20 |
myCWD=$(readlink "/proc/${myPID}/cwd" 2>/dev/null) |
| 21 |
[ -z "${myCWD:-}" ] && startSkipping |
| 22 |
grep -E "^${myPID}: ${myCWD}" "${stdoutF}" > /dev/null |
| 23 |
assertTrue 'pwdx output' $? |
| 24 |
} |
| 25 |
|
| 26 |
oneTimeSetUp() { |
| 27 |
# Define global variables for command output. |
| 28 |
stdoutF="${AUTOPKGTEST_TMP}/stdout" |
| 29 |
stderrF="${AUTOPKGTEST_TMP}/stderr" |
| 30 |
myPID=$$ |
| 31 |
} |
| 32 |
|
| 33 |
setUp() { |
| 34 |
# Truncate the output files. |
| 35 |
cp /dev/null "${stdoutF}" |
| 36 |
cp /dev/null "${stderrF}" |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
# shellcheck disable=SC1091 |
| 41 |
. shunit2 |
| 42 |
|