Move test harness to inline c
This change hopes to address some of the concerns described in https://github.com/AFLplusplus/LibAFL/issues/1799.
This PR moves the Frida ASAN test from an external cpp file to inline c. This is done by having the #inline_c_rs CFLAGS: "-shared" flag at the top which forces it to compile as a shared library. The shared library is then loaded via libloading.
Note that this may break the tests in https://github.com/AFLplusplus/LibAFL/pull/1607. However, if needed, more flags can be introduced.
Thanks!
I'd like to see:
- That we can build and run tests on windows too using
cargo xwinwith wine and/or native on-windows compilation. - a macro for defining a test case, which generates the boiler plate necessary, when provided with a C++ block and some expectations.
Due to the substantial changes needed to inline-c, a fork has been created here: https://github.com/mineo333/libafl-inline-c-rs
Support for compiling as a shared library and cross-compilation is being added.
What's the benefit over simply having a c file lying around? Isn't this way more confusing for new developers joining the project? Also, we won't have clang format nor code completion for inline C, right?
What's the benefit over simply having a c file lying around? Isn't this way more confusing for new developers joining the project? Also, we won't have clang format nor code completion for inline C, right?
I think it could be easier in the long term mainly because the cc stuff would be abstracted out via the inline_c_rs options at the top. We also wouldn't have a growing build script every time we need to have a test. However, there definitely would be a small learning curve when using this.
Also, clang format nor code completion would be available with this.
I agree... The C/C++ snippets are parts of the test fixture. It's very annoying when the test fixure is spread over mulitiple files/localtions.
With this, you have the whole test self-contained in a single location.
Maybe break it up into individual tests?
I agree... The C/C++ snippets are parts of the test fixture. It's very annoying when the test fixure is spread over mulitiple files/localtions.
With this, you have the whole test self-contained in a single location.
Personally I think fn test_frida_cmplog() in rust could just as easily map directly to something like ./tests/test_frida_cmplog.c, it wouldn't be much more friction to write, and get around all of the macro vodoo..
But ultimately I'll trust your judgement. :)
Let's see how we can refine the test macro as we build out some tests...
What's the status?
Right now, in terms of splitting the tests, there's a weird problem where because the frida hooks are not deinit'd, it is effectively impossible to create multiple frida helpers. The ideal solution for that is what @s1341 implemented in https://github.com/AFLplusplus/LibAFL/pull/1607/ with callouts, so I'm going to see what I can do with that.