Commit Graph

41 Commits

Author SHA1 Message Date
Giacomo Vercesi c32bc92f9c revng.daemon: introduce tests
Add end-to-end tests checking that every GraphQL endpoint is properly
working and returning the expected result
2022-04-26 15:05:30 +02:00
Massimo Fioravanti c4aa92694c Introduce revng model apply 2022-04-15 15:15:41 +02:00
Alessandro Di Federico 2b55d1df22 Adopt cmake-format 2022-03-17 18:52:18 +01:00
Filippo Cremonese 7f7a222410 python-model: handle importing multiple versions 2022-02-23 18:03:36 +01:00
Ivan Krysak 1df6bbc6d6 Introduce ABI testing infrastructure 2022-02-14 13:35:37 +01:00
Massimo Fioravanti 67f9cbdf4c Introduce the revng-pipeline CLI tool 2022-02-08 00:05:03 +01:00
Alessandro Di Federico de172232e6 Run the most specific tests first 2020-05-14 11:59:05 +02:00
Alessandro Di Federico 9e52b0c473 Switch ARM tests to Thumb 2020-05-14 11:59:05 +02:00
Alessandro Di Federico 12d093b459 Rethink testing
This commit performs the changes necessary in order to integrate with
revng-qa, the new project for cross-project quality assurance.

Basically, the source code of all the tests has been moved in revng-qa,
which will take care of producing "artifacts" (i.e., compiled programs),
using the appropriate cross-compilers.

revng will then consume them and produce new artifacts to be consumed by
other tools down the pipeline.

The directory structure of the tests has been reworked to reflect
`revng-qa`. A large amount of boilerplate code has been dropped.

Note that certain actions, that used to be carried out during testing,
are now part of the regular build process. Specifically, lifting the
tests is performed at build time, so that they can be installed.
2020-02-20 12:16:56 +01:00
Alessandro Di Federico 5513ae606c Force the text segment at 0x20000 on ARM
For a long time we had an issue on ARM: the linker would use as the
first page 0x10000. However, on many distros, that matches the first
page that can be mapped (see `/proc/sys/vm/mmap_min_addr`). Therefore,
this shouldn't be a problem, except the fact that the translated program
also needs the preceeding page for the (outer) ELF header.

We used to suggest users to run:

    echo 4096 | sudo tee /proc/sys/vm/mmap_min_addr

Now in our tests, we force the text segment page to be at 0x20000,
therefore, this will no longer be necessary.
2018-09-21 17:27:22 +02:00
Andrea Gussoni 0735acd2a0 Add checks for no-pie flag for cross-compilers
The check to see if a compiler supports the `no-pie` flag was done only
for the main C compiler, and not for the cross-compilers used for
creating the executables for the different supported architectures.

This commit introduces the aforementioned missing checks.

In addition instead of hard-coding the flags to check in the CMakeLists
file we have a list that we pass each time we instantiate a project for
the cross-compilers, and we check for the availability of all the flags.

In order to do this we need to apply a sort of serialization and
deserialization to avoid the "unpack" of the list passed as argument to
the external project (that is implemented as a `;` separated string).

Also implemented a fix suggested in the merge request for a line that
mistakenly added the `TEST_CFLAGS` variable to the `NO_PIE` variable.
2018-01-17 21:11:41 +01:00
Alessandro Di Federico d409390084 Unit testing for LazySmallBitVector
This commit introduces the unit test infrastructure, and a first unit
test suite for `LazySmallBitVector`.
2017-08-12 16:56:23 +02:00
Alessandro Di Federico f6b6138408 Introduce tests for the analyses
So far we only had end-to-end functionality testing. This commit
introduces a new part of the testsuite which allows to verify quickly if
the results that a certain analysis should give are changed or not. This
is vital to be able to make larger changes.

So far the test suite is composed by the most difficult case we support
(the uClibc ARM memset) and the typical lowering of switch statements
for ARM, MIPS and x86-64.

I'm so happy now.
2016-12-08 21:50:49 +01:00
Alessandro Di Federico a7f1097988 Improve testsuite
* Add a label for runtime and analysis tests
* Add support for per-test custom compile flags
2016-12-04 00:28:57 +01:00
Alessandro Di Federico f67f7aef77 Reorganize testsuite
So far the only tests we had were end to end tests to assess the
functionality of simple programs and, in particular, certain helper
functions. In the perspective of being able to test individual features,
and in particular check that we have no regressions in our analyses, we
isolated these end to end tests in the Runtime directory. We kept in the
root test directory the mechanism to compile a binary for a certain
architecture so that all the test types can use it.
2016-12-04 00:28:57 +01:00
Alessandro Di Federico bc6a732ad7 Don't compute function boundaries by default 2016-12-03 08:46:12 +01:00
Alessandro Di Federico 83ea2caacd Isolate ELF code and remove architecture parameter
This commit removes all the ELF-specific code from the `CodeGenerator`
class by creating a new class, `BinaryFile` which contains all the
information about the program that might be needed in an image format
independent way. However, `BinaryFile` has some fields which are
specific to ELF, we might want to address this when additional file
formats are supported.

A key benefit of isolating this code is that we can anticipate the
parsing of the input file, so that we have its architecture available
earlier than when `CodeGenerator` is instantiated, therefore we can drop
the `--architecture` parameter.
2016-12-03 08:46:12 +01:00
Alessandro Di Federico d48715494d Improve installation
* Use "$ORIGIN/../lib/" as RPATH when linking the installed binary
* Install also support material such as "support.c"
* Import the `translate` script for easy end-to-end translation
2016-09-22 22:44:16 +02:00
Alessandro Di Federico 59c871afc5 Make revamb portable
Add different search paths for QEMU components, in paritcular relative
to the program's path.
Also, install the revamb.
2016-09-22 18:45:59 +02:00
Alessandro Di Federico d01ee1f437 Copyright notices, license and credits 2016-09-21 01:45:26 +02:00
Alessandro Di Federico 53b1dfbb5d Improve autodetection of QEMU's location 2016-09-21 01:45:26 +02:00
Alessandro Di Federico f0c12bfac4 Fixes to the testing infrastructure
* Disable PIE if enabled by default
* Link librt.so to compiled binaries (sometimes the QEMU runtime needs
  it)
* Replace `strtonum` with `int` in `awk` script
* Specify the compiler, not the triple
2016-09-21 01:45:26 +02:00
Alessandro Di Federico c7990ae60c Autodetect the compiler to use
Check in PATH if there's a compiler compatible with the supported ones
(i.e., using uclibc or musl) and use that triple.
2016-09-21 01:45:19 +02:00
Alessandro Di Federico 6c5c0ad8f7 Add support for using section information 2016-09-17 15:33:54 +02:00
Alessandro Di Federico 9487f0e400 Assign labels to tests 2016-09-17 15:33:54 +02:00
Alessandro Di Federico 4e04f0eed5 Copy run-time files to build directory 2016-08-20 03:10:46 +02:00
Alessandro Di Federico 0d035a93e1 Introduce clang support: fixes and cleanup 2016-08-20 03:10:45 +02:00
Alessandro Di Federico c8274af360 Let tests run from _start 2016-01-30 11:15:50 +01:00
Alessandro Di Federico 32b756510f Prepare stack for the translated program
* Create 3 constant global variables (`phdr_address`, `e_phentsize` and
  `e_phnum`) in the IR which will be used to populate the auxiliary
  vectors at run-time.
* Update compile options for `support.c` to ignore useless warnings and
  enable debug information
* Implement in `support.c` some functions required by QEMU run-time and
  other cleanups to make it compatible with programs translated from
  `_start`, not `root`
* Implement in `support.c` the `prepare_stack` function, which
  initializes the base of the stack with environment variables,
  arguments and auxiliary vectors
* Improve syscall support
2016-01-30 11:15:04 +01:00
Alessandro Di Federico 71f919675e Speedup compilation by using llc -O0 2016-01-30 10:57:15 +01:00
Alessandro Di Federico ea61c896fb Introduce dependencies among tests 2016-01-12 18:00:51 +01:00
Alessandro Di Federico d510fea8c7 Simplify command line usage exploiting ELF info
* s/`importGlobalData`/`parseELF`/
* Save the entry point specified in the ELF header, which will be used
  if the user doesn't provide an address.
* Let parse `parseELF` take care of informing libtinycode about what
  has to be mmap'd and where.
* Remove some support scripts used during testing, now no longer
  necessary.
* Various cleanups
2016-01-09 13:37:03 +01:00
Alessandro Di Federico 51ca34634b global.c: a new test for access to global data 2016-01-07 14:17:39 +01:00
Alessandro Di Federico 8ca9156be3 Add a simple test for the getuid syscall 2016-01-04 21:47:34 +01:00
Alessandro Di Federico f36bc6b42f Introduce tests for floaing point operations 2015-12-04 23:45:50 +01:00
Alessandro Di Federico 1d4e3169eb Add support for indirect jumps and function calls
The main aim of these changes is to support `ret` instructions (that are
indirect jumps), so that function calls can now work properly.

* Emit a dummy call to a `@newPC` function to record where a new
  instruction in the original assembly started, what is its PC and its
  size. The `Size` parameter for these function call is initially zero,
  and it's updated later when a new instruction is met or the current
  basic block is terminated. All these calls, before the final emission
  of the IR are removed `InstructionTranslator::removeNewPCMarkers`.
* Transform translateMoveToPC into an LLVM pass
  (`TranslateDirectBranchesPass`).
* Implement `getNextPC`, which returns the next program counter by
  looking for a call to `@newpc` in the current basic block, and,
  recursively, in all the basic blocks dominating the current one. This
  function is used to force exploration of the basic block coming after
  a direct jump, which is paritcularly useful in case of a function call.
* Introduce `translateIndirectJumps`, which translates all the leftover
  writes to the PC, i.e. all the indirect ones, by diverting execution
  to a large switch statement mapping addresses in the original program
  to the corresponding basic blocks in the translated program.
* Introduce `function_call`, a simple test for function calls.
* Other minor changes and whitespace fixes.
2015-11-15 12:06:17 +01:00
Alessandro Di Federico 94864e49b5 Introduce support for virtual addresses
* mmap on the PTC side before doing any translation
* Update usages of virtual addresses
* Refactor options to have --load-at and --entry
* Update tests according to the changes
2015-11-10 00:05:21 +01:00
Alessandro Di Federico 91a01937cf Let support.c know about the target architecture 2015-11-07 15:02:12 +01:00
Alessandro Di Federico f6ae68516d Use llc from the given LLVM installation 2015-11-07 15:01:34 +01:00
Alessandro Di Federico 15cfbee422 Make reference to QEMU install path and dlopen an absolute path 2015-10-27 11:56:08 +01:00
Alessandro Di Federico 9cf82f36d8 Introduce testing framework
* Import single-function calculator
* Create a puppet CMake project for cross-compiling
* Create a CMake manager for the tests
2015-10-27 09:13:14 +01:00