From owner-freebsd-testing@FreeBSD.ORG Wed Feb 26 03:59:14 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 A89CB817; Wed, 26 Feb 2014 03:59:14 +0000 (UTC) Received: from mail-wg0-x232.google.com (mail-wg0-x232.google.com [IPv6:2a00:1450:400c:c00::232]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 10CB815BA; Wed, 26 Feb 2014 03:59:13 +0000 (UTC) Received: by mail-wg0-f50.google.com with SMTP id l18so1178835wgh.33 for ; Tue, 25 Feb 2014 19:59:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=7xvP0PHRe/Jkr9C5XscgG+qiU/scRISu/GaVM3+5ynA=; b=UeJu3eJTgyKzihaxhlsscdkXSNleDfVQoMlsGd9/f0A1SD4G2FS2R/Wo1vuR9zuaMg Ekjg5pbKdRwkEha/PlsiUo4r0seJYojcrl7bwDCTjoOS2N79xZV7f3zP9+K458/ub4CK t/OQEGAyQZG24PawldBBrqOhoBbBPKYrXYN/n/bTQwiMNeKA2abfUmAEbTCUFHE4G7WF A7TZw4oYt60QT9QhINztDdiXQxhruTUAZG/AQi9JbjVESfMHMgbxSPAvccg0UEgcqL8m EhB44TtrsZ5bQSOEj046ZDghGmFYdZ/DIDE5O2BJvWxxaOF9z1q65K9fGC5nMn8G/oT+ ddnA== MIME-Version: 1.0 X-Received: by 10.180.187.16 with SMTP id fo16mr2905066wic.26.1393387152289; Tue, 25 Feb 2014 19:59:12 -0800 (PST) Sender: asomers@gmail.com Received: by 10.194.168.197 with HTTP; Tue, 25 Feb 2014 19:59:12 -0800 (PST) In-Reply-To: <20140225183306.GA70295@x2.osted.lan> References: <20140225161129.GA59741@x2.osted.lan> <20140225183306.GA70295@x2.osted.lan> Date: Tue, 25 Feb 2014 20:59:12 -0700 X-Google-Sender-Auth: BfwdG0NHSVrmILHPE-Wf8ENsDIs Message-ID: Subject: Re: My first ATF test From: Alan Somers To: Peter Holm Content-Type: text/plain; charset=ISO-8859-1 Cc: "freebsd-testing@freebsd.org" 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: Wed, 26 Feb 2014 03:59:14 -0000 On Tue, Feb 25, 2014 at 11:33 AM, Peter Holm wrote: > On Tue, Feb 25, 2014 at 09:47:52AM -0700, Alan Somers wrote: >> On Tue, Feb 25, 2014 at 9:11 AM, Peter Holm wrote: >> > In order to understand how ATF works I wrote a small test so I had >> > something to work with: >> > http://people.freebsd.org/~pho/kern_descrip_test.diff >> > Did I get it right? >> >> ATF-wise, it looks good. However, it's a bad idea to use random >> numbers in test code, except in stress tests. Random numbers result >> in irreproducible tests. How about replacing the body of dup2_r234131 >> with something like this? >> > > Thank you for looking at this. > >> int fd1, fd2, ret; >> fd1 = open("/etc/passwd", O_RDONLY); >> fd2 = INT_MAX; >> ret = dup2(fd1, fd2); >> ATF_CHECK_EQ(-1, ret); >> ATF_CHECK_EQ(EBADF, errno); >> > > OK. > >> On a side note, perhaps WARNS should be set in atf.test.mk, so we >> won't have to set it in every other Makefile. >> > > I agree. > http://people.freebsd.org/~pho/kern_descrip_test-v2.diff > > I have a style question: > You have the constant as first argument to ATF_CHECK_EQ. It seems > that NetBSD has chosen to have it last, in most cases. Is your > choice the FreeBSD standard? > The atf-c-api(3) man page doesn't recommend one or the other, and its examples show it both ways. My personal habit is to put the constant first. It's been ingrained by both googletest and Ruby's test/unit, which both have a clear policy. Personally, I would say that if you're editing an existing file, try to keep with its preexisting style. Otherwise, I don't think it matters.