summaryrefslogtreecommitdiffstats
path: root/tests/grub_cmd_date.in
blob: f7c9ca00432fa3307a2fb53ac88ca11115d7f73f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! @BUILD_SHEBANG@
set -e

. "@builddir@/grub-core/modinfo.sh"

# FIXME: OpenBIOS on sparc64 doesn't implement RTC
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = sparc64-ieee1275 ]; then
    exit 0
fi

pdt="$(date -u +%s)"
dt=`echo date | @builddir@/grub-shell | sed 's, [A-Z][a-z]*$,,'`
dtg="$(date -u -d "$dt" +%s)"
ndt="$(date -u +%s)"

if [ $pdt -gt $dtg ] || [ $dtg -gt $ndt ]; then
  echo "Date not in range: $pdt <= $dtg <= $ndt"
  exit 1
fi

pdt="$(date -u +%s)"
dt=`echo 'insmod datehook; echo $YEAR-$MONTH-$DAY $HOUR:$MINUTE:$SECOND' | @builddir@/grub-shell`
dtg="$(date -u -d "$dt" +%s)"
ndt="$(date -u +%s)"

if [ $pdt -gt $dtg ] || [ $dtg -gt $ndt ]; then
  echo "Date not in range: $pdt <= $dtg <= $ndt"
  exit 1
fi