From owner-freebsd-testing@FreeBSD.ORG Thu Jan 23 00:21:13 2014 Return-Path: Delivered-To: freebsd-testing@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CABA3748 for ; Thu, 23 Jan 2014 00:21:13 +0000 (UTC) Received: from mail-yh0-f54.google.com (mail-yh0-f54.google.com [209.85.213.54]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 87E591483 for ; Thu, 23 Jan 2014 00:21:13 +0000 (UTC) Received: by mail-yh0-f54.google.com with SMTP id z6so471327yhz.27 for ; Wed, 22 Jan 2014 16:21:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version:subject:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to; bh=2TldFqyv8KK9uLPR4DyEX/KXpF9S7eroD9CrxTZmucE=; b=HEHFq4mWrJsG11U/Q04vshXVFtEppNExc8t8TK0G2S3eKaBvHr2HNUUyJO6Smo2Ehx u6f3a/aGGk3EN0eNSq/+m8RXKGmP71k4TXILqhh4NN/iP4CMwFSSxi0C4+N9vydadsJ1 /O/JnS7zMLNMvqWCgqChisdfFa/Z1znmNRtBg7XDdiucBlcZNY6K7YyUGIWIJJYbQH9/ bzLDIp8esWq7cpHyKw26DSoI7/VyoY8aY6/nXYWhJId0257Am1GX/jlXJeosEvGAvBPn pcT6kFv3MQba+S9r76loCJHd7dhY3aUflrmZn1v4e+BaDEY3OZrw+xp8ZQbrs4A+FZ1L r6WQ== X-Gm-Message-State: ALoCoQlTCvDSXNdZWzOHYzI1l1C/wf2D5/2smYxefjlentHB8qusBPz+nsiy31VRJb6QGcRFr3ec X-Received: by 10.236.171.195 with SMTP id r43mr4727747yhl.56.1390435016100; Wed, 22 Jan 2014 15:56:56 -0800 (PST) Received: from ?IPv6:2620::1003:1007:6102:b049:b28e:1b56? ([2620:0:1003:1007:6102:b049:b28e:1b56]) by mx.google.com with ESMTPSA id e50sm29694671yhd.26.2014.01.22.15.56.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Jan 2014 15:56:52 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.1 \(1827\)) Subject: Re: [PATCH] convert bin/date over to ATF From: Julio Merino In-Reply-To: <6079AD8F-5EBB-431C-A06B-9B51E2729F5A@gmail.com> Date: Wed, 22 Jan 2014 18:56:50 -0500 Content-Transfer-Encoding: quoted-printable Message-Id: References: <6079AD8F-5EBB-431C-A06B-9B51E2729F5A@gmail.com> To: Garrett Cooper X-Mailer: Apple Mail (2.1827) Cc: freebsd-testing@FreeBSD.org, Giorgos Keramidas X-BeenThere: freebsd-testing@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Testing on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jan 2014 00:21:13 -0000 On Jan 20, 2014, at 13:40, Garrett Cooper wrote: > This is based on work done by Giorgos a couple years ago. > Thanks! > -Garrett Pasting patch contents and commenting inline: > diff --git a/bin/date/tests/Makefile b/bin/date/tests/Makefile > index 540008b..459d019 100644 > --- a/bin/date/tests/Makefile > +++ b/bin/date/tests/Makefile > @@ -4,6 +4,6 @@ > =20 > TESTSDIR=3D ${TESTSBASE}/bin/date > =20 > -TAP_TESTS_SH=3D legacy_test > +ATF_TESTS_SH=3D regress Tests ought to end with _test per the description in = https://wiki.freebsd.org/TestSuite/Structure Also, "regress_test" is not a very indicative name. Will this only = contain test cases for bugs to prevent regressions? date_test or integration_test (due to the lack of unit tests for the = code) may be better choices. =20 > --- /dev/null > +++ b/bin/date/tests/regress.sh > @@ -0,0 +1,557 @@ > +#!/bin/sh Remove. This comes from atf.test.mk automatically. > + > +# > +# Regression tests for date(1) > +# > +# Submitted by Edwin Groothuis > +# > +# $FreeBSD: src/tools/regression/bin/date/regress.sh,v 1.4 2011/01/09 = 22:05:09 keramida Exp $ > +# > + > +# > +# 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=3D3222243 # 1970-02-07 07:04:03 > +TEST2=3D1005600000 # 2001-11-12 21:11:12 > + > +export LC_ALL=3DC > +export TZ=3DUTC Kyua does this already as part of the contract between atf and the = runtime engine. You should not be resetting these. > + > +check() > +{ > + S=3D$1 > + A1=3D$2 > + A2=3D$3 S, A1, A2? What do these mean? Also, make local. > + > + # If the second sample text for formatted output has not been > + # passed, assume it should match exactly the first one. > + if [ -z "${A2}" ]; then > + A2=3D${A1} > + fi > + > + R=3D`date -r ${TEST1} +%${S}` Prefer $() over ``. > + atf_check test "${R}" =3D "${A1}" > + > + R=3D`date -r ${TEST2} +%${S}` > + atf_check test "${R}" =3D "${A2}" > +} > + > +# = ---------------------------------------------------------------------- > + > +atf_test_case A > +A_head() > +{ > + atf_set "descr" "Verifies that 'A' formatting spec works" These test case names are truly non-descriptive. I'd recommend renaming = them to something like formatting_spec__A, etc. and omitting the = definition of head() altogether. Will result on a much shorter test = program, and being concise here for readability matters a lot. ... and then you can just create a "macro" to define test cases. Like = this, but untested: formatting_spec_test_case() { local subname=3D"${1}"; shift local name=3D"formatting_spec__${subname}" atf_test_case "${name}" eval "${name}_body() { check ${*} }" } formatting_spec_test_case a a Sat Mon formatting_spec_test_case B B February November ... formatting_spec_test_case plus + "Sat Feb 7 07:04:03 UTC 1970" "Mon Nov = 12 21:20:00 UTC 2001" > +} > +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 > +} >=20 >=20