Unit Tests, Documentation and Mocks (oh my!)
Lei YU
mine260309 at gmail.com
Thu Aug 8 12:18:44 AEST 2019
I always prefer to run unit test in local build, that being said, run
the unit test without a docker but in an SDK environment.
The basic steps are:
1. Build and install a x86-64 SDK (refer to [cheatsheet.md][1])
2. Setup the SDK environment, typically
```
. /opt/openbmc/oecore-x86_64/environment-setup-core2-64-openbmc-linux
```
3. For repos with autotools:
```
./bootstrap
./configure ${CONFIGURE_FLAGS} --enable-oe-sdk
make check
```
4. For repos with meson, I do not have a perfect solution, but there
is an example at
https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-psu-code-mgmt/+/24155/3
and then you could:
```
meson -Doe-sdk=enabled -Dtests=enabled build
ninja -C build/
./build/test/utest
```
Unfortunately, the unit test within SDK does not work for all repos.
* Some repos depends on packages that are not installed in SDK;
* Some repos' unit tests fail for unknown (yet) reason in SDK, but run
OK in docker.
I really wish to improve this so the unit test could be done locally
without docker.
[1]: https://github.com/openbmc/docs/blob/master/cheatsheet.md#building-the-openbmc-sdk
On Thu, Aug 8, 2019 at 8:21 AM Emily Shaffer <emilyshaffer at google.com> wrote:
>
>
>
> On Wed, Aug 7, 2019 at 5:11 PM Andrew Jeffery <andrew at aj.id.au> wrote:
>>
>> Hi Wilfred,
>>
>> On Thu, 8 Aug 2019, at 05:16, Wilfred Smith wrote:
>> > Please pardon my ignorance, but I’ve searched and come up empty-handed.
>> > A URL would be greatly appreciated.
>> >
>> > Where are the unit tests,
>>
>> Unit tests sit in the application repositories alongside the code. OpenBMC
>> has historically been poor on unit testing, though this is improving.
>
>
> I'll add that phosphor-host-ipmid has documentation on how to run unit tests locally using Docker here:
> https://github.com/openbmc/phosphor-host-ipmid/blob/master/docs/testing.md
>
> This setup likely applies to a few other areas of the project (although I haven't tested it). It's very similar to the continuous integration test suite.
>
> - Emily
More information about the openbmc
mailing list