From owner-freebsd-testing@FreeBSD.ORG Tue Feb 25 18:33: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 5B07658A for ; Tue, 25 Feb 2014 18:33:13 +0000 (UTC) Received: from relay02.pair.com (relay02.pair.com [209.68.5.16]) by mx1.freebsd.org (Postfix) with SMTP id E83BD19B3 for ; Tue, 25 Feb 2014 18:33:12 +0000 (UTC) Received: (qmail 7106 invoked from network); 25 Feb 2014 18:33:11 -0000 Received: from 87.58.146.155 (HELO x2.osted.lan) (87.58.146.155) by relay02.pair.com with SMTP; 25 Feb 2014 18:33:11 -0000 X-pair-Authenticated: 87.58.146.155 Received: from x2.osted.lan (localhost [127.0.0.1]) by x2.osted.lan (8.14.5/8.14.5) with ESMTP id s1PIX6WU070767; Tue, 25 Feb 2014 19:33:07 +0100 (CET) (envelope-from pho@x2.osted.lan) Received: (from pho@localhost) by x2.osted.lan (8.14.5/8.14.5/Submit) id s1PIX6e7070766; Tue, 25 Feb 2014 19:33:06 +0100 (CET) (envelope-from pho) Date: Tue, 25 Feb 2014 19:33:06 +0100 From: Peter Holm To: Alan Somers Subject: Re: My first ATF test Message-ID: <20140225183306.GA70295@x2.osted.lan> References: <20140225161129.GA59741@x2.osted.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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: Tue, 25 Feb 2014 18:33:13 -0000 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? > -Alan -- Peter