Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Sep 2019 14:12:42 +0200
From:      Jilles Tjoelker <jilles@stack.nl>
To:        Li-Wen Hsu <lwhsu@freebsd.org>
Cc:        rgrimes@freebsd.org, Enji Cooper <yaneurabeya@gmail.com>, Warner Losh <imp@bsdimp.com>, "Conrad E. Meyer" <cem@freebsd.org>, src-committers <src-committers@freebsd.org>, svn-src-all <svn-src-all@freebsd.org>, svn-src-head <svn-src-head@freebsd.org>
Subject:   Re: svn commit: r351643 - in head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common: dtraceUtil speculation
Message-ID:  <20190903121242.GA23842@stack.nl>
In-Reply-To: <CAKBkRUxTmUT=qo8e3w=smbpZM5_UxyDm97JGWTWxCG6tVOfJVw@mail.gmail.com>
References:  <FFB0A7EC-43FF-4012-9344-0F3A191BB4FA@gmail.com> <201909021549.x82FndM9009860@gndrsh.dnsmgr.net> <CAKBkRUxTmUT=qo8e3w=smbpZM5_UxyDm97JGWTWxCG6tVOfJVw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Sep 03, 2019 at 06:42:00PM +0800, Li-Wen Hsu wrote:
> On Mon, Sep 2, 2019 at 11:49 PM Rodney W. Grimes
> <freebsd@gndrsh.dnsmgr.net> wrote:

> > > > On Aug 31, 2019, at 16:29, Warner Losh <imp@bsdimp.com> wrote:

> > > >> On Sat, Aug 31, 2019 at 5:29 PM Conrad Meyer <cem@freebsd.org> wrote:
> > > >> Thanks Li-Wen!  Might it be less fragile to have the test fixture
> > > >> create a file, if the test(s) will expect one to be present to read?

> > > > Or just use the realpath $0, which you know has to exist :)

> > > I don?t know if this would work, with other some of the dtrace
> > > tests are called. Plus, that relies on a FreeBSD utility which
> > > doesn?t necessarily exist on Linux and I don?t think exists on
> > > IllumOS.

> > > It makes more sense to create a file with mktemp and test for it
> > > in the loop to make the tests portable over to IllumOS, since
> > > that?s where they originally came from and can be contributed back
> > > to.

> > Agreed, especially if these tests are expected to be portable the
> > assumption of existance of /COPYRIGHT is a mistake/bug.

> Thanks for the inputs.  Indeed, depending on any irrelevant files or
> FreeBSD specified tools both do not sound a good solution.  After
> reading these test cases again, I feel that creating a temp file might
> be slightly over engineering because in the end we also need to take
> care of cleaning, in normal and abnormal exiting cases.  In these
> tests, we only need someone calls open(2) and read(2).

> How about changing them to `cat / > /dev/null` ?

Reading a directory as bytes is not portable. For example, FreeBSD
fdescfs and nfs do not allow it, and Linux does not allow it at all.

Apart from the fact that the resulting bytes depend on the filesystem
type, this operation is problematic because it may expose filenames that
were previously deleted.

The files /etc/group and /etc/passwd exist on most operating systems,
but for optimal portability a temporary file seems unavoidable (assuming
that data must come from a regular file).

-- 
Jilles Tjoelker



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