From owner-freebsd-testing@FreeBSD.ORG Thu Jan 23 22:16:35 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 5DF6FF2F; Thu, 23 Jan 2014 22:16:35 +0000 (UTC) Received: from mail-pd0-x22f.google.com (mail-pd0-x22f.google.com [IPv6:2607:f8b0:400e:c02::22f]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 2C0521269; Thu, 23 Jan 2014 22:16:35 +0000 (UTC) Received: by mail-pd0-f175.google.com with SMTP id w10so2309370pde.6 for ; Thu, 23 Jan 2014 14:16:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=Jk1QSaBZKqWqWSoY1H+HoD56xdMOZyEbWKdIZLbBMGY=; b=un6ZvCW59iELQDzpxJvxcKM2WSoQofUkxOWO201l0E3Gb4k0bd0qNF/K9eN9Z0z4ml 0AKdeA7cQRod0jUDZVMgQfWQDm+xgOuHUaEBW7KU0Kjlu50TpnRbdZM78i2BOEMdtlt5 w64c9jiovor9Mww3jz3uS4vldSiHHnvZDUVIlHOLVBRV7Esg88kSLEgUmtxB3BUE7Abv uHwSWQE/LFwBm6MrreEv3acKVCueK8v/BpjtDocjfV2gSKmxzMga5gqWi6i64w34+L4t Ahg6T3hYsPtk3OrGHY4LgSO1iqJNxFA1LvAauUE10DzAhS1LAQXn7j4iV7MGDsV7uKXf iA6w== X-Received: by 10.68.89.162 with SMTP id bp2mr10369125pbb.151.1390515394877; Thu, 23 Jan 2014 14:16:34 -0800 (PST) Received: from fuji.zcorp.zonarsystems.com ([64.14.143.130]) by mx.google.com with ESMTPSA id de3sm41678389pbb.33.2014.01.23.14.16.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Jan 2014 14:16:34 -0800 (PST) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.1 \(1827\)) Subject: Re: [PATCH] convert bin/date over to ATF From: Garrett Cooper In-Reply-To: Date: Thu, 23 Jan 2014 14:16:32 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: References: <6079AD8F-5EBB-431C-A06B-9B51E2729F5A@gmail.com> To: Julio Merino 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 22:16:35 -0000 On Jan 22, 2014, at 3:56 PM, Julio Merino wrote: > On Jan 20, 2014, at 13:40, Garrett Cooper = wrote: >=20 >> This is based on work done by Giorgos a couple years ago. >> Thanks! >> -Garrett >=20 > Pasting patch contents and commenting inline: >=20 >> 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 >=20 > Tests ought to end with _test per the description in = https://wiki.freebsd.org/TestSuite/Structure Ok! Is `_tests` ok? > Also, "regress_test" is not a very indicative name. Will this only = contain test cases for bugs to prevent regressions? It should be =93date_functional_tests=94, because that=92s what they=92re = doing. > date_test or integration_test (due to the lack of unit tests for the = code) may be better choices. ... >> --- /dev/null >> +++ b/bin/date/tests/regress.sh >> @@ -0,0 +1,557 @@ >> +#!/bin/sh >=20 > Remove. This comes from atf.test.mk automatically. >=20 >> + >> +# >> +# 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 >=20 > Kyua does this already as part of the contract between atf and the = runtime engine. You should not be resetting these. Ok. This was code originally written with ATF in mind, but I totally = agree. >> + >> +check() >> +{ >> + S=3D$1 >> + A1=3D$2 >> + A2=3D$3 >=20 > S, A1, A2? What do these mean? Not sure=85 giorgos wrote these (but I assume it=92s format_string, = string, string_post_manipulation based on the comments=85). > Also, make local. Totally agree (will do)! >> + >> + # 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}` >=20 > Prefer $() over ``. Me too (will change). >> + 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" >=20 > 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. >=20 > ... and then you can just create a "macro" to define test cases. Like = this, but untested: >=20 > formatting_spec_test_case() { > local subname=3D"${1}"; shift > local name=3D"formatting_spec__${subname}" >=20 > atf_test_case "${name}" > eval "${name}_body() { check ${*} }" > } >=20 > 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=94 Yeah. I=92ll think about that further and get back to you after I figure = out how the code works a bit more (this was just a straight carryover = from giorgos). =85 Thanks! -Garrett=