Skip to content
AdaCorePublic

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

GNATtest

gnattest generates unit-test skeletons and a complete test-driver infrastructure for Ada code, based on Libadalang. Given a GNAT project, it produces:

  • AUnit-based test skeletons, one per subprogram declared in the project's visible specs;
  • a test harness (drivers, suites, aggregator) that builds and runs those tests and reports results;
  • optional stub-based and TGen-based (automatically generated test inputs) testing infrastructure.

It also runs the generated drivers and aggregates their results when invoked on a test_drivers.list file.

Run gnattest --help for the full list of options.

Requirements

To build gnattest you need a GNAT toolchain with gprbuild, plus the following libraries available on your GPR_PROJECT_PATH:

  • Libadalang (libadalang.gpr);
  • GPR2 (gpr2.gpr);
  • Templates Parser (templates_parser.gpr);
  • XML/Ada.

Building against this repository's main branch requires the matching stable releases of Libadalang and Langkit.

Build

From the top of the repository, after git submodule update --init to fetch the bundled AUnit, Unity and Google Test sources:

# Build gnattest, its library, and the testsuite drivers.
make

# Install the gnattest binaries into ./local/bin (stripped in prod builds).
make install-bin-strip DESTDIR=local

# Install the TGen support files (runtime sources and templates) into ./local.
make install-tgen DESTDIR=local

# Install the sources of the bundled test libraries into ./local.
make install-aunit DESTDIR=local
make install-unity DESTDIR=local
make install-gtest DESTDIR=local

By default this produces a development build (BUILD_MODE=dev). For a production build, pass BUILD_MODE=prod, e.g.:

make BUILD_MODE=prod LIBRARY_TYPE=static

Host TGen is built as a separate library in static, position-independent static, and shared variants. make install-lib DESTDIR=local installs its tgen.gpr project along with the GNATtest libraries. Clients that only use TGen can import tgen.gpr without linking the GNATtest tool code. The host library is named tgen, and the target runtime is named tgen_rts. To build only host TGen, run make lib-tgen-static.

The TGen runtime project must then be built and installed so that generated drivers can link against it:

gprbuild   -P local/share/tgen/tgen_rts/tgen_rts.gpr
gprinstall -P local/share/tgen/tgen_rts/tgen_rts.gpr -p

After installation, the gnattest executable lives in local/bin/. Run local/bin/gnattest setup to build and install the test libraries for your toolchain; --lang restricts it to some of Ada, C and C++ (see gnattest setup --help).

Testing

The testsuite is driven by e3-testsuite. Install it (e.g. pip install e3-testsuite) and make sure the freshly built gnattest is on your PATH.

The simplest way to build everything and run the full testsuite is:

make test

Alternatively, run the testsuite directly. From the testsuite/ directory:

./testsuite.py [--setup-tgen-rts]
  • --setup-tgen-rts builds and installs the TGen runtime as part of the run; it is only needed if you have not already installed it (see the build step above).
  • The testsuite writes its report to an out/ directory in the current working directory.

To run only specific testcases, pass their paths as arguments:

./testsuite.py tests/test/gtest-basic tests/test/60-stub-from-runtime

Use --show-error-output to see the diff between expected and actual output, and ./testsuite.py --help to discover the remaining options. See testsuite/README.rst for more details.

Contributing

See CONTRIBUTING.md.

License

All source files in this repository are licensed under the terms of the GNU General Public License version 3 (GPLv3). See the LICENSE file for more information.

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages