Files
managed-container/tests/test-entrypoint-structure.sh
T

47 lines
827 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT="$(
cd "$(dirname "${BASH_SOURCE[0]}")/.." &&
pwd
)"
ENTRYPOINT="$ROOT/ocf/loxthelion/managed-container"
if [[ ! -x "$ENTRYPOINT" ]]; then
echo "ERROR: managed-container entrypoint is missing or not executable" >&2
exit 1
fi
echo "===== SYNTAX ====="
bash -n "$ENTRYPOINT"
while IFS= read -r -d '' file; do
bash -n "$file"
done < <(
find "$ROOT/ocf/loxthelion/managed-container.d" \
-type f \
-name '*.sh' \
-print0
)
echo "SYNTAX_OK=1"
echo
echo "===== REAL ENTRYPOINT LOAD TEST ====="
output="$(
env \
OCF_ROOT="${OCF_ROOT:-/usr/lib/ocf}" \
MC_ENTRYPOINT_SELFTEST=1 \
"$ENTRYPOINT"
)"
printf '%s\n' "$output"
grep -qx 'ENTRYPOINT_STRUCTURE_OK=1' <<<"$output"
echo
echo "ENTRYPOINT_TEST_PASS=1"