Date: Mon, 27 Jan 2014 02:03:36 -0800 From: Garrett Cooper <yaneurabeya@gmail.com> To: Julio Merino <julio@meroh.net> Cc: freebsd-testing@freebsd.org, Giorgos Keramidas <keramida@freebsd.org> Subject: [PATCH v2] convert bin/date over to ATF Message-ID: <4A25ADF9-3714-4006-ACB6-F8C745CB38AE@gmail.com> In-Reply-To: <CADyfeQXG6KGwgT1X90Ymr%2BFYnwL74H_G2zBvkgdzEhPospNM8A@mail.gmail.com> References: <6079AD8F-5EBB-431C-A06B-9B51E2729F5A@gmail.com> <B90AA730-B7B8-4F1A-9D07-67861C9A6401@meroh.net> <FA467521-BB53-47C0-BAE1-8BCAE29F922F@gmail.com> <CADyfeQXG6KGwgT1X90Ymr%2BFYnwL74H_G2zBvkgdzEhPospNM8A@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail=_F518CF31-AFAD-4414-BB2B-AB1861E87B42 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 The attached patch incorporates the input from Julio for = converting bin/date/tests over to ATF. Thanks! -Garrett --Apple-Mail=_F518CF31-AFAD-4414-BB2B-AB1861E87B42 Content-Disposition: attachment; filename=convert-bin-date-over-to-atf.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="convert-bin-date-over-to-atf.patch" Content-Transfer-Encoding: 7bit diff --git a/bin/date/tests/Makefile b/bin/date/tests/Makefile index 540008b..cb7a39e 100644 --- a/bin/date/tests/Makefile +++ b/bin/date/tests/Makefile @@ -1,9 +1,7 @@ # $FreeBSD$ -.include <bsd.own.mk> - TESTSDIR= ${TESTSBASE}/bin/date -TAP_TESTS_SH= legacy_test +ATF_TESTS_SH= format_string_functional_test -.include <tap.test.mk> +.include <atf.test.mk> diff --git a/bin/date/tests/format_string_functional_test.sh b/bin/date/tests/format_string_functional_test.sh new file mode 100644 index 0000000..a988fbc --- /dev/null +++ b/bin/date/tests/format_string_functional_test.sh @@ -0,0 +1,559 @@ +# +# Regression tests for date(1) +# +# Submitted by Edwin Groothuis <edwin@FreeBSD.org> +# +# $FreeBSD$ +# + +# +# These two date/times have been chosen carefully, they +# create both the single digit and double/multidigit version of +# the values. +# +# To create a new one, make sure you are using the UTC timezone! +# + +TEST1=3222243 # 1970-02-07 07:04:03 +TEST2=1005600000 # 2001-11-12 21:11:12 + +export LC_ALL=C +export TZ=UTC + +check() +{ + local format_string exp_output_1 exp_output_2 output + + format_string=$1 + exp_output_1=$2 + exp_output_2=$3 + + # If the second sample text for formatted output has not been + # passed, assume it should match exactly the first one. + if [ -z "$exp_output_2" ]; then + exp_output_2=${exp_output_1} + fi + + output=$(date -r ${TEST1} +%${format_string}) + atf_check test "${output}" = "$exp_output_1" + + output=$(date -r ${TEST2} +%${format_string}) + atf_check test "${output}" = "$exp_output_2" +} + +# ---------------------------------------------------------------------- + +atf_test_case A +A_head() +{ + atf_set "descr" "Verifies that 'A' formatting spec works" +} +A_body() +{ + check A Saturday Monday +} + +# ---------------------------------------------------------------------- + +atf_test_case a +a_head() +{ + atf_set "descr" "Verifies that 'a' formatting spec works" +} +a_body() +{ + check a Sat Mon +} + +# ---------------------------------------------------------------------- + +atf_test_case B +B_head() +{ + atf_set "descr" "Verifies that 'B' formatting spec works" +} +B_body() +{ + check B February November +} + +# ---------------------------------------------------------------------- + +atf_test_case b +b_head() +{ + atf_set "descr" "Verifies that 'b' formatting spec works" +} +b_body() +{ + check b Feb Nov +} + +# ---------------------------------------------------------------------- + +atf_test_case C +C_head() +{ + atf_set "descr" "Verifies that 'C' formatting spec works" +} +C_body() +{ + check C 19 20 +} + +# ---------------------------------------------------------------------- + +atf_test_case c +c_head() +{ + atf_set "descr" "Verifies that 'c' formatting spec works" +} +c_body() +{ + check c "Sat Feb 7 07:04:03 1970" "Mon Nov 12 21:20:00 2001" +} + +# ---------------------------------------------------------------------- + +atf_test_case D +D_head() +{ + atf_set "descr" "Verifies that 'D' formatting spec works" +} +D_body() +{ + check D 02/07/70 11/12/01 +} + +# ---------------------------------------------------------------------- + +atf_test_case d +d_head() +{ + atf_set "descr" "Verifies that 'd' formatting spec works" +} +d_body() +{ + check d 07 12 +} + +# ---------------------------------------------------------------------- + +atf_test_case e +e_head() +{ + atf_set "descr" "Verifies that 'e' formatting spec works" +} +e_body() +{ + check e " 7" 12 +} + +# ---------------------------------------------------------------------- + +atf_test_case F +F_head() +{ + atf_set "descr" "Verifies that 'F' formatting spec works" +} +F_body() +{ + check F "1970-02-07" "2001-11-12" +} + +# ---------------------------------------------------------------------- + +atf_test_case G +G_head() +{ + atf_set "descr" "Verifies that 'G' formatting spec works" +} +G_body() +{ + check G 1970 2001 +} + +# ---------------------------------------------------------------------- + +atf_test_case g +g_head() +{ + atf_set "descr" "Verifies that 'g' formatting spec works" +} +g_body() +{ + check g 70 01 +} + +# ---------------------------------------------------------------------- + +atf_test_case H +H_head() +{ + atf_set "descr" "Verifies that 'H' formatting spec works" +} +H_body() +{ + check H 07 21 +} + +# ---------------------------------------------------------------------- + +atf_test_case h +h_head() +{ + atf_set "descr" "Verifies that 'h' formatting spec works" +} +h_body() +{ + check h Feb Nov +} + +# ---------------------------------------------------------------------- + +atf_test_case I +I_head() +{ + atf_set "descr" "Verifies that 'I' formatting spec works" +} +I_body() +{ + check I 07 09 +} + +# ---------------------------------------------------------------------- + +atf_test_case j +j_head() +{ + atf_set "descr" "Verifies that 'j' formatting spec works" +} +j_body() +{ + check j 038 316 +} + +# ---------------------------------------------------------------------- + +atf_test_case k +k_head() +{ + atf_set "descr" "Verifies that 'k' formatting spec works" +} +k_body() +{ + check k " 7" 21 +} + +# ---------------------------------------------------------------------- + +atf_test_case l +l_head() +{ + atf_set "descr" "Verifies that 'l' formatting spec works" +} +l_body() +{ + check l " 7" " 9" +} + +# ---------------------------------------------------------------------- + +atf_test_case M +M_head() +{ + atf_set "descr" "Verifies that 'M' formatting spec works" +} +M_body() +{ + check M 04 20 +} + +# ---------------------------------------------------------------------- + +atf_test_case m +m_head() +{ + atf_set "descr" "Verifies that 'm' formatting spec works" +} +m_body() +{ + check m 02 11 +} + +# ---------------------------------------------------------------------- + +atf_test_case p +p_head() +{ + atf_set "descr" "Verifies that 'p' formatting spec works" +} +p_body() +{ + check p AM PM +} + +# ---------------------------------------------------------------------- + +atf_test_case R +R_head() +{ + atf_set "descr" "Verifies that 'R' formatting spec works" +} +R_body() +{ + check R 07:04 21:20 +} + +# ---------------------------------------------------------------------- + +atf_test_case r +r_head() +{ + atf_set "descr" "Verifies that 'r' formatting spec works" +} +r_body() +{ + check r "07:04:03 AM" "09:20:00 PM" +} + +# ---------------------------------------------------------------------- + +atf_test_case S +S_head() +{ + atf_set "descr" "Verifies that 'S' formatting spec works" +} +S_body() +{ + check S 03 00 +} + +# ---------------------------------------------------------------------- + +atf_test_case s +s_head() +{ + atf_set "descr" "Verifies that 's' formatting spec works" +} +s_body() +{ + check s ${TEST1} ${TEST2} +} + +# ---------------------------------------------------------------------- + +atf_test_case U +U_head() +{ + atf_set "descr" "Verifies that 'U' formatting spec works" +} +U_body() +{ + check U 05 45 +} + +# ---------------------------------------------------------------------- + +atf_test_case u +u_head() +{ + atf_set "descr" "Verifies that 'u' formatting spec works" +} +u_body() +{ + check u 6 1 +} + +# ---------------------------------------------------------------------- + +atf_test_case V +V_head() +{ + atf_set "descr" "Verifies that 'V' formatting spec works" +} +V_body() +{ + check V 06 46 +} + +# ---------------------------------------------------------------------- + +atf_test_case v +v_head() +{ + atf_set "descr" "Verifies that 'v' formatting spec works" +} +v_body() +{ + check v " 7-Feb-1970" "12-Nov-2001" +} + +# ---------------------------------------------------------------------- + +atf_test_case W +W_head() +{ + atf_set "descr" "Verifies that 'W' formatting spec works" +} +W_body() +{ + check W 05 46 +} + +# ---------------------------------------------------------------------- + +atf_test_case w +w_head() +{ + atf_set "descr" "Verifies that 'w' formatting spec works" +} +w_body() +{ + check w 6 1 +} + +# ---------------------------------------------------------------------- + +atf_test_case X +X_head() +{ + atf_set "descr" "Verifies that 'X' formatting spec works" +} +X_body() +{ + check X "07:04:03" "21:20:00" +} + +# ---------------------------------------------------------------------- + +atf_test_case x +x_head() +{ + atf_set "descr" "Verifies that 'x' formatting spec works" +} +x_body() +{ + check x "02/07/70" "11/12/01" +} + +# ---------------------------------------------------------------------- + +atf_test_case Y +Y_head() +{ + atf_set "descr" "Verifies that 'Y' formatting spec works" +} +Y_body() +{ + check Y 1970 2001 +} + +# ---------------------------------------------------------------------- + +atf_test_case y +y_head() +{ + atf_set "descr" "Verifies that 'y' formatting spec works" +} +y_body() +{ + check y 70 01 +} + +# ---------------------------------------------------------------------- + +atf_test_case Z +Z_head() +{ + atf_set "descr" "Verifies that 'Z' formatting spec works" +} +Z_body() +{ + check Z UTC UTC +} + +# ---------------------------------------------------------------------- + +atf_test_case z +z_head() +{ + atf_set "descr" "Verifies that 'z' formatting spec works" +} +z_body() +{ + check z +0000 +0000 +} + +# ---------------------------------------------------------------------- + +atf_test_case pct +pct_head() +{ + atf_set "descr" "Verifies that '%' formatting spec works" +} +pct_body() +{ + check % % % +} + +# ---------------------------------------------------------------------- + +atf_test_case plus +plus_head() +{ + atf_set "descr" "Verifies that '+' formatting spec works" +} +plus_body() +{ + check + "Sat Feb 7 07:04:03 UTC 1970" "Mon Nov 12 21:20:00 UTC 2001" +} + +# ---------------------------------------------------------------------- +# Main test case driving script. +# ---------------------------------------------------------------------- + +atf_init_test_cases() +{ + atf_add_test_case A + atf_add_test_case a + atf_add_test_case B + atf_add_test_case b + atf_add_test_case C + atf_add_test_case c + atf_add_test_case D + atf_add_test_case d + atf_add_test_case e + atf_add_test_case F + atf_add_test_case G + atf_add_test_case g + atf_add_test_case H + atf_add_test_case h + atf_add_test_case I + atf_add_test_case j + atf_add_test_case k + atf_add_test_case l + atf_add_test_case M + atf_add_test_case m + atf_add_test_case p + atf_add_test_case R + atf_add_test_case r + atf_add_test_case S + atf_add_test_case s + atf_add_test_case U + atf_add_test_case u + atf_add_test_case V + atf_add_test_case v + atf_add_test_case W + atf_add_test_case w + atf_add_test_case X + atf_add_test_case x + atf_add_test_case Y + atf_add_test_case y + atf_add_test_case Z + atf_add_test_case z + atf_add_test_case pct + atf_add_test_case plus +} + +# vim:syntax=sh diff --git a/bin/date/tests/legacy_test.sh b/bin/date/tests/legacy_test.sh deleted file mode 100644 index 981bdd0..0000000 --- a/bin/date/tests/legacy_test.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/sh - -# -# Regression tests for date(1) -# -# Submitted by Edwin Groothuis <edwin@FreeBSD.org> -# -# $FreeBSD$ -# - -# -# These two date/times have been chosen carefully, they -# create both the single digit and double/multidigit version of -# the values. -# -# To create a new one, make sure you are using the UTC timezone! -# - -TEST1=3222243 # 1970-02-07 07:04:03 -TEST2=1005600000 # 2001-11-12 21:11:12 - -export LC_ALL=C -export TZ=UTC -count=0 - -check() -{ - S=$1 - A1=$2 - A2=$3 - - count=`expr ${count} + 1` - - if [ -z "${A2}" ]; then A2=${A1}; fi - - R=`date -r ${TEST1} +%${S}` - if [ "${R}" = "${A1}" ]; then - echo "ok ${S}{t1}" - else - echo "no ok ${S}{t1} - (got ${R}, expected ${A1})" - fi - - R=`date -r ${TEST2} +%${S}` - if [ "${R}" = "${A2}" ]; then - echo "ok ${S}{t2}" - else - echo "no ok ${S}{t2} - (got ${R}, expected ${A2})" - fi -} - -echo "1..78" - -check A Saturday Monday -check a Sat Mon -check B February November -check b Feb Nov -check C 19 20 -check c "Sat Feb 7 07:04:03 1970" "Mon Nov 12 21:20:00 2001" -check D 02/07/70 11/12/01 -check d 07 12 -check e " 7" 12 -check F "1970-02-07" "2001-11-12" -check G 1970 2001 -check g 70 01 -check H 07 21 -check h Feb Nov -check I 07 09 -check j 038 316 -check k " 7" 21 -check l " 7" " 9" -check M 04 20 -check m 02 11 -check p AM PM -check R 07:04 21:20 -check r "07:04:03 AM" "09:20:00 PM" -check S 03 00 -check s ${TEST1} ${TEST2} -check U 05 45 -check u 6 1 -check V 06 46 -check v " 7-Feb-1970" "12-Nov-2001" -check W 05 46 -check w 6 1 -check X "07:04:03" "21:20:00" -check x "02/07/70" "11/12/01" -check Y 1970 2001 -check y 70 01 -check Z UTC UTC -check z +0000 +0000 -check % % % -check + "Sat Feb 7 07:04:03 UTC 1970" "Mon Nov 12 21:20:00 UTC 2001" --Apple-Mail=_F518CF31-AFAD-4414-BB2B-AB1861E87B42--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4A25ADF9-3714-4006-ACB6-F8C745CB38AE>