Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Feb 2014 20:59:12 -0700
From:      Alan Somers <asomers@freebsd.org>
To:        Peter Holm <peter@holm.cc>
Cc:        "freebsd-testing@freebsd.org" <freebsd-testing@freebsd.org>
Subject:   Re: My first ATF test
Message-ID:  <CAOtMX2jiJurBky-Qe4Mf-Py8Rp%2BCXM-hBo%2BmcsGA_pc=L-0TsA@mail.gmail.com>
In-Reply-To: <20140225183306.GA70295@x2.osted.lan>
References:  <20140225161129.GA59741@x2.osted.lan> <CAOtMX2hQA8SP7zXsOQHd-kAV7R8ziw12Cfz=nWQbBCaS1hS48g@mail.gmail.com> <20140225183306.GA70295@x2.osted.lan>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Feb 25, 2014 at 11:33 AM, Peter Holm <peter@holm.cc> 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 <peter@holm.cc> 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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOtMX2jiJurBky-Qe4Mf-Py8Rp%2BCXM-hBo%2BmcsGA_pc=L-0TsA>