Debian Codegraph @

debian/tests/day-month-out-of-bounds

raw
1 #! /bin/sh
2
3 set -e
4
5 dir=$(pwd)/debian/tests
6 . $dir/textutils.sh
7
8 frame "Here we are testing the bounds allowed" \
9 "for day of month and month fields, as stated in crontab(5)"
10
11 echo "================= adding user 'dummy' ====================="
12 getent passwd dummy || adduser --disabled-password --gecos "" dummy
13
14 frame "make user 'dummy' fill his crontab with dom = 0" \
15 "and check that the error contains 'bad day-of-month'"
16
17 export expected="bad day-of-month"
18 if bad=$(su dummy -c "(export LINES=' * * 0 * * echo hello';
19 echo 'n' | EDITOR=$(pwd)/debian/tests/cronfiller.py crontab -n -e)" 2>&1 \
20 | grep "$expected")
21 then
22 if echo "$bad" | grep -q "$expected"; then
23 echo OK
24 else
25 echo "The response '$bad' was not expected"
26 fi
27 else
28 echo "a crontab with dom = 0 has raised the error $?"
29 fi
30
31 frame "make user 'dummy' fill his crontab with dom = 31" \
32 "and check that the error contains 'bad day-of-month'"
33
34 export expected="bad day-of-month"
35 if bad=$(su dummy -c "(export LINES=' * * 0 * * echo hello';
36 echo 'n' | EDITOR=$(pwd)/debian/tests/cronfiller.py crontab -n -e)" 2>&1 \
37 | grep "$expected")
38 then
39 if echo "$bad" | grep -q "$expected"; then
40 echo OK
41 else
42 echo "The response '$bad' was not expected"
43 fi
44 else
45 echo "a crontab with dom = 31 has raised the error $?"
46 fi
47
48 frame "make user 'dummy' fill his crontab with month = 0" \
49 "and check that the error contains 'bad month'"
50
51 expected="bad month"
52 if bad=$(su dummy -c "(export LINES=' * * * 0 * echo hello';
53 echo 'n' | EDITOR=$(pwd)/debian/tests/cronfiller.py crontab -n -e)" 2>&1 \
54 | grep "$expected")
55 then
56 if echo "$bad" | grep -q "$expected"; then
57 echo OK
58 else
59 echo "The response '$bad' was not expected"
60 fi
61 else
62 echo "a crontab with month = 0 has raised the error $?"
63 fi
64
65
66 frame "make user 'dummy' fill his crontab with month = 13" \
67 "and check that the error contains 'bad month'"
68
69 expected="bad month"
70 if bad=$(su dummy -c "(export LINES=' * * * 13 * echo hello';
71 echo 'n' | EDITOR=$(pwd)/debian/tests/cronfiller.py crontab -n -e)" 2>&1 \
72 | grep "$expected")
73 then
74 if echo "$bad" | grep -q "$expected"; then
75 echo OK
76 else
77 echo "The response '$bad' was not expected"
78 fi
79 else
80 echo "a crontab with month = 0 has raised the error $?"
81 fi