## 7.17. Generated output quality assurance checks - `insane.bbclass`

This class adds a step to the package generation process that sanity checks the packages generated by the OpenEmbedded build system. A range of checks are performed that check the build's output for common problems that show up during runtime. Distribution policy usually dictates whether to include this class.

You can configure the sanity checks so that specific test failures either raise a warning or an error message. Typically, failures for new tests generate a warning. Subsequent failures for the same test would then generate an error message once the metadata is in a known and good condition. You use the `WARN_QA` variable to specify tests for which you want to generate a warning message on failure. You use the `ERROR_QA` variable to specify tests for which you want to generate an error message on failure.

The following list shows the tests you can list with the `WARN_QA` and `ERROR_QA` variables:

- `ldflags:` Ensures that the binaries were linked with the `LDFLAGS` options provided by the build system. If this test fails, check that the `LDFLAGS` variable is being passed to the linker command.

- `useless-rpaths:` Checks for dynamic library load paths (rpaths) in the binaries that by default on a standard system are searched by the linker (e.g. `/lib` and `/usr/lib`). While these paths will not cause any breakage, they do waste space and are unnecessary.

- `rpaths:` Checks for rpaths in the binaries that contain build system paths such as `TMPDIR`. If this test fails, bad `-rpath` options are being passed to the linker commands and your binaries have potential security issues.

- `dev-so:` Checks that the `.so` symbolic links are in the `-dev` package and not in any of the other packages. In general, these symlinks are only useful for development purposes. Thus, the `-dev` package is the correct location for them. Some very rare cases do exist for dynamically loaded modules where these symlinks are needed instead in the main package.

- `debug-files:` Checks for `.debug` directories in anything but the `-dbg` package. The debug files should all be in the `-dbg` package. Thus, anything packaged elsewhere is incorrect packaging.

- `arch:` Checks the Executable and Linkable Format (ELF) type, bit size and endianness of any binaries to ensure it matches the target architecture. This test fails if any binaries don't match the type since there would be an incompatibility. Sometimes software, like bootloaders, might need to bypass this check.

- `debug-deps:` Checks that `-dbg` packages only depend on other `-dbg` packages and not on any other types of packages, which would cause a packaging bug.

- `dev-deps:` Checks that `-dev` packages only depend on other `-dev` packages and not on any other types of packages, which would be a packaging bug.

- `pkgconfig:` Checks `.pc` files for any `TMPDIR/WORKDIR` paths. Any `.pc` file containing these paths is incorrect since `pkg-config` itself adds the correct sysroot prefix when the files are accessed.

- `la:` Checks `.la` files for any `TMPDIR` paths. Any `.la` file continaing these paths is incorrect since `libtool` adds the correct sysroot prefix when using the files automatically itself.

- `desktop:` Runs the `desktop-file-validate` program against any `.desktop` files to validate their contents against the specification for `.desktop` files.