
On 07/27/2017 04:51 PM, Marek Marczykowski-Górecki wrote:
On Thu, Jul 27, 2017 at 03:24:38PM -0600, Jim Fehlig wrote:
Did you have any comment on the approach taken in the attachments to this thread? Particularly the patch titled "libxl: make emulator checks mockable"? I don't see how macros could solve this - those are expanded at individual files compilation time. And you don't recompile the driver for tests.
Right. I went back to my mocking attempt and thought that I had something working https://www.redhat.com/archives/libvir-list/2017-July/msg01335.html But while testing I forgot to remove my /usr/lib/xen/bin/qemu-system-i386 specified in the test files. Once I renamed it, the tests fail with "unsupported configuration: emulator '/usr/lib/xen/bin/qemu-system-i386' not found". So the mocked emulator checks are not called :-(.
Something that could work would be putting those two functions into separate shared object, then override using LD_PRELOAD or something like this. But it would require significant change in the driver structure just for tests. Alternatively something similar could be done by covering lower level functions (virFileExists, virCommandRun, or even open, stat etc). Using /bin/true is much simpler anyway.
Unless you spot something obvious in the V2 that I've overlooked, I'm beginning to agree. Regards, Jim