diff --git a/run.sh b/run.sh index 76d8205..9200bb1 100755 --- a/run.sh +++ b/run.sh @@ -2,5 +2,5 @@ set -o pipefail -o nounset -o errexit -echo "${crond_line}" > "/etc/crontabs/root" +echo "${crond_line:-}" > "/etc/crontabs/root" crond -f -L /dev/stdout diff --git a/tests/test.sh b/tests/test.sh index 7905058..324e10a 100644 --- a/tests/test.sh +++ b/tests/test.sh @@ -11,8 +11,13 @@ CONTAINER_NAME="test-crond-$$" # Test 1: Container starts and crond is running docker run -d --name "$CONTAINER_NAME" "$IMAGE" -sleep 3 -if docker exec "$CONTAINER_NAME" pgrep crond > /dev/null 2>&1; then +sleep 4 +if [ "$(docker inspect "$CONTAINER_NAME" --format='{{.State.Running}}')" != "true" ]; then + echo "FAIL: container exited prematurely" + echo "=== Container logs ===" + docker logs "$CONTAINER_NAME" 2>&1 || true + FAILED=$((FAILED + 1)) +elif docker exec "$CONTAINER_NAME" pgrep crond > /dev/null 2>&1; then echo "PASS: crond is running" PASSED=$((PASSED + 1)) else