UnitTest using the /tmp file system

Sunitha Harish sunithaharish04 at gmail.com
Wed Mar 24 16:07:17 AEDT 2021


On 24-03-2021 08:42, Lei Yu wrote:
> On Tue, Mar 23, 2021 at 11:08 PM Joseph Reynolds <jrey at 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().

Yes. The test platform's /tmp directory is used to create the files. The 
implementations in various repos are as Lei mentioned. The files are 
removed when the test is complete.



More information about the openbmc mailing list