Skip to content

osal_timer_UT has an incorrect failure #514

@mbenson1

Description

@mbenson1

Describe the bug
The UT_os_timerset_test() in the osal_timer_UT calls "OS_TimerSet(99999, startTime, intervalTime)", with both startTime and intervalTime set to 0, expecting that it will fail the ID check before it will fail the start and interval time checks.

To Reproduce
Steps to reproduce the behavior:

  1. Build and run osal_timer_UT on the sample build from the getting started instructions in the cFS repository.

Expected behavior
The unit test is written expecting that the ID validity check will fail before the start and interval time check fails. Its expecting it will return OS_ERR_INVALID_ID, but when when you run this on using the POSIX OSAL from 5.0.3-bv version, it will actually return OS_ERROR because the start and interval times are invalid.

Code snips
A quick fix is to initialize startTime and intervalTime to 1, which will cause the OS_TimerSet() function to pass the start and interval time checks, and fail on the ID check as expected.

System observed on:

  • VirtualBox
  • Ubuntu 16.04
  • OSAL 5.0.3-bv

Additional context
While changing the start and interval times to 1 will fix this problem in this specific case, the test is actually specific to the OSAL (posix, vxworks, rtems, etc...) under test. I would argue that a better design would be to have 1 common OSAL unit test to verify functionality, i.e. that tasks function as tasks, and mutexes function as mutexes, but that each OSAL might have their own individual set of unit tests that are specific to that OSAL. You can think of the common set as black box tests, that are verifying the OSAL meets functional requirements, and white box tests for coverage. White box testing, by their nature, are specific to the source code under test. Therefore, each OSAL might have its own set of white box testing to ensure coverage for that particular OSAL.

Those unit tests normally exercise all the function parameters, to get coverage. That particular unit test does not exercise the start or interval time arguments, because the original OSAL they were written to does not have a validity check for the start or interval time arguments. This is an example of a unit test suite that was written for a specific OSAL.

We follow this concept in our CFS fork. The unit tests originally created by GSFC work well as black box tests. They have little to know platform or configuration dependency. We run the same unit tests on all the NASA provided OSALs, as well as all the OSALs we have written. The unit tests originally created by JSC work well as white box tests, as this bug report indicates. Those unit tests usually fail when we try running them on other OSALs, because of issues similar to what this issue is referring to.

Reporter Info
Mathew Benson
Owner
Windhover Labs, LLC

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions