summaryrefslogtreecommitdiffstats
path: root/tests/grub_cmd_date.in
diff options
context:
space:
mode:
Diffstat (limited to 'tests/grub_cmd_date.in')
-rw-r--r--tests/grub_cmd_date.in29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/grub_cmd_date.in b/tests/grub_cmd_date.in
new file mode 100644
index 0000000..f7c9ca0
--- /dev/null
+++ b/tests/grub_cmd_date.in
@@ -0,0 +1,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