#! /bin/sh set -e dir=$(pwd)/debian/tests . $dir/textutils.sh frame "Here we are testing the ranges of days and months" \ "for day of week and month fields, as stated in crontab(5)" echo "================= adding user 'dummy' =====================" getent passwd dummy || adduser --disabled-password --gecos "" dummy echo "= make user 'dummy' fill his crontab with month = Jan-Mar =" # stderr is redirected towards stdout so the variable warning can catch it reply=$(su dummy -c "(export LINES=' * * * Jan-Mar * echo hello'; echo 'n' | EDITOR=$(pwd)/debian/tests/cronfiller.py crontab -n -e)" 2>&1 | grep syntax) echo "== check that the reply contains 'successfully checked' ===" expected="successfully checked" (echo "$reply" | grep -q "$expected") || (echo "reply = $reply"; \ echo "The expected success did not occur" >&2) echo "= make user 'dummy' fill his crontab with month = Jan,Mar =" # stderr is redirected towards stdout so the variable warning can catch it reply=$(su dummy -c "(export LINES=' * * * Jan,Mar * echo hello'; echo 'n' | EDITOR=$(pwd)/debian/tests/cronfiller.py crontab -n -e)" 2>&1 | grep syntax) echo "== check that the reply contains 'successfully checked' ===" expected="successfully checked" (echo "$reply" | grep -q "$expected") || (echo "reply = $reply"; \ echo "The expected success did not occur" >&2) echo "== make user 'dummy' fill his crontab with dow = Mon-Wed ==" # stderr is redirected towards stdout so the variable warning can catch it reply=$(su dummy -c "(export LINES=' * * * * Mon-Wed echo hello'; echo 'n' | EDITOR=$(pwd)/debian/tests/cronfiller.py crontab -n -e)" 2>&1 | grep syntax) echo "== check that the reply contains 'successfully checked' ===" expected="successfully checked" (echo "$reply" | grep -q "$expected") || (echo "reply = $reply"; \ echo "The expected success did not occur" >&2) echo "== make user 'dummy' fill his crontab with dow = Mon,Wed ==" # stderr is redirected towards stdout so the variable warning can catch it reply=$(su dummy -c "(export LINES=' * * * * Mon,Wed echo hello'; echo 'n' | EDITOR=$(pwd)/debian/tests/cronfiller.py crontab -n -e)" 2>&1 | grep syntax) echo "== check that the reply contains 'successfully checked' ===" expected="successfully checked" (echo "$reply" | grep -q "$expected") || (echo "reply = $reply"; \ echo "The expected success did not occur" >&2)