Skip to content

OSAL tests fails under various conditions #760

@jhnphm

Description

@jhnphm

Describe the bug

osal_loader_UT would fail while running on the target, since the utmod/* files aren't installed along w/ the test executable to build/exe/*

In addition, under certain circumstances, the following tests may fail, i.e. if another user has run the tests and files are left in /dev/shm (the tests don't clean up the files):
file-api-test
select-test

To Reproduce
For the first case, run test out of build/exe/[cpu]

For the second case, run file-api-test/select-test once, chown the files under /dev/shm/RAM[N] to some other user, and run again.

Expected behavior
Tests should succeed

Code snips

Should have an install line for the test modules here:

COMPILE_DEFINITIONS "MODULE_NAME=module${MOD}"
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY utmod)

Should test if actual directory is writable, not just if the parent tmp directory is writable,

if (tmpdir != NULL && stat(tmpdir, &stat_buf) == 0)
{
/* check if the user has write permission to the directory */
if ((stat_buf.st_mode & S_IWOTH) != 0 ||
((stat_buf.st_mode & S_IWGRP) != 0 && stat_buf.st_gid == getegid()) ||
((stat_buf.st_mode & S_IWUSR) != 0 && stat_buf.st_uid == geteuid()))
{
break;
}
}

This alone wouldn't solve the issue though, just punt it to the next available tmp directory. You'd probably also want to use mkstemp() or similar to generate a randomly named directory under the tmp folder.

System observed on:

  • Linux

Reporter Info
John N Pham, Northrop Grumman

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcommunityunit-testTickets related to the OSAL unit testing (functional and/or coverage)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions