On Mon, Jan 17, 2022 at 01:39:31PM +0100, Michal Prívozník wrote:
On 1/17/22 13:37, Andrea Bolognani wrote:
> On Mon, Jan 17, 2022 at 01:11:29PM +0100, Michal Prívozník wrote:
>> On 1/14/22 17:49, Andrea Bolognani wrote:
>>> This all works, but I wonder if we couldn't just create a trivial
>>> shell script that behaves minimally the way we expect dnsmasq to, and
>>> change our virFindFileInPath() mock so that it returns the absolute
>>> path to it? That way we wouldn't need to implement any additional
>>> mocking and the code would end up being much simpler. Diff below.
>>
>> I thought that we should avoid shell for new contributions:
>>
>>
https://libvirt.org/programming-languages.html
>
> Fair enough. Python version below.
>
>
> #!/usr/bin/env python3
>
> import sys
>
> output = {
> "--version": "Dnsmasq version 2.67",
> "--help": "--bind-dynamic\n--ra-param",
> }
>
> if len(sys.argv) != 2 or sys.argv[1] not in output:
> print("invalid usage")
> sys.exit(1)
>
> print(output[sys.argv[1]])
And what exactly is the point? I'm failing to see why this would be any
better than mocking virCommand. Can you elaborate please?
I believe the diffstats speak for themselves :)
$ git diff --stat df09e45310..64325fa9ef
tests/networkmock.c | 16 ++++++++++++++++
tests/networkxml2conftest.c | 38 +++++++++++++++++++++++++++++++++++++-
2 files changed, 53 insertions(+), 1 deletion(-)
$ git diff --stat df09e45310..2b64fb492b
tests/networkmock.c | 2 +-
tests/networkxml2conftest.c | 2 +-
tests/virdnsmasqmock.py | 14 ++++++++++++++
3 files changed, 16 insertions(+), 2 deletions(-)
--
Andrea Bolognani / Red Hat / Virtualization