cpp_box icon indicating copy to clipboard operation
cpp_box copied to clipboard

Increase test coverage of data processing instructions

Open lefticus opened this issue 7 years ago • 0 comments
trafficstars

You can see here in codecov that the unit tests are only covering about 1/2 of the possible Data Processing instructions that the ARM supports.

https://codecov.io/gh/lefticus/cpp_box/src/master/include/cpp_box/arm.hpp#L725...742

You can see details about the instruction format and architecture supported in the README

The instructions to test can be generated by hand or with an ARM assembler or compiler (using objdump on an ARM object file can be quite revealing)

$ clang++ --target=armv4-linux -stdlib=libc++ -O3 some_file.cpp -o some_file.o
$ llvm-objdump --disassemble some_file.o

Tests are located here: https://github.com/lefticus/cpp_box/blob/master/test/constexpr_tests.cpp

There are a couple of important things to notice:

  • We are using a macro so that the tests can be built in either constexpr or not. This is important for debugging. A constexpr build will simply fail to build if there is a problem, and this makes debugging the issue very difficult.
  • The relaxed_constexpr_tests binary is built specifically for this reason, so we can test all aspects of the CPU as either constexpr or not
  • Follow the patterns shown for how to enable a specific test for both constexpr and non-constexpr
  • Do not limit yourself to just the catch2 directives I'm using - be as explicit and verbose with the test descriptions as you would like. (see also, for example https://github.com/catchorg/Catch2/blob/master/docs/test-cases-and-sections.md#top)
  • Try to make the tests small, so it's possible to debug them more easily
  • Consider what register values you need to set up. Consider adding a new overload to run that takes a set of pre-set register values if desired.
  • Look at CMP test for a basic design https://github.com/lefticus/cpp_box/blob/master/test/constexpr_tests.cpp#L94-L101

Once you have made the PR we should be able to see the change in test coverage in the PR report on github.

Feel free to make multiple PRs as well, for different instruction tests.

lefticus avatar Sep 16 '18 23:09 lefticus