m4/virt-driver-libxl.m4 | 6 +- src/libxl/libxl_capabilities.c | 37 ++--- src/libxl/libxl_conf.c | 14 -- tests/Makefile.am | 18 ++- tests/libxlxml2domconfigdata/basic-hvm.json | 89 +++++++++++ tests/libxlxml2domconfigdata/basic-hvm.xml | 36 +++++ tests/libxlxml2domconfigdata/basic-pv.json | 65 ++++++++ tests/libxlxml2domconfigdata/basic-pv.xml | 28 ++++ tests/libxlxml2domconfigdata/moredevs-hvm.json | 111 +++++++++++++ tests/libxlxml2domconfigdata/moredevs-hvm.xml | 63 ++++++++ tests/libxlxml2domconfigtest.c | 208 +++++++++++++++++++++++++ tests/virmocklibxl.c | 87 +++++++++++ 12 files changed, 723 insertions(+), 39 deletions(-) create mode 100644 tests/libxlxml2domconfigdata/basic-hvm.json create mode 100644 tests/libxlxml2domconfigdata/basic-hvm.xml create mode 100644 tests/libxlxml2domconfigdata/basic-pv.json create mode 100644 tests/libxlxml2domconfigdata/basic-pv.xml create mode 100644 tests/libxlxml2domconfigdata/moredevs-hvm.json create mode 100644 tests/libxlxml2domconfigdata/moredevs-hvm.xml create mode 100644 tests/libxlxml2domconfigtest.c create mode 100644 tests/virmocklibxl.c
Long ago danpb posted some patches to test libvirt domXML to libxl_domain_config conversion https://www.redhat.com/archives/libvir-list/2014-May/msg01102.html Some of the prerequisite patches were pushed, but we've never managed to push patches actually providing the conversion tests. I sent several follow-ups to Dan's work but never converged on a satisfactory solution for all the Xen versions supported by libvirt. The last attempt was in Sept 2014 https://www.redhat.com/archives/libvir-list/2014-September/msg00698.html I tried to revive the work in Jan 2015, but that also stalled https://www.redhat.com/archives/libvir-list/2015-January/msg00924.html Fast-forward over 2.5 years from the first attempt and libvirt no longer supports older Xen versions 4.2 and 4.3 that were proving to be problematic. Starting with Xen 4.5 libxl added support for libxl_domain_config_from_json, which provides a way to implement the conversion tests that work with all Xen versions >= 4.5 (including latest xen.git master). The previous approaches compared a static json doc with the results of domXML->libxl_domain_config conversion done in the libxl driver. As discussed in those approaches, the json doc returned from libxl_domain_config_to_json can change over Xen releases as the libxl_domain_config object gains new fields, making it difficult to compare the conversion with a static doc. I had some time last week to pick at this thorn and reworked the test to make use of libxl_domain_config_from_json introduced in Xen 4.5. Instead of comparing the conversion results directly to a static json doc, the static doc is first round-tripped through _from_json -> _to_json. Any new fields added to libxl_domain_config object are then included in both docs, allowing comparison across multiple Xen releases. Patch3 provides the conversion tests using this new approach. The tests are not run on Xen 4.4 (oldest version currently supported by libvirt) since it does not provide libxl_domain_config_from_json. Patches 1 and 2 fix some issues found while working on the tests. See their commit messages for details. Jim Fehlig (3): libxl: determine device model version from emulator name libxl: relax checks on <emulator> libxl: Add a test suite for libxl_domain_config generator m4/virt-driver-libxl.m4 | 6 +- src/libxl/libxl_capabilities.c | 37 ++--- src/libxl/libxl_conf.c | 14 -- tests/Makefile.am | 18 ++- tests/libxlxml2domconfigdata/basic-hvm.json | 89 +++++++++++ tests/libxlxml2domconfigdata/basic-hvm.xml | 36 +++++ tests/libxlxml2domconfigdata/basic-pv.json | 65 ++++++++ tests/libxlxml2domconfigdata/basic-pv.xml | 28 ++++ tests/libxlxml2domconfigdata/moredevs-hvm.json | 111 +++++++++++++ tests/libxlxml2domconfigdata/moredevs-hvm.xml | 63 ++++++++ tests/libxlxml2domconfigtest.c | 208 +++++++++++++++++++++++++ tests/virmocklibxl.c | 87 +++++++++++ 12 files changed, 723 insertions(+), 39 deletions(-) create mode 100644 tests/libxlxml2domconfigdata/basic-hvm.json create mode 100644 tests/libxlxml2domconfigdata/basic-hvm.xml create mode 100644 tests/libxlxml2domconfigdata/basic-pv.json create mode 100644 tests/libxlxml2domconfigdata/basic-pv.xml create mode 100644 tests/libxlxml2domconfigdata/moredevs-hvm.json create mode 100644 tests/libxlxml2domconfigdata/moredevs-hvm.xml create mode 100644 tests/libxlxml2domconfigtest.c create mode 100644 tests/virmocklibxl.c -- 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On Sun, Feb 26, 2017 at 07:02:24PM -0700, Jim Fehlig wrote: > Long ago danpb posted some patches to test libvirt domXML to > libxl_domain_config conversion > > https://www.redhat.com/archives/libvir-list/2014-May/msg01102.html > > Some of the prerequisite patches were pushed, but we've never managed > to push patches actually providing the conversion tests. I sent several > follow-ups to Dan's work but never converged on a satisfactory solution > for all the Xen versions supported by libvirt. The last attempt was in > Sept 2014 > > https://www.redhat.com/archives/libvir-list/2014-September/msg00698.html > > I tried to revive the work in Jan 2015, but that also stalled > > https://www.redhat.com/archives/libvir-list/2015-January/msg00924.html > > Fast-forward over 2.5 years from the first attempt and libvirt no longer > supports older Xen versions 4.2 and 4.3 that were proving to be problematic. > Starting with Xen 4.5 libxl added support for libxl_domain_config_from_json, > which provides a way to implement the conversion tests that work with all > Xen versions >= 4.5 (including latest xen.git master). Few more months have passed... FWIW, I've tested it with Xen 4.6. The patch needs very minor update: - s/VIRT_TEST_MAIN_PRELOAD/VIR_TEST_MAIN_PRELOAD/ - add xencaps argument to libxlBuildDomainConfig call After that, it works! When I made some test to fail, reported error is not so helpful ("libvirt: Xen Light Driver error : internal error: Expected and actual libxl_domain_config objects do not compare"), but it do catch failures. Then, if I change strcmp to virTestCompareToString, the output is much more helpful. I'd really love to have it merged, mostly because I want to add more tests using this framework (see "Add setting CPU features (CPUID) with libxenlight driver" thread). Is there anything I can do to make it happen? -- Best Regards, Marek Marczykowski-Górecki Invisible Things Lab A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On Sun, Jul 02, 2017 at 04:16:02AM +0200, Marek Marczykowski-Górecki wrote: > On Sun, Feb 26, 2017 at 07:02:24PM -0700, Jim Fehlig wrote: > > Long ago danpb posted some patches to test libvirt domXML to > > libxl_domain_config conversion > > > > https://www.redhat.com/archives/libvir-list/2014-May/msg01102.html > > > > Some of the prerequisite patches were pushed, but we've never managed > > to push patches actually providing the conversion tests. I sent several > > follow-ups to Dan's work but never converged on a satisfactory solution > > for all the Xen versions supported by libvirt. The last attempt was in > > Sept 2014 > > > > https://www.redhat.com/archives/libvir-list/2014-September/msg00698.html > > > > I tried to revive the work in Jan 2015, but that also stalled > > > > https://www.redhat.com/archives/libvir-list/2015-January/msg00924.html > > > > Fast-forward over 2.5 years from the first attempt and libvirt no longer > > supports older Xen versions 4.2 and 4.3 that were proving to be problematic. > > Starting with Xen 4.5 libxl added support for libxl_domain_config_from_json, > > which provides a way to implement the conversion tests that work with all > > Xen versions >= 4.5 (including latest xen.git master). > > Few more months have passed... > > FWIW, I've tested it with Xen 4.6. The patch needs very minor update: > - s/VIRT_TEST_MAIN_PRELOAD/VIR_TEST_MAIN_PRELOAD/ > - add xencaps argument to libxlBuildDomainConfig call > > After that, it works! When I made some test to fail, reported error is > not so helpful ("libvirt: Xen Light Driver error : internal error: > Expected and actual libxl_domain_config objects do not compare"), but it > do catch failures. > Then, if I change strcmp to virTestCompareToString, the output is much > more helpful. > > I'd really love to have it merged, mostly because I want to add more tests > using this framework (see "Add setting CPU features (CPUID) with > libxenlight driver" thread). > Is there anything I can do to make it happen? Ping? -- Best Regards, Marek Marczykowski-Górecki Invisible Things Lab A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On 07/01/2017 08:16 PM, Marek Marczykowski-Górecki wrote: > On Sun, Feb 26, 2017 at 07:02:24PM -0700, Jim Fehlig wrote: >> Long ago danpb posted some patches to test libvirt domXML to >> libxl_domain_config conversion >> >> https://www.redhat.com/archives/libvir-list/2014-May/msg01102.html >> >> Some of the prerequisite patches were pushed, but we've never managed >> to push patches actually providing the conversion tests. I sent several >> follow-ups to Dan's work but never converged on a satisfactory solution >> for all the Xen versions supported by libvirt. The last attempt was in >> Sept 2014 >> >> https://www.redhat.com/archives/libvir-list/2014-September/msg00698.html >> >> I tried to revive the work in Jan 2015, but that also stalled >> >> https://www.redhat.com/archives/libvir-list/2015-January/msg00924.html >> >> Fast-forward over 2.5 years from the first attempt and libvirt no longer >> supports older Xen versions 4.2 and 4.3 that were proving to be problematic. >> Starting with Xen 4.5 libxl added support for libxl_domain_config_from_json, >> which provides a way to implement the conversion tests that work with all >> Xen versions >= 4.5 (including latest xen.git master). > > Few more months have passed... And a few more weeks :-). Sorry for the delay. Slowly catching up on libvirt mail after some time away... > > FWIW, I've tested it with Xen 4.6. The patch needs very minor update: > - s/VIRT_TEST_MAIN_PRELOAD/VIR_TEST_MAIN_PRELOAD/ > - add xencaps argument to libxlBuildDomainConfig cal > > > After that, it works! When I made some test to fail, reported error is > not so helpful ("libvirt: Xen Light Driver error : internal error: > Expected and actual libxl_domain_config objects do not compare"), but it > do catch failures. > Then, if I change strcmp to virTestCompareToString, the output is much > more helpful. Thanks for the improvements. I noticed you included them in your V2 of patch 3/3. I assume you needed patches 1 and 2 as well? > I'd really love to have it merged, mostly because I want to add more tests > using this framework (see "Add setting CPU features (CPUID) with > libxenlight driver" thread). I really dislike patches 1 and 2. They remove very useful checks IMO. Shortly after posting the series in Feb, I tried mocking the emulator checks. I failed quite a bit before coming up with something that worked, yet not so satisfying :-). I'll attach the (now rather old) patches for reference. > Is there anything I can do to make it happen? Do you have time to update these old patches, test, and repost to the list? Or perhaps have better ideas on mocking, or approaches that avoid the need for 1/3 and 2/3. Regards, Jim -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On Fri, Jul 14, 2017 at 05:59:57PM -0600, Jim Fehlig wrote: > On 07/01/2017 08:16 PM, Marek Marczykowski-Górecki wrote: > > On Sun, Feb 26, 2017 at 07:02:24PM -0700, Jim Fehlig wrote: > > > Long ago danpb posted some patches to test libvirt domXML to > > > libxl_domain_config conversion > > > > > > https://www.redhat.com/archives/libvir-list/2014-May/msg01102.html > > > > > > Some of the prerequisite patches were pushed, but we've never managed > > > to push patches actually providing the conversion tests. I sent several > > > follow-ups to Dan's work but never converged on a satisfactory solution > > > for all the Xen versions supported by libvirt. The last attempt was in > > > Sept 2014 > > > > > > https://www.redhat.com/archives/libvir-list/2014-September/msg00698.html > > > > > > I tried to revive the work in Jan 2015, but that also stalled > > > > > > https://www.redhat.com/archives/libvir-list/2015-January/msg00924.html > > > > > > Fast-forward over 2.5 years from the first attempt and libvirt no longer > > > supports older Xen versions 4.2 and 4.3 that were proving to be problematic. > > > Starting with Xen 4.5 libxl added support for libxl_domain_config_from_json, > > > which provides a way to implement the conversion tests that work with all > > > Xen versions >= 4.5 (including latest xen.git master). > > > > Few more months have passed... > > And a few more weeks :-). Sorry for the delay. Slowly catching up on libvirt > mail after some time away... It's me this time... > > FWIW, I've tested it with Xen 4.6. The patch needs very minor update: > > - s/VIRT_TEST_MAIN_PRELOAD/VIR_TEST_MAIN_PRELOAD/ > > - add xencaps argument to libxlBuildDomainConfig cal > > > > > After that, it works! When I made some test to fail, reported error is > > not so helpful ("libvirt: Xen Light Driver error : internal error: > > Expected and actual libxl_domain_config objects do not compare"), but it > > do catch failures. > > Then, if I change strcmp to virTestCompareToString, the output is much > > more helpful. > > Thanks for the improvements. I noticed you included them in your V2 of patch > 3/3. I assume you needed patches 1 and 2 as well? Yes, in this tests shape. But see below. > > I'd really love to have it merged, mostly because I want to add more tests > > using this framework (see "Add setting CPU features (CPUID) with > > libxenlight driver" thread). > > I really dislike patches 1 and 2. They remove very useful checks IMO. > Shortly after posting the series in Feb, I tried mocking the emulator > checks. I failed quite a bit before coming up with something that worked, > yet not so satisfying :-). I'll attach the (now rather old) patches for > reference. My independent try to this test approach ("tests: check domain XML to libxl structures conversion") had much simpler (but uglier) solution for this problem: use /bin/true as emulator path (replaced in runtime, just after loading XML from file). While proper mocking this check would be better, apparently it isn't trivial. > > Is there anything I can do to make it happen? > > Do you have time to update these old patches, test, and repost to the list? > Or perhaps have better ideas on mocking, or approaches that avoid the need > for 1/3 and 2/3. If using /bin/true as emulator path is acceptable, I can finish this and post updated version. -- Best Regards, Marek Marczykowski-Górecki Invisible Things Lab A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On 07/26/2017 05:07 PM, Marek Marczykowski-Górecki wrote: > On Fri, Jul 14, 2017 at 05:59:57PM -0600, Jim Fehlig wrote: >> On 07/01/2017 08:16 PM, Marek Marczykowski-Górecki wrote: >>> On Sun, Feb 26, 2017 at 07:02:24PM -0700, Jim Fehlig wrote: >>>> Long ago danpb posted some patches to test libvirt domXML to >>>> libxl_domain_config conversion >>>> >>>> https://www.redhat.com/archives/libvir-list/2014-May/msg01102.html >>>> >>>> Some of the prerequisite patches were pushed, but we've never managed >>>> to push patches actually providing the conversion tests. I sent several >>>> follow-ups to Dan's work but never converged on a satisfactory solution >>>> for all the Xen versions supported by libvirt. The last attempt was in >>>> Sept 2014 >>>> >>>> https://www.redhat.com/archives/libvir-list/2014-September/msg00698.html >>>> >>>> I tried to revive the work in Jan 2015, but that also stalled >>>> >>>> https://www.redhat.com/archives/libvir-list/2015-January/msg00924.html >>>> >>>> Fast-forward over 2.5 years from the first attempt and libvirt no longer >>>> supports older Xen versions 4.2 and 4.3 that were proving to be problematic. >>>> Starting with Xen 4.5 libxl added support for libxl_domain_config_from_json, >>>> which provides a way to implement the conversion tests that work with all >>>> Xen versions >= 4.5 (including latest xen.git master). >>> >>> Few more months have passed... >> >> And a few more weeks :-). Sorry for the delay. Slowly catching up on libvirt >> mail after some time away... > > It's me this time... > >>> FWIW, I've tested it with Xen 4.6. The patch needs very minor update: >>> - s/VIRT_TEST_MAIN_PRELOAD/VIR_TEST_MAIN_PRELOAD/ >>> - add xencaps argument to libxlBuildDomainConfig cal > >>> >>> After that, it works! When I made some test to fail, reported error is >>> not so helpful ("libvirt: Xen Light Driver error : internal error: >>> Expected and actual libxl_domain_config objects do not compare"), but it >>> do catch failures. >>> Then, if I change strcmp to virTestCompareToString, the output is much >>> more helpful. >> >> Thanks for the improvements. I noticed you included them in your V2 of patch >> 3/3. I assume you needed patches 1 and 2 as well? > > Yes, in this tests shape. But see below. > >>> I'd really love to have it merged, mostly because I want to add more tests >>> using this framework (see "Add setting CPU features (CPUID) with >>> libxenlight driver" thread). >> >> I really dislike patches 1 and 2. They remove very useful checks IMO. >> Shortly after posting the series in Feb, I tried mocking the emulator >> checks. I failed quite a bit before coming up with something that worked, >> yet not so satisfying :-). I'll attach the (now rather old) patches for >> reference. > > My independent try to this test approach ("tests: check domain XML to > libxl structures conversion") had much simpler (but uglier) solution for > this problem: use /bin/true as emulator path (replaced in runtime, just > after loading XML from file). Ah, clever and devious. For that matter all the test files could be changed to <emulator>/bin/true</emulator> :-). >> Do you have time to update these old patches, test, and repost to the list? >> Or perhaps have better ideas on mocking, or approaches that avoid the need >> for 1/3 and 2/3. > > If using /bin/true as emulator path is acceptable, I can finish this and > post updated version. Did you have any comment on the approach taken in the attachments to this thread? Particularly the patch titled "libxl: make emulator checks mockable"? -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On Thu, Jul 27, 2017 at 03:24:38PM -0600, Jim Fehlig wrote: > On 07/26/2017 05:07 PM, Marek Marczykowski-Górecki wrote: > > On Fri, Jul 14, 2017 at 05:59:57PM -0600, Jim Fehlig wrote: > > > On 07/01/2017 08:16 PM, Marek Marczykowski-Górecki wrote: > > > > On Sun, Feb 26, 2017 at 07:02:24PM -0700, Jim Fehlig wrote: > > > > > Long ago danpb posted some patches to test libvirt domXML to > > > > > libxl_domain_config conversion > > > > > > > > > > https://www.redhat.com/archives/libvir-list/2014-May/msg01102.html > > > > > > > > > > Some of the prerequisite patches were pushed, but we've never managed > > > > > to push patches actually providing the conversion tests. I sent several > > > > > follow-ups to Dan's work but never converged on a satisfactory solution > > > > > for all the Xen versions supported by libvirt. The last attempt was in > > > > > Sept 2014 > > > > > > > > > > https://www.redhat.com/archives/libvir-list/2014-September/msg00698.html > > > > > > > > > > I tried to revive the work in Jan 2015, but that also stalled > > > > > > > > > > https://www.redhat.com/archives/libvir-list/2015-January/msg00924.html > > > > > > > > > > Fast-forward over 2.5 years from the first attempt and libvirt no longer > > > > > supports older Xen versions 4.2 and 4.3 that were proving to be problematic. > > > > > Starting with Xen 4.5 libxl added support for libxl_domain_config_from_json, > > > > > which provides a way to implement the conversion tests that work with all > > > > > Xen versions >= 4.5 (including latest xen.git master). > > > > > > > > Few more months have passed... > > > > > > And a few more weeks :-). Sorry for the delay. Slowly catching up on libvirt > > > mail after some time away... > > > > It's me this time... > > > > > > FWIW, I've tested it with Xen 4.6. The patch needs very minor update: > > > > - s/VIRT_TEST_MAIN_PRELOAD/VIR_TEST_MAIN_PRELOAD/ > > > > - add xencaps argument to libxlBuildDomainConfig cal > > > > > > > > > After that, it works! When I made some test to fail, reported error is > > > > not so helpful ("libvirt: Xen Light Driver error : internal error: > > > > Expected and actual libxl_domain_config objects do not compare"), but it > > > > do catch failures. > > > > Then, if I change strcmp to virTestCompareToString, the output is much > > > > more helpful. > > > > > > Thanks for the improvements. I noticed you included them in your V2 of patch > > > 3/3. I assume you needed patches 1 and 2 as well? > > > > Yes, in this tests shape. But see below. > > > > > > I'd really love to have it merged, mostly because I want to add more tests > > > > using this framework (see "Add setting CPU features (CPUID) with > > > > libxenlight driver" thread). > > > > > > I really dislike patches 1 and 2. They remove very useful checks IMO. > > > Shortly after posting the series in Feb, I tried mocking the emulator > > > checks. I failed quite a bit before coming up with something that worked, > > > yet not so satisfying :-). I'll attach the (now rather old) patches for > > > reference. > > > > My independent try to this test approach ("tests: check domain XML to > > libxl structures conversion") had much simpler (but uglier) solution for > > this problem: use /bin/true as emulator path (replaced in runtime, just > > after loading XML from file). > > Ah, clever and devious. For that matter all the test files could be changed > to <emulator>/bin/true</emulator> :-). > > > > Do you have time to update these old patches, test, and repost to the list? > > > Or perhaps have better ideas on mocking, or approaches that avoid the need > > > for 1/3 and 2/3. > > > > If using /bin/true as emulator path is acceptable, I can finish this and > > post updated version. > > 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. 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. -- Best Regards, Marek Marczykowski-Górecki Invisible Things Lab A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On Fri, Jul 28, 2017 at 05:24:10PM -0600, Jim Fehlig wrote: > 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. You can override only dynamic symbols this way. If the function is in the same object (or even the same shared library), it is resolved at link time, not load time. You can obtain list of mockable functions this way: objdump -T .../libvirt_driver_libxl.so | grep UND -- Best Regards, Marek Marczykowski-Górecki Invisible Things Lab A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On 07/28/2017 05:33 PM, Marek Marczykowski-Górecki wrote: > On Fri, Jul 28, 2017 at 05:24:10PM -0600, Jim Fehlig wrote: >> 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. > You can override only dynamic symbols this way. If the function is in > the same object (or even the same shared library), it is resolved at > link time, not load time. Yep, understood. I think it is time for you to post your patch using /bin/true as emulator :-). -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2024 Red Hat, Inc.