Attention is currently required from: Nico Huber, David Hendricks, Edward O'Callaghan.
2 comments:
Patchset:
Nico, sorry for a delay, I just needed some time to think about it. […]
Good news: I made it work! No need to include unittest_env.h in every file under test, they are now all covered. I inspected object files with nm, everything built for tests has malloc, free etc redefined, at the same time files built for real have normal memory functions.
Specifically:
nm builddir/tests/flashrom_unit_tests.p/.._flashrom.c.o
Has _test_calloc _test_free _test_malloc _test_realloc
nm builddir/flashrom.p/flashrom.c.o
Has calloc free malloc realloc
Side effect is that now running ninja test produces warnings (but seems fine, especially given this is exactly what’s happening). Example of warning (there are 4 of them)
In file included from ../tests/flashrom.c:19:
../tests/unittest.h:27: warning: "malloc" redefined
27 | #define malloc test_malloc
|
In file included from <command-line>:
../unittest_env.h:46: note: this is the location of the previous definition
46 | #define malloc(size) _test_malloc(size, __FILE__, __LINE__)
However the same approach did not work for test files :( so I am still including unittest.h into a test file, not from tests/meson.build. Which I hope is less of a problem, since this is now contained in tests/ directory.
Patchset:
I have the first attempt to include unittest_env.h from command line for all files under test. This solution is working, but comments are very welcome!
To view, visit change 51243. To unsubscribe, or for help writing mail filters, visit settings.