Code Coverage on target hardware

I am looking to implement collection of code coverage data from running unit tests on target hardware. The project has been able to use the Unity test framework, and tests are built and run on the target using app runProc AppName --exe=TestAppExe

Ideally I’d use gcov as the compiler is gcc. I have previously used lcov to use this and generate visual output. Perhaps someone has already done this??
Some questions:

  1. If a sandboxed application is writing files, where will they go and how can they be accessed?
  2. Is there a straightforward way to install gcov and lcov tools onto the target, or do they need to cross-compiled from source?
  3. Instead of running tests to get coverage on the target, is it easier to run them on the host, and if so, how can that be done (i.e. build and run a Legato application on a Linux build host)?

Many thanks for any help on this.

1 Like

Hello @gnottage,

- If a sandboxed application is writing files, where will they go and how can they be accessed?

Legato sandboxes use chroot to limit a Legato App view to its own section of the file system only. Files are bound into the chroot jail using bind mounts. The process then only has access to files and directories under its root directory. Only processes with certain capabilities can find their way outside of their root directory; processes belonging to sandboxed Legato Apps run as unprivileged users that don’t have those capabilities. See also Security - Legato Docs

“sbtrace” (target tool) and “sbhelper” (host tool) can list the files a sandboxed Legato App is trying to access. See Sandbox Helper - Legato Docs

- Is there a straightforward way to install gcov and lcov tools onto the target, or do they need to cross-compiled from source?

Yes, the procedure is available inside [AirPrime with MDM9x+Legato] Getting code coverage data.v001.pdf (189.4 KB)

- Instead of running tests to get coverage on the target, is it easier to run them on the host, and if so, how can that be done (i.e. build and run a Legato application on a Linux build host)?

It is possible to run a Legato Framework + Apps on a Linux host: see startlegato - Legato Docs
But, running your software outside of the target environment will result in some mobile-oriented features becoming either disabled or simulated.
So the code coverage area will become narrower.

KR.

1 Like