openbmc.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Lei Yu <yulei.sh@bytedance.com>
To: Joseph Reynolds <jrey@linux.ibm.com>
Cc: openbmc <openbmc@lists.ozlabs.org>,
	Sunitha Harish <sunithaharish04@gmail.com>,
	deepak.kodihalli.83@gmail.com, Ed Tanous <edtanous@google.com>,
	Brad Bishop <bradleyb@fuzziesquirrel.com>,
	gmills@us.ibm.com, geissonator@yahoo.com,
	Ratan Gupta <ratagupt@linux.vnet.ibm.com>
Subject: Re: UnitTest using the /tmp file system
Date: Wed, 24 Mar 2021 11:12:54 +0800	[thread overview]
Message-ID: <CAGm54UEm9JXX555jkR7UQGa8P5kzA+cgsb1fRvUvc1OzANxuBQ@mail.gmail.com> (raw)
In-Reply-To: <315434fc-94d3-ec8c-b99d-80a88690a119@linux.ibm.com>

On Tue, Mar 23, 2021 at 11:08 PM Joseph Reynolds <jrey@linux.ibm.com> wrote:
>
> On 3/23/21 12:44 AM, Sunitha Harish wrote:
> > Any views please ?
> >
> > On 21-03-2021 09:30, Sunitha Harish wrote:
> >> Hi,
> >>
> >> This is regarding the unit tests in various repos under openbmc like:
> >> phosphor-bmc-code-management, phosphor-logging, phosphor-networkd,
> >> pldm etc . I have seen the testcases using the /tmp filesystem to
> >> create the directories/files when the UT is run.
>
> Are the files written to the BMC's file system or to the test platform's
> file system?  I don't understand why this is important either way.
> Can't we just erase the file when the unit test is complete?
>

I agree it is better to mock as many interfaces as possible to avoid
accessing host's file system.

But in certain cases, I do want to test the functions that involves filesystem.
In such case, I usually use mkdtemp() to create a temp dir in test
case's ctor or setup(), and remove it on test case's dtor or
tearDown().

-- 
BRs,
Lei YU

  reply	other threads:[~2021-03-24  3:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-21  4:00 UnitTest using the /tmp file system Sunitha Harish
2021-03-23  5:44 ` Sunitha Harish
2021-03-23 15:03   ` Joseph Reynolds
2021-03-24  3:12     ` Lei Yu [this message]
2021-03-24  5:07       ` Sunitha Harish
2021-03-27 14:03 ` Patrick Williams
2021-03-29  4:29   ` Sunitha Harish

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGm54UEm9JXX555jkR7UQGa8P5kzA+cgsb1fRvUvc1OzANxuBQ@mail.gmail.com \
    --to=yulei.sh@bytedance.com \
    --cc=bradleyb@fuzziesquirrel.com \
    --cc=deepak.kodihalli.83@gmail.com \
    --cc=edtanous@google.com \
    --cc=geissonator@yahoo.com \
    --cc=gmills@us.ibm.com \
    --cc=jrey@linux.ibm.com \
    --cc=openbmc@lists.ozlabs.org \
    --cc=ratagupt@linux.vnet.ibm.com \
    --cc=sunithaharish04@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).