Loading…
For full conference details, please visit the 2018 European LLVM Developers’ Meeting website.
Back To Schedule
Monday, April 16 • 11:55am - 12:15pm
Compile-Time Function Call Interception to Mock Functions in C/C++

Sign up or log in to save this to your schedule, view media, leave feedback and see who's attending!

In C/C++, test code is often interwoven with the production code we want to test. During the test development process we often have to modify the public interface of a class to replace existing dependencies; e.g. a supplementary setter or constructor function is added for dependency injection. In many cases, extra template parameters are used for the same purpose. These solutions may have serious detrimental effects on code structure and sometimes on run-time performance as well. We introduce a new technique that makes dependency replacement possible without the modification of the production code, thus it provides an alternative way to add unit tests. Our new compile-time instrumentation technique modifies LLVM IR, thus enables us to intercept function calls and replace them in runtime. Contrary to existing function call interception (FCI) methods, we instrument the call expression instead of the callee, thus we can avoid the modification and recompilation of the function in order to intercept the call. This has a clear advantage in case of system libraries and third party shared libraries, thus it provides an alternative way to automatize tests for legacy software. We created a prototype implementation based on the LLVM compiler infrastructure which is publicly available for testing.

Speakers
avatar for Gábor Márton

Gábor Márton

Ericsson
Gábor has been working with C++ since 2000. Currently, he is the member of Ericsson's CodeChecker program analysis team. He works on Cross Translation Unit (CTU) static analysis and the related ASTImporter of the LLVM/Clang compiler infrastructure.In 2019 he defended his PhD theses... Read More →


Monday April 16, 2018 11:55am - 12:15pm BST
Bristol 1 & 2