summaryrefslogtreecommitdiff
path: root/release/src/router/busybox/testsuite/date
diff options
context:
space:
mode:
Diffstat (limited to 'release/src/router/busybox/testsuite/date')
-rw-r--r--release/src/router/busybox/testsuite/date/date-R-works1
-rw-r--r--release/src/router/busybox/testsuite/date/date-format-works4
-rw-r--r--release/src/router/busybox/testsuite/date/date-u-works1
-rw-r--r--release/src/router/busybox/testsuite/date/date-works44
-rw-r--r--release/src/router/busybox/testsuite/date/date-works-1129
5 files changed, 179 insertions, 0 deletions
diff --git a/release/src/router/busybox/testsuite/date/date-R-works b/release/src/router/busybox/testsuite/date/date-R-works
new file mode 100644
index 00000000..34cd735e
--- /dev/null
+++ b/release/src/router/busybox/testsuite/date/date-R-works
@@ -0,0 +1 @@
+test x"`date -R`" = x"`busybox date -R`"
diff --git a/release/src/router/busybox/testsuite/date/date-format-works b/release/src/router/busybox/testsuite/date/date-format-works
new file mode 100644
index 00000000..f2a2091c
--- /dev/null
+++ b/release/src/router/busybox/testsuite/date/date-format-works
@@ -0,0 +1,4 @@
+# TODO: gnu date doesn't accept '2000.11.22-11:22:33' format,
+# but accepts '2000-11-22 11:22:33'. We must follow.
+test x"01/01/99" = x"`busybox date -d 1999.01.01-11:22:33 '+%d/%m/%y'`"
+test x"22/11/00" = x"`busybox date -d 2000.11.22-11:22:33 '+%d/%m/%y'`"
diff --git a/release/src/router/busybox/testsuite/date/date-u-works b/release/src/router/busybox/testsuite/date/date-u-works
new file mode 100644
index 00000000..eea6e5ae
--- /dev/null
+++ b/release/src/router/busybox/testsuite/date/date-u-works
@@ -0,0 +1 @@
+test x"Sat Jan 1 11:22:33 UTC 2000" = x"`TZ=CET-1CEST-2 busybox date -u -d 2000.01.01-11:22:33`"
diff --git a/release/src/router/busybox/testsuite/date/date-works b/release/src/router/busybox/testsuite/date/date-works
new file mode 100644
index 00000000..0802e887
--- /dev/null
+++ b/release/src/router/busybox/testsuite/date/date-works
@@ -0,0 +1,44 @@
+dt=`busybox date`
+# Expected format: Fri Apr 25 03:47:55 CEST 2008
+dt=`echo "$dt" | sed 's/^[^ ][^ ][^ ] [^ ][^ ][^ ] [ 0123][0-9] [012][0-9]:[0-5][0-9]:[0-6][0-9] [A-Z][A-Z]* [012][0-9][0-9][0-9]$/OK/'`
+test x"$dt" = x"OK"
+
+dt=`busybox date -d 1:2`
+dt=`echo "$dt" | cut -b12-19`
+test x"$dt" = x"01:02:00"
+
+dt=`busybox date -d 1:2:3`
+dt=`echo "$dt" | cut -b12-19`
+test x"$dt" = x"01:02:03"
+
+dt=`busybox date -d 1.2-3:4`
+dt=`echo "$dt" | cut -b5-19`
+test x"$dt" = x"Jan 2 03:04:00"
+
+dt=`busybox date -d 1.2-3:4:5`
+dt=`echo "$dt" | cut -b5-19`
+test x"$dt" = x"Jan 2 03:04:05"
+
+dt=`busybox date -d 1999.1.2-3:4`
+dt=`echo "$dt" | cut -b1-19`
+test x"$dt" = x"Sat Jan 2 03:04:00"
+
+dt=`busybox date -d 1999.1.2-3:4:5`
+dt=`echo "$dt" | cut -b1-19`
+test x"$dt" = x"Sat Jan 2 03:04:05"
+
+dt=`busybox date -d '1999-1-2 3:4:5'`
+dt=`echo "$dt" | cut -b1-19`
+test x"$dt" = x"Sat Jan 2 03:04:05"
+
+dt=`busybox date -d 01231133`
+dt=`echo "$dt" | cut -b5-19`
+test x"$dt" = x"Jan 23 11:33:00"
+
+dt=`busybox date -d 012311332000`
+dt=`echo "$dt" | cut -b1-19`
+test x"$dt" = x"Sun Jan 23 11:33:00"
+
+dt=`busybox date -d 012311332000.30`
+dt=`echo "$dt" | cut -b1-19`
+test x"$dt" = x"Sun Jan 23 11:33:30"
diff --git a/release/src/router/busybox/testsuite/date/date-works-1 b/release/src/router/busybox/testsuite/date/date-works-1
new file mode 100644
index 00000000..e318944d
--- /dev/null
+++ b/release/src/router/busybox/testsuite/date/date-works-1
@@ -0,0 +1,129 @@
+dt=`busybox date -d 1:2 +%T`
+test x"$dt" = x"01:02:00"
+
+dt=`busybox date -d 1:2:3 +%T`
+test x"$dt" = x"01:02:03"
+
+host_date=/bin/date
+
+# date (GNU coreutils) 6.10 reports:
+# date: invalid date '1.2-3:4'
+# busybox 1.11.0.svn date reports:
+# date: invalid date '1/2 3:4'
+
+# TODO: (1) compare with strings, not "host date"
+# (2) implement d/m[/y] hh:mm[:ss] fmt in date applet
+#hdt=`$host_date -d '1/2 3:4'`
+#dt=`busybox date -d 1.2-3:4`
+#test x"$hdt" = x"$dt"
+
+#hdt=`$host_date -d '1/2 3:4:5'`
+#dt=`busybox date -d 1.2-3:4:5`
+#test x"$hdt" = x"$dt"
+
+#hdt=`$host_date -d '1/2/1999 3:4'`
+#dt=`busybox date -d 1999.1.2-3:4`
+#test x"$hdt" = x"$dt"
+
+#hdt=`$host_date -d '1/2/1999 3:4:5'`
+#dt=`busybox date -d 1999.1.2-3:4:5`
+#test x"$hdt" = x"$dt"
+
+hdt=`$host_date -d '1999-1-2 3:4:5'`
+dt=`busybox date -d '1999-1-2 3:4:5'`
+test x"$hdt" = x"$dt"
+
+# Avoiding using week day in this evaluation, as it's mostly different every year
+# date (GNU coreutils) 6.10 reports:
+# date: invalid date '01231133'
+dt=`busybox date -d 01231133 +%c`
+dt=`echo "$dt" | cut -b5-19`
+test x"$dt" = x"Jan 23 11:33:00"
+
+# date (GNU coreutils) 6.10 reports:
+# date: invalid date '012311332000'
+dt=`busybox date -d 012311332000 +%c`
+test x"$dt" = x"Sun Jan 23 11:33:00 2000"
+
+# date (GNU coreutils) 6.10 reports:
+# date: invalid date '012311332000'
+dt=`busybox date -d 012311332000.30 +%c`
+test x"$dt" = x"Sun Jan 23 11:33:30 2000"
+
+lcbbd="LC_ALL=C busybox date"
+wd=$(eval $lcbbd +%a) # weekday name
+mn=$(eval $lcbbd +%b) # month name
+dm=$(eval $lcbbd +%e) # day of month, space padded
+h=$(eval $lcbbd +%H) # hour, zero padded
+m=$(eval $lcbbd +%M) # minute, zero padded
+s=$(eval $lcbbd +%S) # second, zero padded
+z=$(eval $lcbbd -u +%Z) # time zone abbreviation
+y=$(eval $lcbbd +%Y) # year
+
+res=OK
+case $wd in
+ Sun)
+ ;;
+ Mon)
+ ;;
+ Tue)
+ ;;
+ Wed)
+ ;;
+ Thu)
+ ;;
+ Fri)
+ ;;
+ Sat)
+ ;;
+ *)
+ res=BAD
+ ;;
+esac
+
+case $mn in
+ Jan)
+ ;;
+ Feb)
+ ;;
+ Mar)
+ ;;
+ Apr)
+ ;;
+ May)
+ ;;
+ Jun)
+ ;;
+ Jul)
+ ;;
+ Aug)
+ ;;
+ Sep)
+ ;;
+ Oct)
+ ;;
+ Nov)
+ ;;
+ Dec)
+ ;;
+ *)
+ res=BAD
+ ;;
+esac
+
+dm=${dm# *}
+[ $dm -ge 1 ] && [ $dm -le 31 ] || res=BAD
+h=${h#0}
+[ $h -ge 0 ] && [ $h -le 23 ] || res=BAD
+m=${m#0}
+[ $m -ge 0 ] && [ $m -le 59 ] || res=BAD
+s=${s#0}
+[ $s -ge 0 ] && [ $s -le 59 ] || res=BAD
+[ $z = UTC ] || res=BAD
+[ $y -ge 1970 ] || res=BAD
+
+test x"$res" = xOK
+
+# This should error out (by showing usage text). Testing for that
+dt=`busybox date -d 012311332000.30 %+c 2>&1 | head -n 1`
+test x"${dt#BusyBox * multi-call binary}" = x