Update README.md

This commit is contained in:
Robin Nicholson 2018-04-12 00:30:06 +02:00 committed by GitHub
parent 7a0364174c
commit 61629ee4ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -1,11 +1,15 @@
ELFspy is a library for linux for writing tests using [fakes and spies](http://xunitpatterns.com/Test%20Double.html) 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 the program to change 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.
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
![](https://github.com/mollismerx/elfspy/blob/master/images/spy%20before.png)
External code:
```C++
auto add_spy = SPY(&add);
```
Call graph after change(the code does not change, but the runtime execution does)
![](https://github.com/mollismerx/elfspy/blob/master/images/spy%20after.png)