Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Feb 2014 21:02:38 -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:  <CAOtMX2iqDy3Db3RGWnqGppLmVFQthYc25Y5XMn8q0NScjszOBg@mail.gmail.com>
In-Reply-To: <20140225183611.GA70774@x2.osted.lan>
References:  <20140225161129.GA59741@x2.osted.lan> <CAOtMX2hQA8SP7zXsOQHd-kAV7R8ziw12Cfz=nWQbBCaS1hS48g@mail.gmail.com> <CAOgwaMv1pqibdR6WJUB9gzDCOJpdDLdFOOvdgjeLJfd5pqbN_g@mail.gmail.com> <20140225183611.GA70774@x2.osted.lan>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Feb 25, 2014 at 11:36 AM, Peter Holm <peter@holm.cc> wrote:
> On Tue, Feb 25, 2014 at 12:12:38PM -0500, Mehmet Erol Sanliturk wrote:
>>    On Tue, Feb 25, 2014 at 11:47 AM, Alan Somers <[1]asomers@freebsd.org=
>
>>    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 ha=
d
>>      > something to work with:
>>      > [2]http://people.freebsd.org/~pho/kern_descrip_test.diff
>>      > Did I get it right?
>>      ATF-wise, it looks good. =C2 However, it's a bad idea to use random
>>      numbers in test code, except in stress tests. =C2 Random numbers
>>      result
>>      in irreproducible tests. =C2 How about replacing the body of
>>      dup2_r234131
>>      with something like this?
>>      =C2  int fd1, fd2, ret;
>>      =C2  fd1 =3D =C2 open("/etc/passwd", O_RDONLY);
>>      =C2  fd2 =3D INT_MAX;
>>      =C2  ret =3D dup2(fd1, fd2);
>>      =C2  ATF_CHECK_EQ(-1, ret);
>>      =C2  ATF_CHECK_EQ(EBADF, errno);
>>      On a side note, perhaps WARNS should be set in [3]atf.test.mk, so w=
e
>>      won't have to set it in every other Makefile.
>>      -Alan
>>      _______________________________________________
>>
>>    When random numbers are used , it is possible to make the runs
>>    reproducible in the following way :
>>    Generate a specified number of random numbers and store them into a
>>    file .
>>    During usage , for random numbers , traverse that file .
>>    This may be repeated any number of times for different other paramete=
rs
>>    .
>>    All of the runs will use the same random numbers .
>>    Then the results ( which they are generated from the same distributio=
n
>>    ) may be compared with suitable statistical tests .
>>    Thank you very much .
>>    Mehmet Erol Sanliturk
>>
>
> I guess I'm too used to using random values in tests :)
> Using random(3) with an initial seed of "1" could have been an
> alternative, but ...

But in this case it's not necessary.  This isn't a stress test; it's a
basic functional test.  If Peter had been attempting to trigger a race
condition or something like that, then random(3) with a fixed seed
would indeed be appropriate.

-Alan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOtMX2iqDy3Db3RGWnqGppLmVFQthYc25Y5XMn8q0NScjszOBg>