Elfspy fork using the meson build system.
Go to file
sergiotarxz 9368209522 Fixing global mock deletion support. 2022-08-02 11:13:23 +02:00
elfspy Fixing global mock deletion support. 2022-08-02 11:13:23 +02:00
examples added rpath 2018-03-17 09:05:02 +01:00
images cropped 2016-10-09 13:57:12 +02:00
.gitignore Adding meson.build to generate pkg-config. 2022-07-17 20:29:55 +02:00
Call.cpp externing the list correctly 2022-08-02 07:37:27 +02:00
ELFInfo.cpp cache debug directory scans 2018-03-16 23:39:49 +01:00
Error.cpp Initial version 2016-09-16 17:45:35 +02:00
Fail.cpp Initial version 2016-09-16 17:45:35 +02:00
GOTEntry.cpp Moving all headers to elfspy/ 2022-08-02 06:53:52 +02:00
Hook.cpp Fixing global mock deletion support. 2022-08-02 11:13:23 +02:00
LICENSE Create LICENSE 2018-03-19 15:55:19 +01:00
MFile.cpp Minor change 2018-03-15 19:53:38 +01:00
README README change 2016-09-30 18:32:32 +02:00
README.md Update README.md 2018-04-12 00:30:06 +02:00
Report.cpp Initial version 2016-09-16 17:45:35 +02:00
SPY.cpp Initial version 2016-09-16 17:45:35 +02:00
SectionHeader.cpp Support for better syntax 2018-03-15 19:56:25 +01:00
meson.build Fixing global mock deletion support. 2022-08-02 11:13:23 +02:00


ELFspy is a library for linux for writing tests using fakes and spies in C++. For very large call graphs, the testing of the higher nodes can be difficult due to the sum of dependencies of lower nodes e.g. databases, network connections etc. Adding fakes and spies to the callees of a function allows it to be tested in isolation without the inherited dependencies.

ELFspy works by allowing code to externally modify an existing implementation/library of a program. This is achieved by changing function addresses in the global offset tables of the running program, so that these are redirected to a different function created by ELFspy. This allows new functions to be interjected between the caller and the callee to spy on the arguments and return value. In addition the original function can be replaced with a simulation (fake) of the original. The code under test needs no changes and is unaware of the additional calls that are being made in between a caller and a callee.

Call graph before change

External code:

auto add_spy = SPY(&add);

Call graph after change(the code does not change, but the runtime execution does)

This technique relies on code being compiled as position independent code and uses the Executable and Linking Format(ELF) information found in the executable and its shared libraries to find the global offset table entries and modify them.

To see how ELFspy can be used start by reading this example